16def _TrigEff(flags, triggerAndRef, algname='HLTMinBiasEffMonitoringAlg'):
17 from AthenaMonitoring
import AthMonitorCfgHelper
18 monConfig = AthMonitorCfgHelper(flags, algname)
20 alg = monConfig.addAlgorithm(
21 CompFactory.HLTMinBiasEffMonitoringAlg, algname)
23 from InDetTrackSelectionTool.InDetTrackSelectionToolConfig
import (
24 InDetTrackSelectionTool_LoosePrimary_Cfg)
25 trkSel = monConfig.resobj.popToolsAndMerge(InDetTrackSelectionTool_LoosePrimary_Cfg(flags))
26 alg.TrackSelectionTool = trkSel
28 alg.triggerList = [ el[
"chain"]
for el
in triggerAndRef ]
29 alg.refTriggerList = [ el[
"refchain"]
for el
in triggerAndRef ]
31 length = len(alg.triggerList)
33 mainGroup = monConfig.addGroup(alg,
'TrigAll', topPath=
'HLT/MinBiasMon/Counts/')
35 alreadyConfigured =
set()
36 for cdef
in triggerAndRef:
38 refchain = cdef[
'refchain']
43 effGroup = monConfig.addGroup(alg, chain+refchain, topPath=f
'HLT/MinBiasMon/{level}/EffAll/')
45 whichcounter=
'nTrkOffline'
47 if '_sptrk_pt' in chain:
48 effGroup.defineHistogram(f
'EffPassed,leadingTrackPt;{chain}_ref_{refchain}_pt', type=
'TEfficiency',
49 title=chain+
';Leading track pt;Efficiency', xbins=50, xmin=0.0, xmax=10)
52 whichcounter +=
'_'+chain.split(
'_')[3]
53 elif '_excl_' in chain:
54 effGroup.defineHistogram(f
'EffPassed,nTrkOffline;{chain}_ref_{refchain}_exclusivity', type=
'TEfficiency',
55 title=chain+
';Offline Good nTrk (low pt);Efficiency', xbins=30, xmin=-0.5, xmax=30-0.5)
56 effGroup.defineHistogram(f
'EffPassed,leadingTrackPt;{chain}_ref_{refchain}_pt', type=
'TEfficiency',
57 title=chain+
';Leading track pt;Efficiency', xbins=50, xmin=0.0, xmax=10)
59 whichcounter +=
'_'+chain.split(
'_')[4]
61 if '_pusup' in chain
or '_hmt_' in chain:
62 whichcounter =
'nTrkOfflineVtx'
63 effGroup.defineHistogram(f
'EffPassed,{whichcounter};{chain}_ref_{refchain}', type=
'TEfficiency',
64 title=f
'{chain} ref: {refchain} ;Offline Good nTrk {whichcounter};Efficiency', xbins=xbins, xmin=xmin, xmax=xmax)
68 if chain
not in alreadyConfigured:
69 alreadyConfigured.add(chain)
71 mainGroup.defineHistogram(
'nTrkOffline_counts_' + chain, type=
'TH1F',
72 title=chain+
';Offline Good nTrk;Events', xbins=xmax-xmin, xmin=xmin, xmax=xmax)
74 mainGroup.defineHistogram(
'TrigCounts', title=
'Trigger counts;;Event rate',
75 xbins=length, xmin=0, xmax=len(alreadyConfigured), xlabels=list(alreadyConfigured))
77 return monConfig.result()
81 from TrigConfigSvc.TriggerConfigAccess
import getHLTMonitoringAccess
82 monAccess = getHLTMonitoringAccess(flags)
84 mbNames = [name
for name, _
in getMinBiasChains(monAccess)]
88 log.info(f
'Monitoring {len(mbNames)} MinBias chains')
92 def _c(chain, refchain, level, **kwargs):
93 conf = {
"chain": chain,
"refchain": refchain,
"level": level,
"xmin": 0,
"xmax": 20}
99 return "_EMPTY" not in name
and "_UNPAIRED_ISO" not in name
101 spTrkChains = getMinBiasChains(monAccess,
'(_sptrk_|_sp_|_mbts_)')
102 filledChains = list(filter(_isFilled, spTrkChains))
103 emptyChains = [chain
for chain
in spTrkChains
if "_EMPTY" in chain[0]]
104 unpairedChains = [chain
for chain
in spTrkChains
if "_UNPAIRED_ISO" in chain[0]]
109 triggerAndRef += [_c(name,
"HLT_noalg_L1RD0_FILLED", level)
for name, level
in filledChains]
110 triggerAndRef += [_c(name,
"HLT_noalg_L1RD0_EMPTY", level)
for name, level
in emptyChains]
111 triggerAndRef += [_c(name,
"HLT_noalg_L1RD0_UNPAIRED_ISO", level)
for name, level
in unpairedChains]
114 triggerAndRef += [_c(name,
"HLT_noalg_mb_L1RD0_FILLED", level)
for name, level
in filledChains]
115 triggerAndRef += [_c(name,
"HLT_noalg_mb_L1RD0_EMPTY", level)
for name, level
in emptyChains]
116 triggerAndRef += [_c(name,
"HLT_noalg_mb_L1RD0_UNPAIRED_ISO", level)
for name, level
in unpairedChains]
119 triggerAndRef += [_c(
"HLT_mb_sptrk_L1RD0_FILLED",
"HLT_mb_sp_L1RD0_FILLED",
'Shifter')]
122 hmtChains = getMinBiasChains(monAccess,
'(hmt)')
123 nonPusupChains = [chain
for chain
in hmtChains
if '_pusup' not in chain[0]]
124 if len(nonPusupChains) != 0:
128 part = name.split(
"_")
130 if el.startswith(
"trk"):
131 return int(el.strip(
"trk"))
132 raise RuntimeError(f
"Chain {name} is not the hmt chain")
134 nonPusupChains.sort(key=
lambda chain: int(_trk(chain)))
137 first = nonPusupChains[0]
138 triggerAndRef += [_c(first[0],
"HLT_mb_sptrk_L1RD0_FILLED", first[1], xmax=_trk(first) + 30)]
141 triggerAndRef += [_c(chain[0],
"HLT_mb_sptrk_L1RD0_FILLED", chain[1], xmin=_trk(chain) - 20, xmax=_trk(chain) + 50)
for chain
in nonPusupChains[1:]]
144 pusupChains = [chain
for chain
in hmtChains
if '_pusup' in chain[0]]
148 return "_".join(s[:3] + s[4:])
150 triggerAndRef += [_c(chain[0], _dropsup(chain[0]), chain[1], xmin=_trk(chain) - 20, xmax=_trk(chain) + 50)
for chain
in pusupChains]
153 exclChains = getMinBiasChains(monAccess,
'(excl)')
154 for name, level
in exclChains:
155 triggerAndRef.append(_c(name,
'HLT_mb_sptrk_L1RD0_FILLED', level))
156 triggerAndRef.append(_c(name,
'HLT_mb_sp_L1RD0_FILLED', level))
159 noalgMbtsChains = getMinBiasChains(monAccess,
'^HLT_noalg_.*(L1MBTS)')
160 triggerAndRef += [_c(name,
'HLT_mb_sptrk_L1RD0_FILLED', level)
for name, level
in noalgMbtsChains]
163 mbtsL1Chains = [
"L1_MBTS_A",
"L1_MBTS_C",
"L1_MBTS_1",
"L1_MBTS_2",
"L1_MBTS_1_1"]
164 triggerAndRef += [_c(chain,
'HLT_mb_sptrk_L1RD0_FILLED',
'Expert')
for chain
in mbtsL1Chains]
167 triggerAndRef += [_c(
"L1_TE{}".format(i),
'HLT_mb_sptrk_L1RD0_FILLED',
'Expert', xmin=0, xmax=100)
for i
in [3, 5, 10, 40]]
170 def _find_noalg(chain):
171 pos = chain.find(
'L1')
172 return 'HLT_noalg_' + chain[pos:]
174 def _chains_with_noalg_ref():
177 for name, level
in filledChains:
179 if 'L1RD0_FILLED' in name:
182 noalg = _find_noalg(name)
183 if noalg
not in mbNames:
186 chains.append(_c(name, noalg, level))
190 triggerAndRef += _chains_with_noalg_ref()
193 hiChains = getMinBiasChains(monAccess,
'(_hi_)')
196 def _hi_chain_with_mb_ref():
199 for name, level
in hiChains:
200 split = name.split(
'_hi_')
205 split = hi_l1.split(
'L1')
211 if ref
not in mbNames:
214 chains.append(_c(name, ref, level))
218 triggerAndRef += _hi_chain_with_mb_ref()
222 triggerAndRef.append(_c(
'HLT_mb_excl_1trk4_pt1_hi_FgapAC5_L12eEM1_VjTE200',
'HLT_mb_excl_1trk4_pt1_L12eEM1_VjTE200_GAP_AANDC',
'Expert'))
224 return _TrigEff(flags, triggerAndRef)