ATLAS Offline Software
Loading...
Searching...
No Matches
python.TrigMuonEfficiencyMonConfig Namespace Reference

Functions

 regex (pat)
 get_singlemu_chain_closest_to (chainList, ref_hlt_pt, ref_hlt_type, ref_l1_pt)
 TrigMuonEfficiencyMonTTbarConfig (helper, isPhaseII=False, **kwargs)
 A special configuration for ttbar samples, where the cut on m_mumu is loosened to improve the acceptance.
 TrigMuonEfficiencyMonZTPConfig (helper, isPhaseII=False, **kwargs)
 PlotConfig (monAlg, chain)
 defineEfficiencyHistograms (monAlg, histGroup, GroupName, chain, flags)

Variables

 log = logging.getLogger('TrigMuonEfficiencyMonConfig.py')

Function Documentation

◆ defineEfficiencyHistograms()

defineEfficiencyHistograms ( monAlg,
histGroup,
GroupName,
chain,
flags )

Definition at line 189 of file TrigMuonEfficiencyMonConfig.py.

189def defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, flags):
190
191 def defineEachStepHistograms(xvariable, xlabel, xbins, xmin, xmax):
192 histGroup.defineHistogram(GroupName+'_'+xvariable+';'+xvariable,
193 title='All offline combined muon '+chain+';'+xlabel+';Events',
194 type='TH1F',path='',xbins=xbins,xmin=xmin,xmax=xmax)
195
196 histGroup.defineHistogram(GroupName+'_L1pass,'+GroupName+'_'+xvariable+';EffL1MU_'+xvariable+'_wrt_Probe',
197 title='L1MU Efficiency '+chain+';'+xlabel+';Efficiency',
198 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
199
200 if monAlg.doL2SA:
201 histGroup.defineHistogram(GroupName+'_L2SApass,'+GroupName+'_'+xvariable+';EffL2SA_'+xvariable+'_wrt_Upstream',
202 title='L2MuonSA Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
203 cutmask=GroupName+'_L1pass',
204 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
205
206 histGroup.defineHistogram(GroupName+'_L2SApass,'+GroupName+'_'+xvariable+';EffL2SA_'+xvariable+'_wrt_offlineCB',
207 title='L2MuonSA Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
208 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
209
210 if monAlg.doL2CB:
211 histGroup.defineHistogram(GroupName+'_L2CBpass,'+GroupName+'_'+xvariable+';EffL2CB_'+xvariable+'_wrt_Upstream',
212 title='L2muComb Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
213 cutmask=GroupName+'_L2SApass',
214 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
215
216 histGroup.defineHistogram(GroupName+'_L2CBpass,'+GroupName+'_'+xvariable+';EffL2CB_'+xvariable+'_wrt_offlineCB',
217 title='L2muComb Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
218 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
219
220 if monAlg.doEFSA:
221 histGroup.defineHistogram(GroupName+'_EFSApass,'+GroupName+'_'+xvariable+';EffEFSA_'+xvariable+'_wrt_Upstream',
222 title='EFSA Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
223 cutmask=GroupName+'_L2CBpass',
224 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
225
226 histGroup.defineHistogram(GroupName+'_EFSApass,'+GroupName+'_'+xvariable+';EffEFSA_'+xvariable+'_wrt_offlineCB',
227 title='EFSA Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
228 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
229
230 histGroup.defineHistogram(GroupName+'_EFSApass,'+GroupName+'_'+xvariable+';EffEFSA_'+xvariable+'_wrt_offlineCB_passedL2SA',
231 title='EFSA Muon Efficiency passed L2SA '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
232 cutmask=GroupName+'_L2SApass',
233 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
234
235 if monAlg.doEFCB:
236 histGroup.defineHistogram(GroupName+'_EFCBpass,'+GroupName+'_'+xvariable+';EffEFCB_'+xvariable+'_wrt_Upstream',
237 title='EFCB Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
238 cutmask=GroupName+'_EFSApass',
239 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
240
241 histGroup.defineHistogram(GroupName+'_EFCBpass,'+GroupName+'_'+xvariable+';EffEFCB_'+xvariable+'_wrt_offlineCB',
242 title='EFCB Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
243 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
244
245 histGroup.defineHistogram(GroupName+'_EFCBpass,'+GroupName+'_'+xvariable+';EffEFCB_'+xvariable+'_wrt_offlineCB_passedL2CB',
246 title='EFCB Muon Efficiency passed L2CB '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
247 cutmask=GroupName+'_L2CBpass',
248 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
249
250 if monAlg.doEFSAFS:
251 histGroup.defineHistogram(GroupName+'_EFSAFSpass,'+GroupName+'_'+xvariable+';EffEFSAFS_'+xvariable+'_wrt_Upstream',
252 title='EFSAFS Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
253 cutmask=GroupName+'_EFCBpass',
254 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
255
256 histGroup.defineHistogram(GroupName+'_EFSAFSpass,'+GroupName+'_'+xvariable+';EffEFSAFS_'+xvariable+'_wrt_offlineCB',
257 title='EFSAFS Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
258 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
259
260 histGroup.defineHistogram(GroupName+'_EFSAFSpass,'+GroupName+'_'+xvariable+';EffEFSAFS_'+xvariable+'_wrt_offlineCB_passedL2SA',
261 title='EFSAFS Muon Efficiency passed L2SA '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
262 cutmask=GroupName+'_L2SApass',
263 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
264
265 if monAlg.doEFCBFS:
266 histGroup.defineHistogram(GroupName+'_EFCBFSpass,'+GroupName+'_'+xvariable+';EffEFCBFS_'+xvariable+'_wrt_Upstream',
267 title='EFCBFS Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
268 cutmask=GroupName+'_EFSAFSpass',
269 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
270
271 histGroup.defineHistogram(GroupName+'_EFCBFSpass,'+GroupName+'_'+xvariable+';EffEFCBFS_'+xvariable+'_wrt_offlineCB',
272 title='EFCBFS Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
273 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
274
275 histGroup.defineHistogram(GroupName+'_EFCBFSpass,'+GroupName+'_'+xvariable+';EffEFCBFS_'+xvariable+'_wrt_offlineCB_passedL2CB',
276 title='EFCBFS Muon Efficiency passed L2CB '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
277 cutmask=GroupName+'_L2CBpass',
278 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
279
280
281 if monAlg.doEFIso:
282 histGroup.defineHistogram(GroupName+'_EFIsopass,'+GroupName+'_'+xvariable+';EffEFIso_'+xvariable+'_wrt_Upstream',
283 title='EFIso Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
284 cutmask=GroupName+'_EFCBpass',
285 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
286
287 histGroup.defineHistogram(GroupName+'_EFIsopass,'+GroupName+'_'+xvariable+';EffEFIso_'+xvariable+'_wrt_offlineCB',
288 title='EFIso Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
289 type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
290
291
292 defineEachStepHistograms('muPt', 'p_{T} [GeV]', 50, 0.0, 100.)
293 defineEachStepHistograms('muEta', '#eta', 30, -3.0, 3.0)
294 defineEachStepHistograms('muPhi', '#phi', 30, -math.pi, math.pi)
295 if flags.GeoModel.Run >= LHCPeriod.Run4:
296 defineEachStepHistograms('averageMu', 'average pileup', 4, 100., 220.)
297 else:
298 defineEachStepHistograms('averageMu', 'average pileup', 4, 0., 80.)
299
300
301 histGroup.defineHistogram(GroupName+'_invmass;invmass',
302 title='invariant mass of tag & probe muon '+chain+';inv mass [GeV];Events',
303 type='TH1F',path='',xbins=40,xmin=0.,xmax=200.)
304

◆ get_singlemu_chain_closest_to()

get_singlemu_chain_closest_to ( chainList,
ref_hlt_pt,
ref_hlt_type,
ref_l1_pt )

Definition at line 18 of file TrigMuonEfficiencyMonConfig.py.

18def get_singlemu_chain_closest_to(chainList, ref_hlt_pt, ref_hlt_type, ref_l1_pt):
19 # find the "closest" HLT muon chain with respect to the chain you would use for the tag
20 # in tag&probe; "close" means "mostly as good as the given reference HLT/L1 chain",
21 # which implies pt thresholds should be similar and isolation, if pt thresholds are the
22 # same, should be required
23 chain_data = []
24 for chainName in chainList:
25 # regexp to match ordinary single-muon HLT chain names
26 match = regex('HLT_mu([0-9]+)(?:_([a-zA-Z_]+))?_(L1MU([0-9]+)[A-Z_]+)').match(chainName)
27 if match:
28 hlt_threshold = float(match.group(1))
29 hlt_type = match.group(2) # None, ivarmedium, barrel only...
30 #level1_item = match.group(3) # not used so not assigned
31 level1_threshold = float(match.group(4))
32 if hlt_type is None or hlt_type == 'ivarmedium': # we restrict ourselves to ordinary cases
33 chain_data.append((chainName, hlt_type, hlt_threshold, level1_threshold))
34
35 # we determine automatically the HLT chain to choose, based on these criteria (in order of priority):
36 # 1) how far the HLT pt cut is wrt the ideal chain we'd want (based on abs(pt-ptref) := delta_hlt)
37 # 2) we prefer the chain with the lowest pt cut, if two are available with the same delta_hlt (i.e. if we want 24, we'll take 23 instead of 26 GeV)
38 # 3) we prefer the isolated version of the trigger (higher tag purity)
39 # 4+5) we prefer the chain with the lowest L1 item (again as close as possible to the one we'd want)
40 # note that the check for 3) is performed in this way as "sorted" uses ascending order (so 0 comes before 1)
41 chain_data_sorted = sorted(chain_data, key=lambda tup: (abs(tup[2]-ref_hlt_pt), tup[2]-ref_hlt_pt, tup[1]!=ref_hlt_type, abs(tup[3]-ref_l1_pt), tup[3]-ref_l1_pt))
42 chainList_sorted = [x[0] for x in chain_data_sorted]
43 return chainList_sorted
44
45
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359

◆ PlotConfig()

PlotConfig ( monAlg,
chain )

Definition at line 165 of file TrigMuonEfficiencyMonConfig.py.

165def PlotConfig(monAlg, chain):
166 from xAODMuon.xAODMuonEnums import xAODMuonEnums
167 if "msonly" in chain:
168 monAlg.MuonType = xAODMuonEnums.MuonStandAlone
169 else:
170 monAlg.MuonType = xAODMuonEnums.Combined
171
172 if "msonly" in chain:
173 monAlg.doL2CB = False
174 monAlg.doEFCB = False
175 if "ivar" not in chain:
176 monAlg.doEFIso = False
177
178 if "0eta105" in chain:
179 monAlg.BarrelOnly = True
180
181 if "noL1" in chain:
182 monAlg.doEFSAFS = True
183 monAlg.doEFCBFS = True
184 else:
185 monAlg.doEFSAFS = False
186 monAlg.doEFCBFS = False
187
188

◆ regex()

regex ( pat)

Definition at line 10 of file TrigMuonEfficiencyMonConfig.py.

10def regex(pat):
11 if 'cached_regex' not in globals():
12 global cached_regex
13 cached_regex = {}
14 if pat not in cached_regex:
15 cached_regex.update({pat:re.compile(pat)})
16 return cached_regex[pat]
17

◆ TrigMuonEfficiencyMonTTbarConfig()

TrigMuonEfficiencyMonTTbarConfig ( helper,
isPhaseII = False,
** kwargs )

A special configuration for ttbar samples, where the cut on m_mumu is loosened to improve the acceptance.

This is useless for data samples because the ttbar process has very small contribution.

Definition at line 49 of file TrigMuonEfficiencyMonConfig.py.

49def TrigMuonEfficiencyMonTTbarConfig(helper, isPhaseII=False, **kwargs):
50
51 from AthenaConfiguration.ComponentFactory import CompFactory
52
53
54 from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
55 moniAccess = getHLTMonitoringAccess(helper.flags)
56 Chains = moniAccess.monitoredChains(signatures="muonMon",monLevels=["shifter","t0","val"])
57 MonitoredChains = [c for c in Chains if 'HLT_mu' in c] # this makes sure we don't consider 2mu, 3mu, 4mu chains
58
59 # if mon groups not found fall back to hard-coded trigger monitoring list
60 if len(MonitoredChains) == 0:
61 # HLT_mu6_L1MU6 is test chain for small statistics, so it will be removed.
62 MonitoredChains = ['HLT_mu6_L1MU5VF', 'HLT_mu24_ivarmedium_L1MU14FCH', 'HLT_mu50_L1MU14FCH', 'HLT_mu60_0eta105_msonly_L1MU14FCH', 'HLT_mu14_L1MU8F', 'HLT_mu22_mu8noL1_L1MU14FCH', 'HLT_mu6_mu6noL1_L1MU5VF']
63
64
65 singlemu_chains_sorted = get_singlemu_chain_closest_to(MonitoredChains, 24, 'ivarmedium', 14)
66 if not singlemu_chains_sorted:
67 log.warning('No suitable single-muon trigger chain found as tag for ttbar tag&probe')
68 return
69 else:
70 tagandprobe_chain = singlemu_chains_sorted[0]
71 log.info(f'Using {tagandprobe_chain} as tag and event trigger in ttbar tag&probe')
72
73 from MuonSelectorTools.MuonSelectorToolsConfig import MuonLoosenedNonCalibratedSelectionToolCfg
74 from .MuonMatchingToolConfig import MuonMatchingToolConfig
75
76 # Set the offline muon container
77 kwargs.setdefault("MuonContainerName", "Muons")
78
79 for chain in MonitoredChains:
80 monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,'TrigMuEff_ttbar_'+chain,
81 MuonSelectionTool = helper.result().popToolsAndMerge(MuonLoosenedNonCalibratedSelectionToolCfg(helper.flags,
82 MuQuality=1)),
83 MuonMatchingTool = helper.result().popToolsAndMerge(MuonMatchingToolConfig(helper.flags,
84 isPhaseII=isPhaseII,
85 MuonContainerName=kwargs["MuonContainerName"])),
86 **kwargs)
87
88 monAlg.EventTrigger = tagandprobe_chain
89 monAlg.TagTrigger = tagandprobe_chain
90 monAlg.Method = 'TTbarTagAndProbe'
91 monAlg.MonitoredChains = [chain]
92 threshold, level1 = regex('HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').match(chain).groups()
93 monAlg.L1Seeds = [regex('L1MU').sub('L1_MU', level1)]
94 monAlg.Thresholds = [float(threshold)]
95 monAlg.Group = 'Eff_ttbar_'+chain
96
97 GroupName = 'Eff_ttbar_'+chain
98 histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ttbar/'+chain)
99
100 PlotConfig(monAlg, chain)
101 defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, helper.flags)
102
103 return
104
105

◆ TrigMuonEfficiencyMonZTPConfig()

TrigMuonEfficiencyMonZTPConfig ( helper,
isPhaseII = False,
** kwargs )

Definition at line 106 of file TrigMuonEfficiencyMonConfig.py.

106def TrigMuonEfficiencyMonZTPConfig(helper, isPhaseII=False, **kwargs):
107
108 from AthenaConfiguration.ComponentFactory import CompFactory
109
110
111 from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
112 moniAccess = getHLTMonitoringAccess(helper.flags)
113 Chains = moniAccess.monitoredChains(signatures="muonMon",monLevels=["shifter","t0","val"])
114 MonitoredChains = [c for c in Chains if 'HLT_mu' in c] # this makes sure we don't consider 2mu, 3mu, 4mu chains
115
116 # if mon groups not found fall back to hard-coded trigger monitoring list
117 if len(MonitoredChains) == 0:
118 # HLT_mu6_L1MU6 is test chain for small statistics, so it will be removed.
119 MonitoredChains = ['HLT_mu6_L1MU5VF', 'HLT_mu24_ivarmedium_L1MU14FCH', 'HLT_mu50_L1MU14FCH', 'HLT_mu60_0eta105_msonly_L1MU14FCH', 'HLT_mu14_L1MU8F', 'HLT_mu22_mu8noL1_L1MU14FCH', 'HLT_mu6_mu6noL1_L1MU5VF']
120
121
122 singlemu_chains_sorted = get_singlemu_chain_closest_to(MonitoredChains, 24, 'ivarmedium', 14)
123 if not singlemu_chains_sorted:
124 log.warning('No suitable single-muon trigger chain found as tag for Z tag&probe.')
125 return
126 else:
127 tagandprobe_chain = singlemu_chains_sorted[0]
128 log.info(f'Using {tagandprobe_chain} as tag and event trigger in Z tag&probe')
129
130
131 from MuonSelectorTools.MuonSelectorToolsConfig import MuonLoosenedNonCalibratedSelectionToolCfg
132 from .MuonMatchingToolConfig import MuonMatchingToolConfig
133
134 # Set the offline muon container
135 kwargs.setdefault("MuonContainerName", "Muons")
136
137 for chain in MonitoredChains:
138 monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,'TrigMuEff_ZTP_'+chain,
139 MuonSelectionTool = helper.result().popToolsAndMerge(MuonLoosenedNonCalibratedSelectionToolCfg(helper.flags,
140 MuQuality=1)),
141 MuonMatchingTool = helper.result().popToolsAndMerge(MuonMatchingToolConfig(helper.flags,
142 isPhaseII=isPhaseII,
143 MuonContainerName=kwargs["MuonContainerName"])),
144 **kwargs)
145
146 monAlg.EventTrigger = tagandprobe_chain
147 monAlg.TagTrigger = tagandprobe_chain
148 monAlg.Method = 'ZTagAndProbe'
149 monAlg.MonitoredChains = [chain]
150 threshold, level1 = regex('HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').match(chain).groups()
151 monAlg.L1Seeds = [regex('L1MU').sub('L1_MU', level1)]
152 monAlg.Thresholds = [float(threshold)]
153 monAlg.Group = 'Eff_ZTP_'+chain
154
155 GroupName = 'Eff_ZTP_'+chain
156 histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ZTP/'+chain)
157
158 PlotConfig(monAlg, chain)
159 defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, helper.flags)
160
161 return
162
163
164

Variable Documentation

◆ log

python.TrigMuonEfficiencyMonConfig.log = logging.getLogger('TrigMuonEfficiencyMonConfig.py')

Definition at line 8 of file TrigMuonEfficiencyMonConfig.py.