6 from AthenaCommon.Logging
import logging
7 from AthenaConfiguration.Enums
import LHCPeriod
8 log = logging.getLogger(
'TrigMuonEfficiencyMonConfig.py')
11 if 'cached_regex' not in globals():
14 if pat
not in cached_regex:
15 cached_regex.update({pat:re.compile(pat)})
16 return cached_regex[pat]
24 for chainName
in chainList:
26 match =
regex(
'HLT_mu([0-9]+)(?:_([a-zA-Z_]+))?_(L1MU([0-9]+)[A-Z_]+)').
match(chainName)
28 hlt_threshold =
float(match.group(1))
29 hlt_type = match.group(2)
31 level1_threshold =
float(match.group(4))
32 if hlt_type
is None or hlt_type ==
'ivarmedium':
33 chain_data.append((chainName, hlt_type, hlt_threshold, level1_threshold))
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
51 from AthenaConfiguration.ComponentFactory
import CompFactory
54 from TrigConfigSvc.TriggerConfigAccess
import getHLTMonitoringAccess
56 Chains = moniAccess.monitoredChains(signatures=
"muonMon",monLevels=[
"shifter",
"t0",
"val"])
57 MonitoredChains = [c
for c
in Chains
if 'HLT_mu' in c]
60 if len(MonitoredChains) == 0:
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']
66 if not singlemu_chains_sorted:
67 log.warning(
'No suitable single-muon trigger chain found as tag for ttbar tag&probe')
70 tagandprobe_chain = singlemu_chains_sorted[0]
71 log.info(f
'Using {tagandprobe_chain} as tag and event trigger in ttbar tag&probe')
73 from MuonSelectorTools.MuonSelectorToolsConfig
import MuonSelectionToolCfg
74 from .MuonMatchingToolConfig
import MuonMatchingToolConfig
75 for chain
in MonitoredChains:
76 monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,
'TrigMuEff_ttbar_'+chain,
77 MuonSelectionTool = helper.result().popToolsAndMerge(
MuonSelectionToolCfg(helper.flags, MuQuality=1)),
80 monAlg.EventTrigger = tagandprobe_chain
81 monAlg.TagTrigger = tagandprobe_chain
82 monAlg.Method =
'TTbarTagAndProbe'
83 monAlg.MonitoredChains = [chain]
84 threshold, level1 =
regex(
'HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').
match(chain).
groups()
85 monAlg.L1Seeds = [
regex(
'L1MU').sub(
'L1_MU', level1)]
86 monAlg.Thresholds = [
float(threshold)]
87 monAlg.Group =
'Eff_ttbar_'+chain
89 GroupName =
'Eff_ttbar_'+chain
90 histGroup = helper.addGroup(monAlg, GroupName,
'HLT/MuonMon/Efficiency/ttbar/'+chain)
100 from AthenaConfiguration.ComponentFactory
import CompFactory
103 from TrigConfigSvc.TriggerConfigAccess
import getHLTMonitoringAccess
105 Chains = moniAccess.monitoredChains(signatures=
"muonMon",monLevels=[
"shifter",
"t0",
"val"])
106 MonitoredChains = [c
for c
in Chains
if 'HLT_mu' in c]
109 if len(MonitoredChains) == 0:
111 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']
115 if not singlemu_chains_sorted:
116 log.warning(
'No suitable single-muon trigger chain found as tag for Z tag&probe.')
119 tagandprobe_chain = singlemu_chains_sorted[0]
120 log.info(f
'Using {tagandprobe_chain} as tag and event trigger in Z tag&probe')
123 from MuonSelectorTools.MuonSelectorToolsConfig
import MuonSelectionToolCfg
124 from .MuonMatchingToolConfig
import MuonMatchingToolConfig
125 for chain
in MonitoredChains:
126 monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,
'TrigMuEff_ZTP_'+chain,
127 MuonSelectionTool = helper.result().popToolsAndMerge(
MuonSelectionToolCfg(helper.flags, MuQuality=1)),
130 monAlg.EventTrigger = tagandprobe_chain
131 monAlg.TagTrigger = tagandprobe_chain
132 monAlg.Method =
'ZTagAndProbe'
133 monAlg.MonitoredChains = [chain]
134 threshold, level1 =
regex(
'HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').
match(chain).
groups()
135 monAlg.L1Seeds = [
regex(
'L1MU').sub(
'L1_MU', level1)]
136 monAlg.Thresholds = [
float(threshold)]
137 monAlg.Group =
'Eff_ZTP_'+chain
139 GroupName =
'Eff_ZTP_'+chain
140 histGroup = helper.addGroup(monAlg, GroupName,
'HLT/MuonMon/Efficiency/ZTP/'+chain)
150 from xAODMuon.xAODMuonEnums
import xAODMuonEnums
151 if "msonly" in chain:
152 monAlg.MuonType = xAODMuonEnums.MuonStandAlone
154 monAlg.MuonType = xAODMuonEnums.Combined
156 if "msonly" in chain:
157 monAlg.doL2CB =
False
158 monAlg.doEFCB =
False
159 if "ivar" not in chain:
160 monAlg.doEFIso =
False
162 if "0eta105" in chain:
163 monAlg.BarrelOnly =
True
166 monAlg.doEFSAFS =
True
167 monAlg.doEFCBFS =
True
169 monAlg.doEFSAFS =
False
170 monAlg.doEFCBFS =
False
175 def defineEachStepHistograms(xvariable, xlabel, xbins, xmin, xmax):
176 histGroup.defineHistogram(GroupName+
'_'+xvariable+
';'+xvariable,
177 title=
'All offline combined muon '+chain+
';'+xlabel+
';Events',
178 type=
'TH1F',path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
180 histGroup.defineHistogram(GroupName+
'_L1pass,'+GroupName+
'_'+xvariable+
';EffL1MU_'+xvariable+
'_wrt_Probe',
181 title=
'L1MU Efficiency '+chain+
';'+xlabel+
';Efficiency',
182 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
185 histGroup.defineHistogram(GroupName+
'_L2SApass,'+GroupName+
'_'+xvariable+
';EffL2SA_'+xvariable+
'_wrt_Upstream',
186 title=
'L2MuonSA Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
187 cutmask=GroupName+
'_L1pass',
188 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
190 histGroup.defineHistogram(GroupName+
'_L2SApass,'+GroupName+
'_'+xvariable+
';EffL2SA_'+xvariable+
'_wrt_offlineCB',
191 title=
'L2MuonSA Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
192 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
195 histGroup.defineHistogram(GroupName+
'_L2CBpass,'+GroupName+
'_'+xvariable+
';EffL2CB_'+xvariable+
'_wrt_Upstream',
196 title=
'L2muComb Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
197 cutmask=GroupName+
'_L2SApass',
198 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
200 histGroup.defineHistogram(GroupName+
'_L2CBpass,'+GroupName+
'_'+xvariable+
';EffL2CB_'+xvariable+
'_wrt_offlineCB',
201 title=
'L2muComb Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
202 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
205 histGroup.defineHistogram(GroupName+
'_EFSApass,'+GroupName+
'_'+xvariable+
';EffEFSA_'+xvariable+
'_wrt_Upstream',
206 title=
'EFSA Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
207 cutmask=GroupName+
'_L2CBpass',
208 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
210 histGroup.defineHistogram(GroupName+
'_EFSApass,'+GroupName+
'_'+xvariable+
';EffEFSA_'+xvariable+
'_wrt_offlineCB',
211 title=
'EFSA Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
212 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
214 histGroup.defineHistogram(GroupName+
'_EFSApass,'+GroupName+
'_'+xvariable+
';EffEFSA_'+xvariable+
'_wrt_offlineCB_passedL2SA',
215 title=
'EFSA Muon Efficiency passed L2SA '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
216 cutmask=GroupName+
'_L2SApass',
217 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
220 histGroup.defineHistogram(GroupName+
'_EFCBpass,'+GroupName+
'_'+xvariable+
';EffEFCB_'+xvariable+
'_wrt_Upstream',
221 title=
'EFCB Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
222 cutmask=GroupName+
'_EFSApass',
223 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
225 histGroup.defineHistogram(GroupName+
'_EFCBpass,'+GroupName+
'_'+xvariable+
';EffEFCB_'+xvariable+
'_wrt_offlineCB',
226 title=
'EFCB Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
227 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
229 histGroup.defineHistogram(GroupName+
'_EFCBpass,'+GroupName+
'_'+xvariable+
';EffEFCB_'+xvariable+
'_wrt_offlineCB_passedL2CB',
230 title=
'EFCB Muon Efficiency passed L2CB '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
231 cutmask=GroupName+
'_L2CBpass',
232 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
235 histGroup.defineHistogram(GroupName+
'_EFSAFSpass,'+GroupName+
'_'+xvariable+
';EffEFSAFS_'+xvariable+
'_wrt_Upstream',
236 title=
'EFSAFS Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
237 cutmask=GroupName+
'_EFCBpass',
238 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
240 histGroup.defineHistogram(GroupName+
'_EFSAFSpass,'+GroupName+
'_'+xvariable+
';EffEFSAFS_'+xvariable+
'_wrt_offlineCB',
241 title=
'EFSAFS Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
242 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
244 histGroup.defineHistogram(GroupName+
'_EFSAFSpass,'+GroupName+
'_'+xvariable+
';EffEFSAFS_'+xvariable+
'_wrt_offlineCB_passedL2SA',
245 title=
'EFSAFS Muon Efficiency passed L2SA '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
246 cutmask=GroupName+
'_L2SApass',
247 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
250 histGroup.defineHistogram(GroupName+
'_EFCBFSpass,'+GroupName+
'_'+xvariable+
';EffEFCBFS_'+xvariable+
'_wrt_Upstream',
251 title=
'EFCBFS Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
252 cutmask=GroupName+
'_EFSAFSpass',
253 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
255 histGroup.defineHistogram(GroupName+
'_EFCBFSpass,'+GroupName+
'_'+xvariable+
';EffEFCBFS_'+xvariable+
'_wrt_offlineCB',
256 title=
'EFCBFS Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
257 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
259 histGroup.defineHistogram(GroupName+
'_EFCBFSpass,'+GroupName+
'_'+xvariable+
';EffEFCBFS_'+xvariable+
'_wrt_offlineCB_passedL2CB',
260 title=
'EFCBFS Muon Efficiency passed L2CB '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
261 cutmask=GroupName+
'_L2CBpass',
262 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
266 histGroup.defineHistogram(GroupName+
'_EFIsopass,'+GroupName+
'_'+xvariable+
';EffEFIso_'+xvariable+
'_wrt_Upstream',
267 title=
'EFIso Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
268 cutmask=GroupName+
'_EFCBpass',
269 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
271 histGroup.defineHistogram(GroupName+
'_EFIsopass,'+GroupName+
'_'+xvariable+
';EffEFIso_'+xvariable+
'_wrt_offlineCB',
272 title=
'EFIso Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
273 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
276 defineEachStepHistograms(
'muPt',
'p_{T} [GeV]', 50, 0.0, 100.)
277 defineEachStepHistograms(
'muEta',
'#eta', 30, -3.0, 3.0)
278 defineEachStepHistograms(
'muPhi',
'#phi', 30, -math.pi, math.pi)
279 if flags.GeoModel.Run >= LHCPeriod.Run4:
280 defineEachStepHistograms(
'averageMu',
'average pileup', 4, 100., 220.)
282 defineEachStepHistograms(
'averageMu',
'average pileup', 4, 0., 80.)
285 histGroup.defineHistogram(GroupName+
'_invmass;invmass',
286 title=
'invariant mass of tag & probe muon '+chain+
';inv mass [GeV];Events',
287 type=
'TH1F',path=
'',xbins=40,xmin=0.,xmax=200.)