1 from PhysicsTools.HeppyCore.framework.analyzer
import Analyzer
2 from PhysicsTools.Heppy.analyzers.AutoHandle
import AutoHandle
3 from PhysicsTools.HeppyCore.statistics.counter
import Counter
4 from PhysicsTools.HeppyCore.utils.TriggerList
import TriggerList
5 from PhysicsTools.HeppyCore.utils.TriggerMatching
import selTriggerObjects
6 from PhysicsTools.Heppy.physicsobjects.PhysicsObjects
import TriggerObject
11 '''Access to trigger information, and trigger selection'''
16 self.handles[
'cmgTriggerObjectSel'] = AutoHandle(
17 'cmgTriggerObjectSel',
18 'std::vector<cmg::TriggerObject>'
21 self.handles[
'cmgTriggerObjectListSel'] = AutoHandle(
22 'cmgTriggerObjectListSel',
23 'std::vector<cmg::TriggerObject>'
27 super(TriggerAnalyzer,self).
beginLoop(setup)
29 if hasattr(self.cfg_comp,
'vetoTriggers'):
34 self.counters.addCounter(
'Trigger')
35 self.counters.counter(
'Trigger').register(
'All events')
36 self.counters.counter(
'Trigger').register(
'HLT')
40 self.readCollections( iEvent )
42 event.triggerObject = self.handles[
'cmgTriggerObjectSel'].product()[0]
43 run = iEvent.eventAuxiliary().id().
run()
44 lumi = iEvent.eventAuxiliary().id().luminosityBlock()
45 eventId = iEvent.eventAuxiliary().id().
event()
49 event.eventId = eventId
54 self.counters.counter(
'Trigger').inc(
'All events')
57 if hasattr( self.cfg_ana,
'usePrescaled'):
58 usePrescaled = self.cfg_ana.usePrescaled
61 passed, hltPath = self.triggerList.triggerPassed(event.triggerObject,
62 run, lumi, self.cfg_comp.isData,
63 usePrescaled = usePrescaled)
69 if self.vetoTriggerList
is not None:
70 veto,hltVetoPath = self.vetoTriggerList.triggerPassed(event.triggerObject,
71 run,lumi,self.cfg_comp.isData,
72 usePrescaled = usePrescaled)
75 keepFailingEvents =
False
76 if hasattr( self.cfg_ana,
'keepFailingEvents'):
77 keepFailingEvents = self.cfg_ana.keepFailingEvents
78 if not passed
or (passed
and veto):
79 event.passedTriggerAnalyzer =
False
80 if not keepFailingEvents:
83 event.passedTriggerAnalyzer =
True
85 event.hltPath = hltPath
87 if hltPath
is not None:
88 trigObjs = map( TriggerObject,
89 self.handles[
'cmgTriggerObjectListSel'].product())
91 event.triggerObjects = selTriggerObjects( trigObjs, hltPath )
93 self.counters.counter(
'Trigger').inc(
'HLT')
94 event.TriggerFired = 1
98 print 'writing TriggerAnalyzer'
99 super(TriggerAnalyzer, self).
write(setup)
100 self.triggerList.write( self.dirName )
103 tmp = super(TriggerAnalyzer,self).
__str__()
104 triglist = str( self.triggerList )
105 return '\n'.
join( [tmp, triglist ] )
static std::string join(char **cmd)