ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMinBiasEffMonitoring Namespace Reference

Functions

 _TrigEff (flags, triggerAndRef, algname='HLTMinBiasEffMonitoringAlg')
 TrigMinBiasEff (flags)

Variables

 log = logging.getLogger('TrigMinBiasEffMonitoring')
 flags = initConfigFlags()
 HISTFileName
 cfg = MainServicesCfg(flags)
 withDetails

Detailed Description

@brief configuration for the trigger efficiency monitoring

Function Documentation

◆ _TrigEff()

TrigMinBiasEffMonitoring._TrigEff ( flags,
triggerAndRef,
algname = 'HLTMinBiasEffMonitoringAlg' )
protected

Definition at line 16 of file TrigMinBiasEffMonitoring.py.

16def _TrigEff(flags, triggerAndRef, algname='HLTMinBiasEffMonitoringAlg'):
17 from AthenaMonitoring import AthMonitorCfgHelper
18 monConfig = AthMonitorCfgHelper(flags, algname)
19
20 alg = monConfig.addAlgorithm(
21 CompFactory.HLTMinBiasEffMonitoringAlg, algname)
22
23 from InDetTrackSelectionTool.InDetTrackSelectionToolConfig import (
24 InDetTrackSelectionTool_LoosePrimary_Cfg)
25 trkSel = monConfig.resobj.popToolsAndMerge(InDetTrackSelectionTool_LoosePrimary_Cfg(flags))
26 alg.TrackSelectionTool = trkSel
27
28 alg.triggerList = [ el["chain"] for el in triggerAndRef ]
29 alg.refTriggerList = [ el["refchain"] for el in triggerAndRef ]
30
31 length = len(alg.triggerList)
32
33 mainGroup = monConfig.addGroup(alg, 'TrigAll', topPath='HLT/MinBiasMon/Counts/')
34
35 alreadyConfigured = set()
36 for cdef in triggerAndRef:
37 chain = cdef['chain']
38 refchain = cdef['refchain']
39 level = cdef['level']
40 xmin = cdef['xmin']
41 xmax = cdef['xmax']
42 xbins = xmax-xmin
43 effGroup = monConfig.addGroup(alg, chain+refchain, topPath=f'HLT/MinBiasMon/{level}/EffAll/')
44
45 whichcounter='nTrkOffline'
46 # if the chain cuts on higher pt (there is a few predefined chains) use different counter
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)
50
51 # these chains have such name pattern: HLT_mb_sptrk_pt2_L1MBTS_2
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)
58 # these chains have such form: HLT_mb_excl_1trk5_pt4_L1RD0_FILLED
59 whichcounter += '_'+chain.split('_')[4]
60
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)
65
66
67
68 if chain not in alreadyConfigured:
69 alreadyConfigured.add(chain)
70 # need this protection because we can measure efficiency with several reference trigger, but want counts irrespective of ref. triggers
71 mainGroup.defineHistogram('nTrkOffline_counts_' + chain, type='TH1F',
72 title=chain+';Offline Good nTrk;Events', xbins=xmax-xmin, xmin=xmin, xmax=xmax)
73
74 mainGroup.defineHistogram('TrigCounts', title='Trigger counts;;Event rate',
75 xbins=length, xmin=0, xmax=len(alreadyConfigured), xlabels=list(alreadyConfigured))
76
77 return monConfig.result()
78
79
STL class.

◆ TrigMinBiasEff()

TrigMinBiasEffMonitoring.TrigMinBiasEff ( flags)

Definition at line 80 of file TrigMinBiasEffMonitoring.py.

80def TrigMinBiasEff(flags):
81 from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
82 monAccess = getHLTMonitoringAccess(flags)
83
84 mbNames = [name for name, _ in getMinBiasChains(monAccess)]
85 if len(mbNames) == 0:
86 return _TrigEff(flags, [])
87
88 log.info(f'Monitoring {len(mbNames)} MinBias chains')
89 log.debug(mbNames)
90
91 # here we generate config with detailed settings
92 def _c(chain, refchain, level, **kwargs):
93 conf = {"chain": chain, "refchain": refchain, "level": level, "xmin": 0, "xmax": 20}
94 conf.update(kwargs)
95 return conf
96
97 def _isFilled(chain):
98 name, _ = chain
99 return "_EMPTY" not in name and "_UNPAIRED_ISO" not in name
100
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]]
105
106 triggerAndRef = []
107
108 # check all mb_sptrk chains w.r.t. random noalg
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]
112
113 # for monitoring in MB stream
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]
117
118 # sptrk vs sp
119 triggerAndRef += [_c("HLT_mb_sptrk_L1RD0_FILLED", "HLT_mb_sp_L1RD0_FILLED", 'Shifter')]
120
121 # HMT chains
122 hmtChains = getMinBiasChains(monAccess, '(hmt)')
123 nonPusupChains = [chain for chain in hmtChains if '_pusup' not in chain[0]]
124 if len(nonPusupChains) != 0:
125 # sort by trk threshold
126 def _trk(chain):
127 name, _ = chain
128 part = name.split("_")
129 for el in part:
130 if el.startswith("trk"):
131 return int(el.strip("trk"))
132 raise RuntimeError(f"Chain {name} is not the hmt chain")
133
134 nonPusupChains.sort(key=lambda chain: int(_trk(chain)))
135
136 # monitor first hmt w.r.t sptrk
137 first = nonPusupChains[0]
138 triggerAndRef += [_c(first[0], "HLT_mb_sptrk_L1RD0_FILLED", first[1], xmax=_trk(first) + 30)]
139
140 # group set the ref for each trigger to be one of lower threshold : ordering of chains needs to be reviewed
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:]]
142
143 # pu suppressing trigger should be monitored using trigger of the same threshold w/o pu suppression
144 pusupChains = [chain for chain in hmtChains if '_pusup' in chain[0]]
145
146 def _dropsup(name):
147 s = name.split("_")
148 return "_".join(s[:3] + s[4:])
149
150 triggerAndRef += [_c(chain[0], _dropsup(chain[0]), chain[1], xmin=_trk(chain) - 20, xmax=_trk(chain) + 50) for chain in pusupChains]
151
152 # monitor exclusivity cut
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))
157
158 # monitor noalg MBTS chains
159 noalgMbtsChains = getMinBiasChains(monAccess, '^HLT_noalg_.*(L1MBTS)')
160 triggerAndRef += [_c(name, 'HLT_mb_sptrk_L1RD0_FILLED', level) for name, level in noalgMbtsChains]
161
162 # L1 MBTS
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]
165
166 # L1 transverse energy
167 triggerAndRef += [_c("L1_TE{}".format(i), 'HLT_mb_sptrk_L1RD0_FILLED', 'Expert', xmin=0, xmax=100) for i in [3, 5, 10, 40]]
168
169 # Pair HLT chain with its noalg version
170 def _find_noalg(chain):
171 pos = chain.find('L1')
172 return 'HLT_noalg_' + chain[pos:]
173
174 def _chains_with_noalg_ref():
175 chains = []
176
177 for name, level in filledChains:
178 # Already added
179 if 'L1RD0_FILLED' in name:
180 continue
181
182 noalg = _find_noalg(name)
183 if noalg not in mbNames:
184 continue
185
186 chains.append(_c(name, noalg, level))
187
188 return chains
189
190 triggerAndRef += _chains_with_noalg_ref()
191
192 # HI chains
193 hiChains = getMinBiasChains(monAccess, '(_hi_)')
194
195 # Pair MB+HI chains with MB only reference if it exists
196 def _hi_chain_with_mb_ref():
197 chains = []
198
199 for name, level in hiChains:
200 split = name.split('_hi_')
201 if len(split) != 2:
202 continue
203 mb, hi_l1 = split
204
205 split = hi_l1.split('L1')
206 if len(split) != 2:
207 continue
208 hi, l1 = split
209
210 ref = f'{mb}_L1{l1}'
211 if ref not in mbNames:
212 continue
213
214 chains.append(_c(name, ref, level))
215
216 return chains
217
218 triggerAndRef += _hi_chain_with_mb_ref()
219
220 # Add here all the special cases:
221 # HI Fgap chains
222 triggerAndRef.append(_c('HLT_mb_excl_1trk4_pt1_hi_FgapAC5_L12eEM1_VjTE200', 'HLT_mb_excl_1trk4_pt1_L12eEM1_VjTE200_GAP_AANDC', 'Expert'))
223
224 return _TrigEff(flags, triggerAndRef)
225
226

Variable Documentation

◆ cfg

TrigMinBiasEffMonitoring.cfg = MainServicesCfg(flags)

Definition at line 238 of file TrigMinBiasEffMonitoring.py.

◆ flags

TrigMinBiasEffMonitoring.flags = initConfigFlags()

Definition at line 230 of file TrigMinBiasEffMonitoring.py.

◆ HISTFileName

TrigMinBiasEffMonitoring.HISTFileName

Definition at line 231 of file TrigMinBiasEffMonitoring.py.

◆ log

TrigMinBiasEffMonitoring.log = logging.getLogger('TrigMinBiasEffMonitoring')

Definition at line 13 of file TrigMinBiasEffMonitoring.py.

◆ withDetails

TrigMinBiasEffMonitoring.withDetails

Definition at line 244 of file TrigMinBiasEffMonitoring.py.