1 from __future__
import print_function
2 from PhysicsTools.HeppyCore.framework.analyzer
import Analyzer
3 from PhysicsTools.Heppy.analyzers.AutoHandle
import AutoHandle
4 from PhysicsTools.HeppyCore.statistics.counter
import Counter
5 from PhysicsTools.HeppyCore.utils.TriggerList
import TriggerList
6 from PhysicsTools.HeppyCore.utils.TriggerMatching
import selTriggerObjects
7 from PhysicsTools.Heppy.physicsobjects.PhysicsObjects
import TriggerObject
12 '''Access to trigger information, and trigger selection''' 17 self.handles[
'cmgTriggerObjectSel'] = AutoHandle(
18 'cmgTriggerObjectSel',
19 'std::vector<cmg::TriggerObject>' 22 self.handles[
'cmgTriggerObjectListSel'] = AutoHandle(
23 'cmgTriggerObjectListSel',
24 'std::vector<cmg::TriggerObject>' 28 super(TriggerAnalyzer,self).
beginLoop(setup)
30 if hasattr(self.cfg_comp,
'vetoTriggers'):
35 self.counters.addCounter(
'Trigger')
36 self.counters.counter(
'Trigger').register(
'All events')
37 self.counters.counter(
'Trigger').register(
'HLT')
41 self.readCollections( iEvent )
43 event.triggerObject = self.handles[
'cmgTriggerObjectSel'].product()[0]
44 run = iEvent.eventAuxiliary().
id().
run()
45 lumi = iEvent.eventAuxiliary().
id().luminosityBlock()
46 eventId = iEvent.eventAuxiliary().
id().
event()
50 event.eventId = eventId
55 self.counters.counter(
'Trigger').inc(
'All events')
58 if hasattr( self.cfg_ana,
'usePrescaled'):
59 usePrescaled = self.cfg_ana.usePrescaled
62 passed, hltPath = self.triggerList.triggerPassed(event.triggerObject,
63 run, lumi, self.cfg_comp.isData,
64 usePrescaled = usePrescaled)
70 if self.vetoTriggerList
is not None:
71 veto,hltVetoPath = self.vetoTriggerList.triggerPassed(event.triggerObject,
72 run,lumi,self.cfg_comp.isData,
73 usePrescaled = usePrescaled)
76 keepFailingEvents =
False 77 if hasattr( self.cfg_ana,
'keepFailingEvents'):
78 keepFailingEvents = self.cfg_ana.keepFailingEvents
79 if not passed
or (passed
and veto):
80 event.passedTriggerAnalyzer =
False 81 if not keepFailingEvents:
84 event.passedTriggerAnalyzer =
True 86 event.hltPath = hltPath
88 if hltPath
is not None:
89 trigObjs =
map( TriggerObject,
90 self.handles[
'cmgTriggerObjectListSel'].product())
92 event.triggerObjects = selTriggerObjects( trigObjs, hltPath )
94 self.counters.counter(
'Trigger').inc(
'HLT')
95 event.TriggerFired = 1
99 print(
'writing TriggerAnalyzer')
100 super(TriggerAnalyzer, self).
write(setup)
101 self.triggerList.write( self.dirName )
104 tmp = super(TriggerAnalyzer,self).
__str__()
105 triglist =
str( self.triggerList )
106 return '\n'.
join( [tmp, triglist ] )
def beginLoop(self, setup)
S & print(S &os, JobReport::InputFile const &f)
def process(self, iEvent, event)
static std::string join(char **cmd)