ATLAS Offline Software
Functions | Variables
python.TrigMuonEfficiencyMonConfig Namespace Reference

Functions

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

Variables

 log
 

Function Documentation

◆ defineEfficiencyHistograms()

def python.TrigMuonEfficiencyMonConfig.defineEfficiencyHistograms (   monAlg,
  histGroup,
  GroupName,
  chain,
  flags 
)

Definition at line 173 of file TrigMuonEfficiencyMonConfig.py.

173 def defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, flags):
174 
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)
179 
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)
183 
184  if monAlg.doL2SA:
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)
189 
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)
193 
194  if monAlg.doL2CB:
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)
199 
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)
203 
204  if monAlg.doEFSA:
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)
209 
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)
213 
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)
218 
219  if monAlg.doEFCB:
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)
224 
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)
228 
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)
233 
234  if monAlg.doEFSAFS:
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)
239 
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)
243 
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)
248 
249  if monAlg.doEFCBFS:
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)
254 
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)
258 
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)
263 
264 
265  if monAlg.doEFIso:
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)
270 
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)
274 
275 
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.)
281  else:
282  defineEachStepHistograms('averageMu', 'average pileup', 4, 0., 80.)
283 
284 
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.)
288 

◆ get_singlemu_chain_closest_to()

def python.TrigMuonEfficiencyMonConfig.get_singlemu_chain_closest_to (   chainList,
  ref_hlt_pt,
  ref_hlt_type,
  ref_l1_pt 
)

Definition at line 18 of file TrigMuonEfficiencyMonConfig.py.

18 def 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 

◆ PlotConfig()

def python.TrigMuonEfficiencyMonConfig.PlotConfig (   monAlg,
  chain 
)

Definition at line 149 of file TrigMuonEfficiencyMonConfig.py.

149 def PlotConfig(monAlg, chain):
150  from xAODMuon.xAODMuonEnums import xAODMuonEnums
151  if "msonly" in chain:
152  monAlg.MuonType = xAODMuonEnums.MuonStandAlone
153  else:
154  monAlg.MuonType = xAODMuonEnums.Combined
155 
156  if "msonly" in chain:
157  monAlg.doL2CB = False
158  monAlg.doEFCB = False
159  if "ivar" not in chain:
160  monAlg.doEFIso = False
161 
162  if "0eta105" in chain:
163  monAlg.BarrelOnly = True
164 
165  if "noL1" in chain:
166  monAlg.doEFSAFS = True
167  monAlg.doEFCBFS = True
168  else:
169  monAlg.doEFSAFS = False
170  monAlg.doEFCBFS = False
171 
172 

◆ regex()

def python.TrigMuonEfficiencyMonConfig.regex (   pat)

Definition at line 10 of file TrigMuonEfficiencyMonConfig.py.

10 def 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()

def python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonTTbarConfig (   helper)

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.

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 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)),
78  MuonMatchingTool = helper.result().popToolsAndMerge(MuonMatchingToolConfig(helper.flags)))
79 
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
88 
89  GroupName = 'Eff_ttbar_'+chain
90  histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ttbar/'+chain)
91 
92  PlotConfig(monAlg, chain)
93  defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, helper.flags)
94 
95  return
96 
97 

◆ TrigMuonEfficiencyMonZTPConfig()

def python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonZTPConfig (   helper)

Definition at line 98 of file TrigMuonEfficiencyMonConfig.py.

99 
100  from AthenaConfiguration.ComponentFactory import CompFactory
101 
102 
103  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
104  moniAccess = getHLTMonitoringAccess(helper.flags)
105  Chains = moniAccess.monitoredChains(signatures="muonMon",monLevels=["shifter","t0","val"])
106  MonitoredChains = [c for c in Chains if 'HLT_mu' in c] # this makes sure we don't consider 2mu, 3mu, 4mu chains
107 
108  # if mon groups not found fall back to hard-coded trigger monitoring list
109  if len(MonitoredChains) == 0:
110  # HLT_mu6_L1MU6 is test chain for small statistics, so it will be removed.
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']
112 
113 
114  singlemu_chains_sorted = get_singlemu_chain_closest_to(MonitoredChains, 24, 'ivarmedium', 14)
115  if not singlemu_chains_sorted:
116  log.warning('No suitable single-muon trigger chain found as tag for Z tag&probe.')
117  return
118  else:
119  tagandprobe_chain = singlemu_chains_sorted[0]
120  log.info(f'Using {tagandprobe_chain} as tag and event trigger in Z tag&probe')
121 
122 
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)),
128  MuonMatchingTool = helper.result().popToolsAndMerge(MuonMatchingToolConfig(helper.flags)))
129 
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
138 
139  GroupName = 'Eff_ZTP_'+chain
140  histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ZTP/'+chain)
141 
142  PlotConfig(monAlg, chain)
143  defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, helper.flags)
144 
145  return
146 
147 
148 

Variable Documentation

◆ log

python.TrigMuonEfficiencyMonConfig.log

Definition at line 8 of file TrigMuonEfficiencyMonConfig.py.

DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
ChainDefInMenu.groups
groups
Definition: ChainDefInMenu.py:43
python.TriggerConfigAccess.getHLTMonitoringAccess
HLTMonitoringAccess getHLTMonitoringAccess(flags=None)
Definition: TriggerConfigAccess.py:256
python.TrigMuonEfficiencyMonConfig.regex
def regex(pat)
Definition: TrigMuonEfficiencyMonConfig.py:10
python.TrigMuonEfficiencyMonConfig.get_singlemu_chain_closest_to
def get_singlemu_chain_closest_to(chainList, ref_hlt_pt, ref_hlt_type, ref_l1_pt)
Definition: TrigMuonEfficiencyMonConfig.py:18
python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonTTbarConfig
def TrigMuonEfficiencyMonTTbarConfig(helper)
A special configuration for ttbar samples, where the cut on m_mumu is loosened to improve the accepta...
Definition: TrigMuonEfficiencyMonConfig.py:49
python.TrigMuonEfficiencyMonConfig.defineEfficiencyHistograms
def defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, flags)
Definition: TrigMuonEfficiencyMonConfig.py:173
python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonZTPConfig
def TrigMuonEfficiencyMonZTPConfig(helper)
Definition: TrigMuonEfficiencyMonConfig.py:98
python.TrigMuonEfficiencyMonConfig.PlotConfig
def PlotConfig(monAlg, chain)
Definition: TrigMuonEfficiencyMonConfig.py:149
python.MuonSelectorToolsConfig.MuonSelectionToolCfg
def MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs)
Definition: MuonSelectorToolsConfig.py:13
python.MuonMatchingToolConfig.MuonMatchingToolConfig
def MuonMatchingToolConfig(flags)
Definition: MuonMatchingToolConfig.py:3
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65