6 from AthenaCommon.Logging
import logging
7 log = logging.getLogger(
'TrigMuonEfficiencyMonConfig.py')
10 if 'cached_regex' not in globals():
13 if pat
not in cached_regex:
14 cached_regex.update({pat:re.compile(pat)})
15 return cached_regex[pat]
23 for chainName
in chainList:
25 match =
regex(
'HLT_mu([0-9]+)(?:_([a-zA-Z_]+))?_(L1MU([0-9]+)[A-Z_]+)').
match(chainName)
27 hlt_threshold =
float(match.group(1))
28 hlt_type = match.group(2)
30 level1_threshold =
float(match.group(4))
31 if hlt_type
is None or hlt_type ==
'ivarmedium':
32 chain_data.append((chainName, hlt_type, hlt_threshold, level1_threshold))
40 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))
41 chainList_sorted = [x[0]
for x
in chain_data_sorted]
42 return chainList_sorted
50 from AthenaConfiguration.ComponentFactory
import CompFactory
53 from TrigConfigSvc.TriggerConfigAccess
import getHLTMonitoringAccess
55 Chains = moniAccess.monitoredChains(signatures=
"muonMon",monLevels=[
"shifter",
"t0",
"val"])
56 MonitoredChains = [c
for c
in Chains
if 'HLT_mu' in c]
59 if len(MonitoredChains) == 0:
61 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']
65 tagandprobe_chain = singlemu_chains_sorted[0]
66 log.info(f
'Using {tagandprobe_chain} as tag and event trigger in ttbar tag&probe')
68 from MuonSelectorTools.MuonSelectorToolsConfig
import MuonSelectionToolCfg
69 for chain
in MonitoredChains:
70 monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,
'TrigMuEff_ttbar_'+chain,
71 MuonSelectionTool = helper.result().popToolsAndMerge(
MuonSelectionToolCfg(helper.flags, MuQuality=1)))
73 monAlg.EventTrigger = tagandprobe_chain
74 monAlg.TagTrigger = tagandprobe_chain
75 monAlg.Method =
'TTbarTagAndProbe'
76 monAlg.MonitoredChains = [chain]
77 threshold, level1 =
regex(
'HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').
match(chain).
groups()
78 monAlg.L1Seeds = [
regex(
'L1MU').sub(
'L1_MU', level1)]
79 monAlg.Thresholds = [
float(threshold)]
80 monAlg.Group =
'Eff_ttbar_'+chain
82 GroupName =
'Eff_ttbar_'+chain
83 histGroup = helper.addGroup(monAlg, GroupName,
'HLT/MuonMon/Efficiency/ttbar/'+chain)
93 from AthenaConfiguration.ComponentFactory
import CompFactory
96 from TrigConfigSvc.TriggerConfigAccess
import getHLTMonitoringAccess
98 Chains = moniAccess.monitoredChains(signatures=
"muonMon",monLevels=[
"shifter",
"t0",
"val"])
99 MonitoredChains = [c
for c
in Chains
if 'HLT_mu' in c]
102 if len(MonitoredChains) == 0:
104 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']
108 tagandprobe_chain = singlemu_chains_sorted[0]
109 log.info(f
'Using {tagandprobe_chain} as tag and event trigger in Z tag&probe')
111 from MuonSelectorTools.MuonSelectorToolsConfig
import MuonSelectionToolCfg
112 for chain
in MonitoredChains:
113 monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,
'TrigMuEff_ZTP_'+chain,
114 MuonSelectionTool = helper.result().popToolsAndMerge(
MuonSelectionToolCfg(helper.flags, MuQuality=1)))
116 monAlg.EventTrigger = tagandprobe_chain
117 monAlg.TagTrigger = tagandprobe_chain
118 monAlg.Method =
'ZTagAndProbe'
119 monAlg.MonitoredChains = [chain]
120 threshold, level1 =
regex(
'HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').
match(chain).
groups()
121 monAlg.L1Seeds = [
regex(
'L1MU').sub(
'L1_MU', level1)]
122 monAlg.Thresholds = [
float(threshold)]
123 monAlg.Group =
'Eff_ZTP_'+chain
125 GroupName =
'Eff_ZTP_'+chain
126 histGroup = helper.addGroup(monAlg, GroupName,
'HLT/MuonMon/Efficiency/ZTP/'+chain)
136 from xAODMuon.xAODMuonEnums
import xAODMuonEnums
137 if "msonly" in chain:
138 monAlg.MuonType = xAODMuonEnums.MuonStandAlone
140 monAlg.MuonType = xAODMuonEnums.Combined
142 if "msonly" in chain:
143 monAlg.doL2CB =
False
144 monAlg.doEFCB =
False
145 if "ivar" not in chain:
146 monAlg.doEFIso =
False
148 if "0eta105" in chain:
149 monAlg.BarrelOnly =
True
152 monAlg.doEFSAFS =
True
153 monAlg.doEFCBFS =
True
155 monAlg.doEFSAFS =
False
156 monAlg.doEFCBFS =
False
161 def defineEachStepHistograms(xvariable, xlabel, xbins, xmin, xmax):
162 histGroup.defineHistogram(GroupName+
'_'+xvariable+
';'+xvariable,
163 title=
'All offline combined muon '+chain+
';'+xlabel+
';Events',
164 type=
'TH1F',path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
166 histGroup.defineHistogram(GroupName+
'_L1pass,'+GroupName+
'_'+xvariable+
';EffL1MU_'+xvariable+
'_wrt_Probe',
167 title=
'L1MU Efficiency '+chain+
';'+xlabel+
';Efficiency',
168 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
171 histGroup.defineHistogram(GroupName+
'_L2SApass,'+GroupName+
'_'+xvariable+
';EffL2SA_'+xvariable+
'_wrt_Upstream',
172 title=
'L2MuonSA Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
173 cutmask=GroupName+
'_L1pass',
174 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
176 histGroup.defineHistogram(GroupName+
'_L2SApass,'+GroupName+
'_'+xvariable+
';EffL2SA_'+xvariable+
'_wrt_offlineCB',
177 title=
'L2MuonSA Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
178 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
181 histGroup.defineHistogram(GroupName+
'_L2CBpass,'+GroupName+
'_'+xvariable+
';EffL2CB_'+xvariable+
'_wrt_Upstream',
182 title=
'L2muComb Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
183 cutmask=GroupName+
'_L2SApass',
184 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
186 histGroup.defineHistogram(GroupName+
'_L2CBpass,'+GroupName+
'_'+xvariable+
';EffL2CB_'+xvariable+
'_wrt_offlineCB',
187 title=
'L2muComb Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
188 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
191 histGroup.defineHistogram(GroupName+
'_EFSApass,'+GroupName+
'_'+xvariable+
';EffEFSA_'+xvariable+
'_wrt_Upstream',
192 title=
'EFSA Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
193 cutmask=GroupName+
'_L2CBpass',
194 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
196 histGroup.defineHistogram(GroupName+
'_EFSApass,'+GroupName+
'_'+xvariable+
';EffEFSA_'+xvariable+
'_wrt_offlineCB',
197 title=
'EFSA Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
198 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
200 histGroup.defineHistogram(GroupName+
'_EFSApass,'+GroupName+
'_'+xvariable+
';EffEFSA_'+xvariable+
'_wrt_offlineCB_passedL2SA',
201 title=
'EFSA Muon Efficiency passed L2SA '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
202 cutmask=GroupName+
'_L2SApass',
203 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
206 histGroup.defineHistogram(GroupName+
'_EFCBpass,'+GroupName+
'_'+xvariable+
';EffEFCB_'+xvariable+
'_wrt_Upstream',
207 title=
'EFCB Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
208 cutmask=GroupName+
'_EFSApass',
209 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
211 histGroup.defineHistogram(GroupName+
'_EFCBpass,'+GroupName+
'_'+xvariable+
';EffEFCB_'+xvariable+
'_wrt_offlineCB',
212 title=
'EFCB Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
213 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
215 histGroup.defineHistogram(GroupName+
'_EFCBpass,'+GroupName+
'_'+xvariable+
';EffEFCB_'+xvariable+
'_wrt_offlineCB_passedL2CB',
216 title=
'EFCB Muon Efficiency passed L2CB '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
217 cutmask=GroupName+
'_L2CBpass',
218 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
221 histGroup.defineHistogram(GroupName+
'_EFSAFSpass,'+GroupName+
'_'+xvariable+
';EffEFSAFS_'+xvariable+
'_wrt_Upstream',
222 title=
'EFSAFS Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
223 cutmask=GroupName+
'_EFCBpass',
224 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
226 histGroup.defineHistogram(GroupName+
'_EFSAFSpass,'+GroupName+
'_'+xvariable+
';EffEFSAFS_'+xvariable+
'_wrt_offlineCB',
227 title=
'EFSAFS Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
228 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
230 histGroup.defineHistogram(GroupName+
'_EFSAFSpass,'+GroupName+
'_'+xvariable+
';EffEFSAFS_'+xvariable+
'_wrt_offlineCB_passedL2SA',
231 title=
'EFSAFS Muon Efficiency passed L2SA '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
232 cutmask=GroupName+
'_L2SApass',
233 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
236 histGroup.defineHistogram(GroupName+
'_EFCBFSpass,'+GroupName+
'_'+xvariable+
';EffEFCBFS_'+xvariable+
'_wrt_Upstream',
237 title=
'EFCBFS Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
238 cutmask=GroupName+
'_EFSAFSpass',
239 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
241 histGroup.defineHistogram(GroupName+
'_EFCBFSpass,'+GroupName+
'_'+xvariable+
';EffEFCBFS_'+xvariable+
'_wrt_offlineCB',
242 title=
'EFCBFS Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
243 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
245 histGroup.defineHistogram(GroupName+
'_EFCBFSpass,'+GroupName+
'_'+xvariable+
';EffEFCBFS_'+xvariable+
'_wrt_offlineCB_passedL2CB',
246 title=
'EFCBFS Muon Efficiency passed L2CB '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
247 cutmask=GroupName+
'_L2CBpass',
248 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
252 histGroup.defineHistogram(GroupName+
'_EFIsopass,'+GroupName+
'_'+xvariable+
';EffEFIso_'+xvariable+
'_wrt_Upstream',
253 title=
'EFIso Muon Efficiency '+chain+
' wrt Upstream;'+xlabel+
';Efficiency',
254 cutmask=GroupName+
'_EFCBpass',
255 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
257 histGroup.defineHistogram(GroupName+
'_EFIsopass,'+GroupName+
'_'+xvariable+
';EffEFIso_'+xvariable+
'_wrt_offlineCB',
258 title=
'EFIso Muon Efficiency '+chain+
' wrt offlineCB;'+xlabel+
';Efficiency',
259 type=
'TEfficiency', path=
'',xbins=xbins,xmin=xmin,xmax=xmax)
262 defineEachStepHistograms(
'muPt',
'p_{T} [GeV]', 50, 0.0, 100.)
263 defineEachStepHistograms(
'muEta',
'#eta', 30, -3.0, 3.0)
264 defineEachStepHistograms(
'muPhi',
'#phi', 30, -math.pi, math.pi)
265 defineEachStepHistograms(
'averageMu',
'average pileup', 4, 0., 80.)
268 histGroup.defineHistogram(GroupName+
'_invmass;invmass',
269 title=
'invariant mass of tag & probe muon '+chain+
';inv mass [GeV];Events',
270 type=
'TH1F',path=
'',xbins=40,xmin=0.,xmax=200.)