5 '''@file TrigHLTMonitorAlgorithm.py
7 @brief TrigHLTMonitoring general monitoring
12 '''Function to configure general HLT algorithms in the monitoring system.'''
16 from AthenaCommon.Logging
import logging
17 log_trighlt = logging.getLogger(
'TrigGeneralMonitorAlgorithm' )
21 from TrigConfigSvc.TriggerConfigAccess
import getHLTMenuAccess
22 from TrigConfigSvc.TriggerConfigAccess
import getL1MenuAccess
29 from AthenaMonitoring
import AthMonitorCfgHelper
30 helper = AthMonitorCfgHelper(inputFlags,
'TrigHLTAthMonitorCfg')
37 from AthenaConfiguration.ComponentFactory
import CompFactory
38 cfgsvc = CompFactory.TrigConf.xAODConfigSvc(
'xAODConfigSvc')
39 helper.resobj.addService(cfgsvc)
40 trigHLTMonAlg = helper.addAlgorithm(CompFactory.TrigHLTMonitorAlgorithm,
'TrigHLTMonAlg')
41 trigHLTMonAlg.TrigConfigSvc = cfgsvc
46 signature_names_regexes = [(
'HLT_AllChains',
'HLT_.*'),
47 (
'HLT_Electrons',
'HLT_[0-9]*e[0-9]+.*'),
48 (
'HLT_Gamma',
'HLT_[0-9]*g[0-9]+.*'),
49 (
'HLT_Muons',
'HLT_[0-9]*mu[0-9]+.*'),
50 (
'HLT_Taus',
'HLT_(tau[0-9]*|trk.*Tau).*'),
51 (
'HLT_MissingET',
'HLT_(t|x)e[0-9]+.*'),
52 (
'HLT_Jets',
'HLT_[0-9]*j[0-9]+.*'),
53 (
'HLT_MinBias',
'HLT_mb.*')]
57 hltGroup = helper.addGroup(
70 hltGroup.defineHistogram(
'HLTEvents', title=
'HLT events;HLT;Events',
71 path=
'',xbins=2,xmin=0,xmax=2)
73 consistency_names=[
'SMK DB NULL',
'SMK BS NULL',
'SMK Inconsistent',
'HLT Prescale DB NULL',
74 'HLT Prescale BS NULL',
'HLT Prescale Inconsistent',
75 'No onlineKeys',
'No eventKeys']
76 hltGroup.defineHistogram(
'ConfigConsistency_HLT', title=
'ConfigConsistency_HLT;;Events',
77 path=
'',xbins=8,xmin=1,xmax=9,xlabels=consistency_names,
88 HLT_names_signature = []
89 ListOf_signatures = []
92 for signame, m_this_regex
in signature_names_regexes:
93 log_trighlt.debug(
'Signature: %s', signame)
94 ListOf_signatures.append(signame)
95 this_regex = re.compile(m_this_regex)
96 HLT_names_signature.clear()
98 if this_regex.match(chain_name):
99 log_trighlt.debug(
'chain name %s matches regex %s',chain_name,m_this_regex)
100 HLT_names_signature.append(chain_name)
101 ListOf_HLT_names.append(
list(HLT_names_signature))
106 ListOf_HLT_names_sorted = []
107 HLT_names_signature_sorted = []
108 for i
in range(len(ListOf_HLT_names)):
109 HLT_names_signature.clear()
110 HLT_names_signature=ListOf_HLT_names[i]
112 HLT_names_signature_sorted.clear()
113 HLT_names_signature_sorted =
sorted(HLT_names_signature)
114 ListOf_HLT_names_sorted.append(
list(HLT_names_signature_sorted))
115 for chain
in HLT_names_signature_sorted:
117 log_trighlt.debug(
'sorted HLT chain: %s',chain)
122 log_trighlt.debug(
'L1 items: ')
124 L1_names.append(item_name)
125 max_L1_items = len(L1_names)
126 log_trighlt.debug(
'max_L1_items = %i', max_L1_items)
130 L1_names_sorted =
sorted(L1_names)
132 for item_name
in L1_names_sorted:
133 log_trighlt.debug(
'L1 item: = %s',item_name)
138 hltGroup.defineHistogram(
'L1Events',title=
'Events per Item at L1;;Events',
139 path=
'',xbins=len(L1_names_sorted), xmin=0,
140 xmax=len(L1_names_sorted), xlabels=L1_names_sorted)
144 triggerstatus = [
'RAW',
'PS']
146 for i, pair
in enumerate(signature_names_regexes):
148 m_this_regex = pair[1]
149 log_trighlt.debug(
"Signature %s, pattern %s:",sig, m_this_regex)
152 titlename = sig+
";;"+
"Events"
153 HLT_names_signature_sorted.clear()
154 HLT_names_signature_sorted = ListOf_HLT_names_sorted[i]
156 Xmax=len(HLT_names_signature_sorted)
159 log_trighlt.debug(
'Xmax= %i', Xmax)
161 for trigstatus
in triggerstatus:
162 histname = sig+trigstatus
163 titlename = sig+trigstatus+
";;"+
"Events"
164 hltGroup.defineHistogram(histname,title=titlename,
165 path=sig,xbins=len(HLT_names_signature_sorted),
167 xlabels=HLT_names_signature_sorted,opt=
'kAlwaysCreate')
170 histname = sig+
"_eta"
171 titlename = histname+
";#eta;"+
"Events"
172 hltGroup.defineHistogram(histname,title=titlename,
173 path=sig,xbins=64,xmin=-3.2,xmax=3.2)
175 histname = sig+
"_phi"
176 titlename = histname+
";#phi;"+
"Events"
177 hltGroup.defineHistogram(histname,title=titlename,
178 path=sig,xbins=64,xmin=-3.2,xmax=3.2)
181 histname = sig+
"RoI_N"
182 titlename = histname+
";Number of RoIs;"+
"Events"
183 hltGroup.defineHistogram(histname,title=titlename,
184 path=sig,xbins=100,xmin=0,xmax=500)
190 listOfSignatureGroups =[]
191 for signame
in ListOf_signatures:
192 thistoolname =
'Trig'+signame+
'Monitor'
193 thisGroup = helper.addGroup(
196 'HLT/ResultMon/'+signame
198 listOfSignatureGroups.append(thisGroup)
202 log_trighlt.debug(
'Creating RoI histograms...')
203 for i, thisGroup
in enumerate(listOfSignatureGroups):
204 thispair = signature_names_regexes[i]
205 thissigname = thispair[0]
206 histname =
"eta,phi;"+thissigname+
"RoIs"
208 titlename = thissigname+
"RoIs;#eta;#phi"
209 thisGroup.defineHistogram(histname,type=
'TH2F',title=titlename,
210 path=
'',xbins=64,xmin=-3.2,xmax=3.2,
211 ybins=64,ymin=-3.2,ymax=3.2)
217 return helper.result()
220 if __name__==
'__main__':
222 from AthenaCommon.Logging
import log
227 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
229 flags.Input.isMC =
False
230 flags.Output.HISTFileName =
'TrigHLTMonitorOutput.root'
235 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
236 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
241 cfg.merge(trigHLTMonitorAcc)
245 cfg.printConfig(withDetails=
True)