def compileC(filename, target=None): global compiledir if not target is None: originaldir = compiledir compiledir = target from ROOT import gSystem if not gSystem.CompileMacro(filename, "k-", "", filedir+"/../"+compiledir): print "@@@@@ ERROR: Failed to compile", filename sys.exit(1) if not target is None: compiledir = originaldir
def __init__(self,macroName,functionName=None,libs=[], incs=[]): super(self.__class__,self).__init__() for lib in libs: gSystem.Load(lib) for inc in incs: gROOT.LoadMacro(inc) gSystem.CompileMacro(macroName) if functionName is not None: Runner.target = lambda s,x : getattr(root,functionName)(*x) self.functionName = functionName else: Runner.target = lambda s,x : getattr(root,macroName.replace('.C',''))(*x) self.functionName = macroName.replace('.C','') self.argList = None
#!/usr/bin/env python import os from ROOT import gSystem, TChain, TSystem, TFile from PSet import process gSystem.CompileMacro('HTTEvent.cxx') gSystem.CompileMacro('ScaleFactor.cc') gSystem.CompileMacro('HTauTauTreeBase.C') gSystem.CompileMacro('HTauTauTree.C') from ROOT import HTauTauTree fileNames = [] for aFile in process.source.fileNames: aFile = aFile.replace("Enriched_miniAOD", "HTauTauAnalysis") aFile = aFile.replace("/store", "root://cms-xrd-global.cern.ch///store") fileNames.append(aFile) print "Adding file: ", aFile aROOTFile = TFile.Open(aFile) aTree = aROOTFile.Get("HTauTauTree/HTauTauTree") print "TTree entries: ", aTree.GetEntries() HTauTauTree(aTree).Loop() #Merge files. command = "hadd -f WAW_HTauTauAnalysis.root WAW_HTauTauAnalysis_*.root" #os.system(command) #Produce framework report required by CRAB command = "cmsRun -j FrameworkJobReport.xml -p PSet.py"
from ROOT import gSystem, TChain, TSystem, TFile from PSet import process #doSvFit = True doSvFit = False applyRecoil = True #applyRecoil=False if doSvFit: print "Run with SVFit computation" if applyRecoil: print "Apply MET recoil corrections" #Some system have problem runnig compilation (missing glibc-static library?). #First we try to compile, and only ther we start time consuming cmssw status = gSystem.CompileMacro('HTTEvent.cxx') status *= gSystem.CompileMacro('NanoEventsSkeleton.C') gSystem.Load('$CMSSW_BASE/lib/$SCRAM_ARCH/libTauAnalysisClassicSVfit.so') gSystem.Load('$CMSSW_BASE/lib/$SCRAM_ARCH/libTauAnalysisSVfitTF.so') gSystem.Load( '$CMSSW_BASE/lib/$SCRAM_ARCH/libHTT-utilitiesRecoilCorrections.so') status *= gSystem.CompileMacro('HTauTauTreeFromNanoBase.C') status *= gSystem.CompileMacro('HMuTauhTreeFromNano.C') status *= gSystem.CompileMacro('HTauhTauhTreeFromNano.C') print "Compilation status: ", status if status == 0: exit(-1) from ROOT import HMuTauhTreeFromNano, HTauhTauhTreeFromNano fileNames = [
aTree = aTree.CopyTree("event == {0}".format(check_event)) entries = aTree.GetEntries() if not entries: print "file is empty. Aborting" exit(0) else: print "TTree entries: ", entries print "Compiling...." #Some system have problem runnig compilation (missing glibc-static library?). #First we try to compile, and only then we start time consuming cmssw assert gSystem.CompileMacro('HTTEvent.cxx', 'k') assert gSystem.CompileMacro('utils/TauTriggerSFs2017/src/TauTriggerSFs2017.cc', 'k') assert gSystem.CompileMacro('HTXSClassification.cc', 'k') assert gSystem.CompileMacro('EventWriter.C', 'k') #status *= gSystem.CompileMacro('NanoEventsSkeleton.C') #RECOMPILE IF IT CHANGES! assert gSystem.CompileMacro('NanoEventsSkeleton.C', 'k') gSystem.Load('$CMSSW_BASE/lib/$SCRAM_ARCH/libTauAnalysisClassicSVfit.so') gSystem.Load('$CMSSW_BASE/lib/$SCRAM_ARCH/libTauAnalysisSVfitTF.so') gSystem.Load( '$CMSSW_BASE/lib/$SCRAM_ARCH/libHTT-utilitiesRecoilCorrections.so') assert gSystem.CompileMacro('HTauTauTreeFromNanoBase.C', 'k') from ROOT import HTTParticle, HTTAnalysis
#!/usr/bin/env python import os from ROOT import gSystem, TChain, TSystem, TFile from PSet import process doSvFit = True if doSvFit: print "Run with SVFit computation" #Produce framework report required by CRAB command = "cmsRun -j FrameworkJobReport.xml -p PSet.py" os.system(command) gSystem.CompileMacro('HTTEvent.cxx') gSystem.Load( '$CMSSW_BASE/lib/slc6_amd64_gcc530/libTauAnalysisSVfitStandalone.so') gSystem.CompileMacro('HTauTauTreeBase.C') gSystem.CompileMacro('HTauTauTree.C') gSystem.CompileMacro('HTauhTauhTree.C') gSystem.CompileMacro('HMuMuTree.C') from ROOT import HTauTauTree from ROOT import HTauhTauhTree from ROOT import HMuMuTree fileNames = [] aFile = "file://./HTauTauAnalysis.root" fileNames.append(aFile) print "Adding file: ", aFile
nevents = -1 #all #nevents=5000 vlumis = vector('string')() nthreads = 6 print 'Channel: ', channel if doSvFit: print "Run with SVFit computation" if applyRecoil: print "Apply MET recoil corrections" #Some system have problem runnig compilation (missing glibc-static library?). #First we try to compile, and only then we start time consuming cmssw status = 1 gSystem.CompileMacro('HTTEvent.cxx', 'k') status *= gSystem.CompileMacro('syncDATA.C', 'k') #status *= gSystem.CompileMacro('NanoEventsSkeleton.C') #RECOMPILE IF IT CHANGES! status *= gSystem.CompileMacro('NanoEventsSkeleton.C', 'k') gSystem.Load('$CMSSW_BASE/lib/$SCRAM_ARCH/libTauAnalysisClassicSVfit.so') gSystem.Load('$CMSSW_BASE/lib/$SCRAM_ARCH/libTauAnalysisSVfitTF.so') gSystem.Load( '$CMSSW_BASE/lib/$SCRAM_ARCH/libHTT-utilitiesRecoilCorrections.so') # xline=gSystem.GetMakeSharedLib()+' -Wattributes' # xline=xline.replace(' -W ',' -W -Wattributes ') # gSystem.SetMakeSharedLib(xline) # print 'MMM ',gSystem.GetMakeSharedLib() # yline=gSystem.GetMakeExe()+' -Wattributes' # yline=yline.replace(' -W ',' -W -Wattributes ')