Skip to content

Commit

Permalink
Merge pull request #63 from MadAnalysis/sharedlib
Browse files Browse the repository at this point in the history
Substructure to Shared Library
  • Loading branch information
BFuks committed May 18, 2022
2 parents ffbf4d1 + fbe64c8 commit a2ff644
Show file tree
Hide file tree
Showing 49 changed files with 4,315 additions and 2,074 deletions.
16 changes: 10 additions & 6 deletions madanalysis/IOinterface/job_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,16 +708,20 @@ def WriteMakefiles(self, option="", **kwargs):
options.has_process = True
# @JACK enable usage of fastjet
# If there are any root files, fastjet clusterer should not run with MA5_FASTJET_MODE Flag
options.ma5_fastjet_mode = (
all([all([('root' not in x) for x in dataset.filenames]) for dataset in self.main.datasets])
and self.main.archi_info.has_fastjet
and kwargs.get('ma5_fastjet_mode',True)
and self.main.fastsim.package == 'fastjet'
)
options.ma5_fastjet_mode = self.main.archi_info.has_fastjet and self.main.archi_info.has_fjcontrib
options.has_fastjet_lib = self.main.archi_info.has_fastjet
options.has_fastjet_ma5lib = self.main.archi_info.has_fastjet
# @JACK: fastjet_inc is required to be able to use the FJ files when FJ mode is on
options.has_fastjet_inc = self.main.archi_info.has_fastjet
# @Jack: add substructure library
options.has_substructure = self.main.archi_info.has_fastjet and self.main.archi_info.has_fjcontrib
# @Jack: add HTT library
options.has_heptoptagger = (
self.main.archi_info.has_fastjet and \
self.main.archi_info.has_fjcontrib and \
self.main.archi_info.has_heptoptagger
)

options.has_root_inc = self.main.archi_info.has_root
options.has_root_lib = self.main.archi_info.has_root
#options.has_userpackage = True
Expand Down
76 changes: 63 additions & 13 deletions madanalysis/IOinterface/library_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@


from __future__ import absolute_import
from madanalysis.selection.instance_name import InstanceName
from madanalysis.IOinterface.folder_writer import FolderWriter
from madanalysis.IOinterface.job_writer import JobWriter
from string_tools import StringTools
from shell_command import ShellCommand
import logging
import shutil
import os
import subprocess
from six.moves import input


Expand Down Expand Up @@ -126,6 +121,8 @@ def WriteMakefileForInterfaces(self,package):
filename = self.path+"/SampleAnalyzer/Test/Makefile_zlib"
elif package=='test_fastjet':
filename = self.path+"/SampleAnalyzer/Test/Makefile_fastjet"
elif package=='test_htt':
filename = self.path+"/SampleAnalyzer/Test/Makefile_htt"
elif package=='test_delphes':
filename = self.path+"/SampleAnalyzer/Test/Makefile_delphes"
elif package=='test_delphesMA5tune':
Expand All @@ -149,6 +146,8 @@ def WriteMakefileForInterfaces(self,package):
title='*zlib-interface* test'
elif package=='test_fastjet':
title='*fastjet-interface* test'
elif package=='test_htt':
title='*htt-interface* test'
elif package=='test_delphes':
title='*delphes-interface* test'
elif package=='test_delphesMA5tune':
Expand All @@ -173,6 +172,49 @@ def WriteMakefileForInterfaces(self,package):
options.has_fastjet_inc=True
# options.has_fastjet_lib=True
toRemove.extend(['compilation_fastjet.log','linking_fastjet.log','cleanup_fastjet.log','mrproper_fastjet.log','../Bin/TestFastjet.log'])
elif package == "substructure":
options.has_commons=True
options.has_fastjet_inc=True
options.has_fastjet_lib=True
# @JACK: To be able to use fastjet in Ma5 data structure
options.ma5_fastjet_mode=True
options.has_fjcontrib = True
options.has_nsubjettiness = True
toRemove.extend(
['compilation_substructure.log',
'linking_substructure.log',
'cleanup_substructure.log',
'mrproper_substructure.log']
)
elif package == "HEPTopTagger":
options.has_commons=True
options.has_fastjet_inc=True
options.has_fastjet_lib=True
# @JACK: To be able to use fastjet in Ma5 data structure
options.ma5_fastjet_mode=True
options.has_nsubjettiness = True
options.has_substructure = True
toRemove.extend(
['compilation_heptoptagger.log',
'linking_heptoptagger.log',
'cleanup_heptoptagger.log',
'mrproper_heptoptagger.log']
)
elif package == "test_htt":
options.has_commons=True
options.has_fastjet_inc=True
# options.has_fastjet_lib=True
# @JACK: To be able to use fastjet in Ma5 data structure
options.ma5_fastjet_mode=True
options.has_fastjet_ma5lib = True
options.has_substructure = True
options.has_heptoptagger = True
toRemove.extend(
['compilation_test_heptoptagger.log',
'linking_test_heptoptagger.log',
'cleanup_test_heptoptagger.log',
'mrproper_test_heptoptagger.log']
)
elif package=='configuration':
toRemove.extend(['compilation.log','linking.log','cleanup.log','mrproper.log'])
elif package=='commons':
Expand Down Expand Up @@ -264,6 +306,7 @@ def WriteMakefileForInterfaces(self,package):
options.has_fastjet_inc = self.main.archi_info.has_fastjet
options.has_fastjet_lib = self.main.archi_info.has_fastjet
options.ma5_fastjet_mode = self.main.archi_info.has_fastjet
options.has_substructure = self.main.archi_info.has_fjcontrib and self.main.archi_info.has_fastjet

toRemove.extend(['compilation.log','linking.log','cleanup.log','mrproper.log'])
elif package=='test_process':
Expand Down Expand Up @@ -299,6 +342,9 @@ def WriteMakefileForInterfaces(self,package):
elif package=='test_fastjet':
cppfiles = ['Fastjet/*.cpp']
hfiles = ['Fastjet/*.h']
elif package=='test_htt':
cppfiles = ['HEPTopTagger/*.cpp']
hfiles = ['HEPTopTagger/*.h']
elif package=='test_delphes':
cppfiles = ['Delphes/*.cpp']
hfiles = ['Delphes/*.h']
Expand Down Expand Up @@ -333,6 +379,10 @@ def WriteMakefileForInterfaces(self,package):
isLibrary=False
ProductName='TestFastjet'
ProductPath='../Bin/'
elif package=='test_htt':
isLibrary=False
ProductName='TestHEPTopTagger'
ProductPath='../Bin/'
elif package=='test_root':
isLibrary=False
ProductName='TestRoot'
Expand Down Expand Up @@ -366,15 +416,15 @@ def Compile(self,ncores,package,folder):
# log file name
if package in ['process','commons','test','configuration']:
logfile = folder+'/compilation.log'
elif package in ['test_process','test_commons','test_zlib','test_fastjet','test_root','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_fastjet', "test_htt", 'test_root','test_delphes','test_delphesMA5tune']:
logfile = folder+'/compilation_'+package[5:]+'.log'
else:
logfile = folder+'/compilation_'+package+'.log'

# makefile
if package in ['process','commons','test','configuration']:
makefile = 'Makefile'
elif package in ['test_process','test_commons','test_zlib','test_fastjet','test_root','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_fastjet', "test_htt", 'test_root','test_delphes','test_delphesMA5tune']:
makefile = 'Makefile_'+package[5:]
else:
makefile = 'Makefile_'+package
Expand All @@ -401,15 +451,15 @@ def Link(self,package,folder):
# log file name
if package in ['process','commons','test','configuration']:
logfile = folder+'/linking.log'
elif package in ['test_process','test_commons','test_zlib','test_fastjet','test_root','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_fastjet',"test_htt",'test_root','test_delphes','test_delphesMA5tune']:
logfile = folder+'/linking_'+package[5:]+'.log'
else:
logfile = folder+'/linking_'+package+'.log'

# makefile
if package in ['process','commons','test','configuration']:
makefile = 'Makefile'
elif package in ['test_process','test_commons','test_zlib','test_fastjet','test_root','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_fastjet',"test_htt",'test_root','test_delphes','test_delphesMA5tune']:
makefile = 'Makefile_'+package[5:]
else:
makefile = 'Makefile_'+package
Expand All @@ -433,15 +483,15 @@ def Clean(self,package,folder):
# log file name
if package in ['process','commons','configuration','test']:
logfile = folder+'/cleanup.log'
elif package in ['test_process','test_commons','test_zlib','test_fastjet','test_root','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_fastjet',"test_htt",'test_root','test_delphes','test_delphesMA5tune']:
logfile = folder+'/cleanup_'+package[5:]+'.log'
else:
logfile = folder+'/cleanup_'+package+'.log'

# makefile
if package in ['process','commons','test','configuration']:
makefile = 'Makefile'
elif package in ['test_process','test_commons','test_zlib','test_fastjet','test_root','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_fastjet',"test_htt",'test_root','test_delphes','test_delphesMA5tune']:
makefile = 'Makefile_'+package[5:]
else:
makefile = 'Makefile_'+package
Expand All @@ -465,7 +515,7 @@ def MrProper(self,package,folder):
# log file name
if package in ['process','commons','configuration']:
logfile = folder+'/mrproper.log'
elif package in ['test_process','test_commons','test_zlib','test_root','test_fastjet','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_root','test_fastjet',"test_htt",'test_delphes','test_delphesMA5tune']:
logfile = folder+'/mrproper_'+package[5:]+'.log'
else:
logfile = folder+'/mrproper_'+package+'.log'
Expand All @@ -475,7 +525,7 @@ def MrProper(self,package,folder):
# makefile
if package in ['process','commons','test','configuration']:
makefile = 'Makefile'
elif package in ['test_process','test_commons','test_zlib','test_root','test_fastjet','test_delphes','test_delphesMA5tune']:
elif package in ['test_process','test_commons','test_zlib','test_root','test_fastjet',"test_htt",'test_delphes','test_delphesMA5tune']:
makefile = 'Makefile_'+package[5:]
else:
makefile = 'Makefile_'+package
Expand Down
32 changes: 24 additions & 8 deletions madanalysis/build/makefile_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ def __init__(self):
self.has_fastjet_tag = False
# @JACK: cant use FASTJET_USE tag, it clashes with ROOT
self.ma5_fastjet_mode = False
self.has_fjcontrib = False
self.has_substructure = False
self.has_heptoptagger = False
self.has_nsubjettiness = False

self.has_delphes_tag = False
self.has_delphesMA5tune_tag = False
self.has_root_tag = False
Expand Down Expand Up @@ -363,7 +368,6 @@ def Makefile(
if options.has_zlib_ma5lib:
libs.extend(['-lzlib_for_ma5'])
if options.has_zlib_lib:
# libs.extend(['-L'+archi_info.zlib_lib_path,'-lz'])
libs.extend(['-lz'])
file.write('LIBFLAGS += '+' '.join(libs)+'\n')

Expand All @@ -386,22 +390,25 @@ def Makefile(
if options.has_fastjet_ma5lib:
libs.extend(['-lfastjet_for_ma5'])
if options.has_fastjet_lib:
# libs.extend(['$(shell fastjet-config --libs --plugins)']) # --rpath=no)'])
libs.extend(['$(shell $(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/fastjet-config --libs --plugins)'])
file.write('LIBFLAGS += '+' '.join(libs)+'\n')
libs=[]
if options.has_fjcontrib:
# Add fjcontrib libraries
libs.extend(["-lRecursiveTools"]) # SoftDrop
libs.extend(["-lNsubjettiness"]) # Nsubjettiness
libs.extend(["-lVariableR"]) # VariableR
libs.extend(["-lEnergyCorrelator"]) # -lEnergyCorrelator
file.write('LIBFLAGS += '+' '.join(libs)+'\n')
if options.has_nsubjettiness:
libs.extend(["-lNsubjettiness"]) # Nsubjettiness
if options.has_nsubjettiness or options.has_fjcontrib:
file.write('LIBFLAGS += '+' '.join(libs)+'\n')

# - delphes
if options.has_delphes_ma5lib or options.has_delphes_lib:
libs=[]
if options.has_delphes_ma5lib:
libs.extend(['-ldelphes_for_ma5'])
if options.has_delphes_lib:
# libs.extend(['-L'+archi_info.delphes_lib_paths[0],'-lDelphes'])
libs.extend(['-lDelphes'])
file.write('LIBFLAGS += '+' '.join(libs)+'\n')

Expand All @@ -411,10 +418,17 @@ def Makefile(
if options.has_delphesMA5tune_ma5lib:
libs.extend(['-ldelphesMA5tune_for_ma5'])
if options.has_delphesMA5tune_lib:
# libs.extend(['-L'+archi_info.delphesMA5tune_lib_paths[0],'-lDelphesMA5tune'])
libs.extend(['-lDelphesMA5tune'])
file.write('LIBFLAGS += '+' '.join(libs)+'\n')

# Substructure module
if options.has_substructure:
file.write('LIBFLAGS += -lsubstructure_for_ma5\n')

# HEPTopTagger module
if options.has_heptoptagger:
file.write('LIBFLAGS += -lHEPTopTagger_for_ma5\n')

# - Commons
if options.has_commons:
libs=[]
Expand All @@ -423,8 +437,6 @@ def Makefile(

# - Root
libs=[]
#libs.extend(['-L'+archi_info.root_lib_path, \
# '-lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lEG'])
# becareful: to not forget -lEG
if options.has_root:
libs.extend(['$(shell $(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/root-config --libs)','-lEG'])
Expand All @@ -448,6 +460,10 @@ def Makefile(
libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelphesMA5tune_for_ma5.so')
if options.has_fastjet_ma5lib:
libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so')
if options.has_substructure:
libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libsubstructure_for_ma5.so')
if options.has_heptoptagger:
libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libHEPTopTagger_for_ma5.so')
if len(libs)!=0:
file.write('# Requirements to check before building\n')
for ind in range(0,len(libs)):
Expand Down

0 comments on commit a2ff644

Please sign in to comment.