5 '''@file TrigTLAMonitorAlgorithm.py
9 @brief Example trigger python configuration for the Run III AthenaMonitoring package, based on the example by C Burton and P Onyisi
14 Read in the TLA trigger chain names as submitted to the MonGroups
18 from TrigConfigSvc.TriggerConfigAccess
import getHLTMonitoringAccess
20 TLAChainsE=moniAccess.monitoredChains(signatures=
"tlaMon",monLevels=[
"t0"])
22 log.info (
" ==> tla_chainlist t0: %s", TLAChainsE)
23 for chain
in TLAChainsE:
25 tla_triglist.append(chain)
26 TLAChainsS=moniAccess.monitoredChains(signatures=
"tlaMon",monLevels=[
"shifter"])
28 log.info (
" ==> tla_chainlist shifter: %s", TLAChainsS)
29 for chain
in TLAChainsS:
31 tla_triglist.append(chain)
33 log.info (
" ==> tla_triglist: %s", tla_triglist)
38 '''Function to configures some algorithms in the monitoring system.'''
40 from AthenaCommon.Logging
import logging
41 log = logging.getLogger(
'TrigTLAMonitorAlgorithm.py' )
52 from AthenaMonitoring
import AthMonitorCfgHelper
53 helper = AthMonitorCfgHelper(inputFlags,
'TrigTLAAthMonitorCfg')
58 from AthenaConfiguration.ComponentFactory
import CompFactory
59 trigTLAMonAlg = helper.addAlgorithm(CompFactory.TrigTLAMonitorAlgorithm,
'TrigTLAMonAlg')
66 trigTLAMonAlg.TriggerChain =
''
67 trigTLAMonAlg.TriggerDecisionTool = tdt
74 TLAMonGroup = helper.addGroup(trigTLAMonAlg,
'TrigTLAMonitor',
'HLT/TLAMon/')
77 from TrigTLAMonitoring.TrigTLAMonitorHistograms
import (
78 histdefs_eventinfo, histdefs_particle, histdefs_tracks, histdefs_dR, histdefs_jetcalibscales, histdefs_jetvariables
89 histdefs+=histdefs_tracks (
'trk' ,
'track')
90 histdefs+=histdefs_dR (
'jet0' ,
'jet1' ,
'leading jet' ,
'subleading jet' )
91 histdefs+=histdefs_dR (
'pfjet0',
'pfjet1',
'leading pf jet',
'subleading pf jet')
92 histdefs+=histdefs_dR (
'jet0' ,
'ph0' ,
'leading jet' ,
'leading photon' )
93 histdefs+=histdefs_dR (
'pfjet0',
'ph0' ,
'leading pf jet',
'leading photon' )
101 for chain
in tla_triglist :
102 AllChains.append(chain[2:])
104 for histdef
in histdefs:
105 HistName = histdef[
'name'] +
'_' + chain[2:]
107 xlabel=histdef.get(
'xlabel',histdef[
'name' ])
108 if 'xunit' in histdef:
109 xlabel+=f
' [{histdef["xunit"]}'
110 ylabel=histdef.get(
'ylabel',histdef[
'ylabel'])
112 if chain[0:1] ==
"E" :
113 TLAMonGroup.defineHistogram(HistName, title=f
'Distribution of {histdef["name"]};{xlabel};{ylabel}',
114 path=
'Expert/' +chain[2:],xbins=histdef[
'xbins'],xmin=histdef[
'xmin'],xmax=histdef[
'xmax'])
115 if chain[0:1] ==
"S" :
116 TLAMonGroup.defineHistogram(HistName, title=f
'Distribution of {histdef["name"]};{xlabel};{ylabel}',
117 path=
'Shifter/'+chain[2:],xbins=histdef[
'xbins'],xmin=histdef[
'xmin'],xmax=histdef[
'xmax'])
120 for histdef
in histdefs_global:
121 HistName = histdef[
'name']
122 xlabel=histdef.get(
'xlabel',histdef[
'name' ])
123 if 'xunit' in histdef:
124 xlabel+=f
' [{histdef["xunit"]}'
125 ylabel=histdef.get(
'ylabel',histdef[
'ylabel'])
126 TLAMonGroup.defineHistogram(HistName, title=f
'Distribution of {histdef["name"]};{xlabel};{ylabel}',
127 path=
'Expert/EventInfo',xbins=histdef[
'xbins'],xmin=histdef[
'xmin'],xmax=histdef[
'xmax'])
129 log.info (
" ==> In TrigTLAMonitorAlgorithm.py: AllChains list: %s", AllChains)
130 trigTLAMonAlg.AllChains = AllChains
137 return helper.result()
140 if __name__==
'__main__':
143 parser = argparse.ArgumentParser()
145 parser.add_argument(
'input',nargs=
'?',default=
'/afs/cern.ch/work/e/enagy/public/ARTfiles/MCtest160322.AOD.pool.root')
146 parser.add_argument(
'--data',action=
'store_true',help=
'Input file is data.')
147 parser.add_argument(
'--nevents',type=int,default=-1,help=
'Number of events to process.')
148 args = parser.parse_args()
151 from AthenaCommon.Logging
import log
158 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
162 flags.Exec.MaxEvents = args.nevents
165 flags.Input.Files = [args.input]
166 flags.Input.isMC =
not args.data
169 flags.Output.HISTFileName =
'TrigTLAMonitorOutput.root'
172 flags.Trigger.triggerMenuSetup =
'Physics_pp_run3_v1'
173 flags.Trigger.triggerConfig =
'DB'
178 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
179 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
184 from TrigDecisionTool.TrigDecisionToolConfig
import TrigDecisionToolCfg
188 from AthenaCommon.CFElements
import seqAND, seqOR
189 cfg.addSequence(
seqOR(
"monSeq") )
192 cfg.addSequence(
seqAND(
"trackAugmentSeq"), parentName=
"monSeq")
193 pfChains=[trig[2:]
for trig
in tla_chains(flags)
if 'pf_ftf' in trig]
194 from AthenaConfiguration.ComponentFactory
import CompFactory
196 CompFactory.CP.TrigEventSelectionAlg(triggers=pfChains,tool=tdt,noL1=
True),
197 sequenceName=
"trackAugmentSeq",
199 from BTagging.BTagTrackAugmenterAlgConfig
import BTagTrackAugmenterAlgCfg
203 TrackCollection=
'HLT_IDTrack_FS_FTF',
204 PrimaryVertexCollectionName=
'HLT_IDVertex_FS',
206 sequenceName=
"trackAugmentSeq"
213 sequenceName=
"monSeq"
219 cfg.printConfig(withDetails=
False)