diff --git a/CMGTools/TTHAnalysis/cfg/run_susyMultilepton_cfg.py b/CMGTools/TTHAnalysis/cfg/run_susyMultilepton_cfg.py index e0baa9069ed26..5d753e540cec8 100644 --- a/CMGTools/TTHAnalysis/cfg/run_susyMultilepton_cfg.py +++ b/CMGTools/TTHAnalysis/cfg/run_susyMultilepton_cfg.py @@ -16,6 +16,9 @@ #ttHLepSkim.ptCuts = [] +# switch off slow photon MC matching +photonAna.do_mc_match = False + # Event Analyzer for susy multi-lepton (at the moment, it's the TTH one) from CMGTools.TTHAnalysis.analyzers.ttHLepEventAnalyzer import ttHLepEventAnalyzer ttHEventAna = cfg.Analyzer( @@ -57,9 +60,9 @@ #-------- SAMPLES AND TRIGGERS ----------- #-------- SEQUENCE -from CMGTools.TTHAnalysis.samples.samples_13TeV_PHYS14 import TTH_PU40bx25, SMS_T1tttt_2J_mGl1500_mLSP100 +from CMGTools.TTHAnalysis.samples.samples_13TeV_PHYS14 import * -selectedComponents = [ TTH_PU40bx25 ] +selectedComponents = [ SMS_T1tttt_2J_mGl1200_mLSP800 ] sequence = cfg.Sequence(susyCoreSequence+[ ttHEventAna, @@ -68,11 +71,22 @@ test = 1 if test == 1: - comp = TTH_PU40bx25; comp.name = "TTH" + comp = TTH; comp.name = "TTH" #comp = SMS_T1tttt_2J_mGl1500_mLSP100 comp.files = comp.files[:1] comp.splitFactor = 1 + comp.fineSplitFactor = 4 selectedComponents = [ comp ] +elif test == 2: + for comp in selectedComponents: + comp.files = comp.files[:1] + comp.splitFactor = 1 +elif test == 3: + comp = TTJets + comp.files = comp.files[:1] + comp.splitFactor = 1 + selectedComponents = [ comp ] + # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events diff --git a/CMGTools/TTHAnalysis/python/analyzers/susyCore_modules_cff.py b/CMGTools/TTHAnalysis/python/analyzers/susyCore_modules_cff.py index 22a1404389de8..09520edda1884 100644 --- a/CMGTools/TTHAnalysis/python/analyzers/susyCore_modules_cff.py +++ b/CMGTools/TTHAnalysis/python/analyzers/susyCore_modules_cff.py @@ -189,7 +189,8 @@ photons='slimmedPhotons', ptMin = 20, etaMax = 2.5, - gammaID = "PhotonCutBasedIDLoose_CSA14" + gammaID = "PhotonCutBasedIDLoose_CSA14", + do_mc_match = True, ) diff --git a/CMGTools/TTHAnalysis/python/plotter/bins/validation_plots.txt b/CMGTools/TTHAnalysis/python/plotter/bins/validation_plots.txt index b70f29b2ec284..b54c296df1db4 100644 --- a/CMGTools/TTHAnalysis/python/plotter/bins/validation_plots.txt +++ b/CMGTools/TTHAnalysis/python/plotter/bins/validation_plots.txt @@ -13,8 +13,8 @@ lep1sip3d: LepGood1_sip3d: 15,0,5; Legend='TR' lep2sip3d: LepGood2_sip3d: 15,0,5; Legend='TR' lep1tightId: LepGood1_tightId: [-0.5,0.5,1.5]; Legend='TL' lep2tightId: LepGood2_tightId: [-0.5,0.5,1.5]; Legend='TL' -lep1mvaTTH: LepGood1_mvaTTH: 20,-1,1; Legend='TL' -lep2mvaTTH: LepGood2_mvaTTH: 20,-1,1; Legend='TL' +lep1mvaSusy: LepGood1_mvaSusy: 20,-1,1; Legend='TL' +lep2mvaSusy: LepGood2_mvaSusy: 20,-1,1; Legend='TL' lep1mcMatchId: abs(LepGood1_mcMatchId): 28,-1.5,26.5; Legend='TR' lep2mcMatchId: abs(LepGood2_mcMatchId): 28,-1.5,26.5; Legend='TR' lep1mcMatchAny: LepGood1_mcMatchAny: [-1.5,-0.5,0.5,1.5,2.5,3.5]; Legend='TR' diff --git a/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py b/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py index d0c7a0e2a9616..799dbe26afedf 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py +++ b/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py @@ -50,7 +50,6 @@ def declareCoreVariables(self, tr, isMC): tr.var('lumi', int, storageType="i") tr.var('evt', int, storageType="i") tr.var('isData', int) - tr.var('xsec', float) # self.triggerBitCheckers = [] # if hasattr(self.cfg_ana, 'triggerBits'): @@ -62,6 +61,8 @@ def declareCoreVariables(self, tr, isMC): # self.triggerBitCheckers.append( (T, TriggerBitChecker(trigVec)) ) if isMC: + ## cross section + tr.var('xsec', float) ## PU weights tr.var("puWeight") ## number of true interactions @@ -109,13 +110,14 @@ def fillCoreVariables(self, tr, event, isMC): tr.fill('lumi',event.input.eventAuxiliary().id().luminosityBlock()) tr.fill('evt', event.input.eventAuxiliary().id().event()) tr.fill('isData', 0 if isMC else 1) - tr.fill('xsec',self.cfg_comp.xSection) # triggerResults = self.handles['TriggerResults'].product() # for T,TC in self.triggerBitCheckers: # tr.fill("HLT_"+T, TC.check(event.object(), triggerResults)) if isMC: + ## xsection, if available + tr.fill('xsec', getattr(self.cfg_comp,'xSection',1.0)) ## PU weights, check if a PU analyzer actually filled it if hasattr(event,"nPU"): tr.fill("nTrueInt", event.nPU) diff --git a/PhysicsTools/Heppy/python/physicsobjects/GenParticle.py b/PhysicsTools/Heppy/python/physicsobjects/GenParticle.py index 984800b34a5bf..bc2f7946b4d90 100644 --- a/PhysicsTools/Heppy/python/physicsobjects/GenParticle.py +++ b/PhysicsTools/Heppy/python/physicsobjects/GenParticle.py @@ -14,4 +14,5 @@ def printGenParticle(self): return theStr setattr(ROOT.reco.GenParticle,"__str__",printGenParticle) -from ROOT.reco import GenParticle +#from ROOT.reco import GenParticle # sometimes doesn't work +GenParticle = ROOT.reco.GenParticle # this instead does diff --git a/PhysicsTools/HeppyCore/python/framework/heppy.py b/PhysicsTools/HeppyCore/python/framework/heppy.py index c62cb44ef9659..f83483f2d7780 100755 --- a/PhysicsTools/HeppyCore/python/framework/heppy.py +++ b/PhysicsTools/HeppyCore/python/framework/heppy.py @@ -48,7 +48,8 @@ def runLoop( comp, outDir, config, options): loop = Looper( fullName, config, options.nevents, 0, - nPrint = options.nprint) + nPrint = options.nprint, + timeReport = options.timeReport) print loop if options.iEvent is None: loop.loop() @@ -202,6 +203,12 @@ def main( options, args ): action='store_true', help="stay in the command line prompt instead of exiting", default=False) + parser.add_option("-t", "--timereport", + dest="timeReport", + action='store_true', + help="Make a report of the time used by each analyzer", + default=False) + (options,args) = parser.parse_args() diff --git a/PhysicsTools/HeppyCore/python/framework/looper.py b/PhysicsTools/HeppyCore/python/framework/looper.py index 31802988e229d..23ca23ecd2f9b 100644 --- a/PhysicsTools/HeppyCore/python/framework/looper.py +++ b/PhysicsTools/HeppyCore/python/framework/looper.py @@ -10,7 +10,7 @@ from platform import platform from math import ceil from event import Event -import time +import timeit class Setup(object): '''The Looper creates a Setup object to hold information relevant during @@ -52,7 +52,7 @@ class Looper(object): def __init__( self, name, config, nEvents=None, - firstEvent=0, nPrint=0 ): + firstEvent=0, nPrint=0, timeReport=False ): """Handles the processing of an event sample. An Analyzer is built for each Config.Analyzer present in sequence. The Looper can then be used to process an event, @@ -79,6 +79,7 @@ def __init__( self, name, self.nEvents = nEvents self.firstEvent = firstEvent self.nPrint = int(nPrint) + self.timeReport = [ {'time':0.0,'events':0} for a in self.analyzers ] if timeReport else False tree_name = None if( hasattr(self.cfg_comp, 'tree_name') ): tree_name = self.cfg_comp.tree_name @@ -158,10 +159,10 @@ def loop(self): # print 'event', iEv if not hasattr(self,'start_time'): print 'event', iEv - self.start_time = time.time() + self.start_time = timeit.default_timer() self.start_time_event = iEv else: - print 'event %d (%.1f ev/s)' % (iEv, (iEv-self.start_time_event)/float(time.time() - self.start_time)) + print 'event %d (%.1f ev/s)' % (iEv, (iEv-self.start_time_event)/float(timeit.default_timer() - self.start_time)) self.process( iEv ) if iEv 0: + self.timeReport[i]['time'] += timeit.default_timer() - start + if ret == False: return (False, analyzer.name) return (True, analyzer.name) @@ -201,6 +208,15 @@ def write(self): for analyzer in self.analyzers: analyzer.write(self.setup) self.setup.close() + + if self.timeReport: + allev = max([x['events'] for x in self.timeReport]) + print "\n ---- TimeReport (all times in ms; first evt is skipped) ---- " + print "%9s %9s %9s %9s %s" % ("processed","all evts","time/proc", " time/all", "analyer") + print "%9s %9s %9s %9s %s" % ("---------","--------","---------", "---------", "-------------") + for ana,rep in zip(self.analyzers,self.timeReport): + print "%9d %9d %10.2f %10.2f %s" % ( rep['events'], allev, 1000*rep['time']/(rep['events']-1) if rep['events']>1 else 0, 1000*rep['time']/(allev-1) if allev > 1 else 0, ana.name) + print "" pass