Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 160 of file TrigMuonEfficiencyMonConfig.py.

160 def defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, flags):
161 
162  def defineEachStepHistograms(xvariable, xlabel, xbins, xmin, xmax):
163  histGroup.defineHistogram(GroupName+'_'+xvariable+';'+xvariable,
164  title='All offline combined muon '+chain+';'+xlabel+';Events',
165  type='TH1F',path='',xbins=xbins,xmin=xmin,xmax=xmax)
166 
167  histGroup.defineHistogram(GroupName+'_L1pass,'+GroupName+'_'+xvariable+';EffL1MU_'+xvariable+'_wrt_Probe',
168  title='L1MU Efficiency '+chain+';'+xlabel+';Efficiency',
169  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
170 
171  if monAlg.doL2SA:
172  histGroup.defineHistogram(GroupName+'_L2SApass,'+GroupName+'_'+xvariable+';EffL2SA_'+xvariable+'_wrt_Upstream',
173  title='L2MuonSA Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
174  cutmask=GroupName+'_L1pass',
175  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
176 
177  histGroup.defineHistogram(GroupName+'_L2SApass,'+GroupName+'_'+xvariable+';EffL2SA_'+xvariable+'_wrt_offlineCB',
178  title='L2MuonSA Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
179  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
180 
181  if monAlg.doL2CB:
182  histGroup.defineHistogram(GroupName+'_L2CBpass,'+GroupName+'_'+xvariable+';EffL2CB_'+xvariable+'_wrt_Upstream',
183  title='L2muComb Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
184  cutmask=GroupName+'_L2SApass',
185  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
186 
187  histGroup.defineHistogram(GroupName+'_L2CBpass,'+GroupName+'_'+xvariable+';EffL2CB_'+xvariable+'_wrt_offlineCB',
188  title='L2muComb Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
189  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
190 
191  if monAlg.doEFSA:
192  histGroup.defineHistogram(GroupName+'_EFSApass,'+GroupName+'_'+xvariable+';EffEFSA_'+xvariable+'_wrt_Upstream',
193  title='EFSA Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
194  cutmask=GroupName+'_L2CBpass',
195  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
196 
197  histGroup.defineHistogram(GroupName+'_EFSApass,'+GroupName+'_'+xvariable+';EffEFSA_'+xvariable+'_wrt_offlineCB',
198  title='EFSA Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
199  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
200 
201  histGroup.defineHistogram(GroupName+'_EFSApass,'+GroupName+'_'+xvariable+';EffEFSA_'+xvariable+'_wrt_offlineCB_passedL2SA',
202  title='EFSA Muon Efficiency passed L2SA '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
203  cutmask=GroupName+'_L2SApass',
204  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
205 
206  if monAlg.doEFCB:
207  histGroup.defineHistogram(GroupName+'_EFCBpass,'+GroupName+'_'+xvariable+';EffEFCB_'+xvariable+'_wrt_Upstream',
208  title='EFCB Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
209  cutmask=GroupName+'_EFSApass',
210  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
211 
212  histGroup.defineHistogram(GroupName+'_EFCBpass,'+GroupName+'_'+xvariable+';EffEFCB_'+xvariable+'_wrt_offlineCB',
213  title='EFCB Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
214  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
215 
216  histGroup.defineHistogram(GroupName+'_EFCBpass,'+GroupName+'_'+xvariable+';EffEFCB_'+xvariable+'_wrt_offlineCB_passedL2CB',
217  title='EFCB Muon Efficiency passed L2CB '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
218  cutmask=GroupName+'_L2CBpass',
219  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
220 
221  if monAlg.doEFSAFS:
222  histGroup.defineHistogram(GroupName+'_EFSAFSpass,'+GroupName+'_'+xvariable+';EffEFSAFS_'+xvariable+'_wrt_Upstream',
223  title='EFSAFS Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
224  cutmask=GroupName+'_EFCBpass',
225  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
226 
227  histGroup.defineHistogram(GroupName+'_EFSAFSpass,'+GroupName+'_'+xvariable+';EffEFSAFS_'+xvariable+'_wrt_offlineCB',
228  title='EFSAFS Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
229  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
230 
231  histGroup.defineHistogram(GroupName+'_EFSAFSpass,'+GroupName+'_'+xvariable+';EffEFSAFS_'+xvariable+'_wrt_offlineCB_passedL2SA',
232  title='EFSAFS Muon Efficiency passed L2SA '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
233  cutmask=GroupName+'_L2SApass',
234  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
235 
236  if monAlg.doEFCBFS:
237  histGroup.defineHistogram(GroupName+'_EFCBFSpass,'+GroupName+'_'+xvariable+';EffEFCBFS_'+xvariable+'_wrt_Upstream',
238  title='EFCBFS Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
239  cutmask=GroupName+'_EFSAFSpass',
240  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
241 
242  histGroup.defineHistogram(GroupName+'_EFCBFSpass,'+GroupName+'_'+xvariable+';EffEFCBFS_'+xvariable+'_wrt_offlineCB',
243  title='EFCBFS Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
244  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
245 
246  histGroup.defineHistogram(GroupName+'_EFCBFSpass,'+GroupName+'_'+xvariable+';EffEFCBFS_'+xvariable+'_wrt_offlineCB_passedL2CB',
247  title='EFCBFS Muon Efficiency passed L2CB '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
248  cutmask=GroupName+'_L2CBpass',
249  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
250 
251 
252  if monAlg.doEFIso:
253  histGroup.defineHistogram(GroupName+'_EFIsopass,'+GroupName+'_'+xvariable+';EffEFIso_'+xvariable+'_wrt_Upstream',
254  title='EFIso Muon Efficiency '+chain+' wrt Upstream;'+xlabel+';Efficiency',
255  cutmask=GroupName+'_EFCBpass',
256  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
257 
258  histGroup.defineHistogram(GroupName+'_EFIsopass,'+GroupName+'_'+xvariable+';EffEFIso_'+xvariable+'_wrt_offlineCB',
259  title='EFIso Muon Efficiency '+chain+' wrt offlineCB;'+xlabel+';Efficiency',
260  type='TEfficiency', path='',xbins=xbins,xmin=xmin,xmax=xmax)
261 
262 
263  defineEachStepHistograms('muPt', 'p_{T} [GeV]', 50, 0.0, 100.)
264  defineEachStepHistograms('muEta', '#eta', 30, -3.0, 3.0)
265  defineEachStepHistograms('muPhi', '#phi', 30, -math.pi, math.pi)
266  if flags.GeoModel.Run >= LHCPeriod.Run4:
267  defineEachStepHistograms('averageMu', 'average pileup', 4, 100., 220.)
268  else:
269  defineEachStepHistograms('averageMu', 'average pileup', 4, 0., 80.)
270 
271 
272  histGroup.defineHistogram(GroupName+'_invmass;invmass',
273  title='invariant mass of tag & probe muon '+chain+';inv mass [GeV];Events',
274  type='TH1F',path='',xbins=40,xmin=0.,xmax=200.)
275 

◆ 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 136 of file TrigMuonEfficiencyMonConfig.py.

136 def PlotConfig(monAlg, chain):
137  from xAODMuon.xAODMuonEnums import xAODMuonEnums
138  if "msonly" in chain:
139  monAlg.MuonType = xAODMuonEnums.MuonStandAlone
140  else:
141  monAlg.MuonType = xAODMuonEnums.Combined
142 
143  if "msonly" in chain:
144  monAlg.doL2CB = False
145  monAlg.doEFCB = False
146  if "ivar" not in chain:
147  monAlg.doEFIso = False
148 
149  if "0eta105" in chain:
150  monAlg.BarrelOnly = True
151 
152  if "noL1" in chain:
153  monAlg.doEFSAFS = True
154  monAlg.doEFCBFS = True
155  else:
156  monAlg.doEFSAFS = False
157  monAlg.doEFCBFS = False
158 
159 

◆ 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  tagandprobe_chain = singlemu_chains_sorted[0]
67  log.info(f'Using {tagandprobe_chain} as tag and event trigger in ttbar tag&probe')
68 
69  from MuonSelectorTools.MuonSelectorToolsConfig import MuonSelectionToolCfg
70  for chain in MonitoredChains:
71  monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,'TrigMuEff_ttbar_'+chain,
72  MuonSelectionTool = helper.result().popToolsAndMerge(MuonSelectionToolCfg(helper.flags, MuQuality=1)))
73 
74  monAlg.EventTrigger = tagandprobe_chain
75  monAlg.TagTrigger = tagandprobe_chain
76  monAlg.Method = 'TTbarTagAndProbe'
77  monAlg.MonitoredChains = [chain]
78  threshold, level1 = regex('HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').match(chain).groups()
79  monAlg.L1Seeds = [regex('L1MU').sub('L1_MU', level1)]
80  monAlg.Thresholds = [float(threshold)]
81  monAlg.Group = 'Eff_ttbar_'+chain
82 
83  GroupName = 'Eff_ttbar_'+chain
84  histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ttbar/'+chain)
85 
86  PlotConfig(monAlg, chain)
87  defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, helper.flags)
88 
89  return
90 
91 

◆ TrigMuonEfficiencyMonZTPConfig()

def python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonZTPConfig (   helper)

Definition at line 92 of file TrigMuonEfficiencyMonConfig.py.

93 
94  from AthenaConfiguration.ComponentFactory import CompFactory
95 
96 
97  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
98  moniAccess = getHLTMonitoringAccess(helper.flags)
99  Chains = moniAccess.monitoredChains(signatures="muonMon",monLevels=["shifter","t0","val"])
100  MonitoredChains = [c for c in Chains if 'HLT_mu' in c] # this makes sure we don't consider 2mu, 3mu, 4mu chains
101 
102  # if mon groups not found fall back to hard-coded trigger monitoring list
103  if len(MonitoredChains) == 0:
104  # HLT_mu6_L1MU6 is test chain for small statistics, so it will be removed.
105  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']
106 
107 
108  singlemu_chains_sorted = get_singlemu_chain_closest_to(MonitoredChains, 24, 'ivarmedium', 14)
109  tagandprobe_chain = singlemu_chains_sorted[0]
110  log.info(f'Using {tagandprobe_chain} as tag and event trigger in Z tag&probe')
111 
112  from MuonSelectorTools.MuonSelectorToolsConfig import MuonSelectionToolCfg
113  for chain in MonitoredChains:
114  monAlg = helper.addAlgorithm(CompFactory.TrigMuonEfficiencyMon,'TrigMuEff_ZTP_'+chain,
115  MuonSelectionTool = helper.result().popToolsAndMerge(MuonSelectionToolCfg(helper.flags, MuQuality=1)))
116 
117  monAlg.EventTrigger = tagandprobe_chain
118  monAlg.TagTrigger = tagandprobe_chain
119  monAlg.Method = 'ZTagAndProbe'
120  monAlg.MonitoredChains = [chain]
121  threshold, level1 = regex('HLT_mu([0-9]+).*_(L1MU[A-Za-z0-9_]+)').match(chain).groups()
122  monAlg.L1Seeds = [regex('L1MU').sub('L1_MU', level1)]
123  monAlg.Thresholds = [float(threshold)]
124  monAlg.Group = 'Eff_ZTP_'+chain
125 
126  GroupName = 'Eff_ZTP_'+chain
127  histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ZTP/'+chain)
128 
129  PlotConfig(monAlg, chain)
130  defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain, helper.flags)
131 
132  return
133 
134 
135 

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:160
python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonZTPConfig
def TrigMuonEfficiencyMonZTPConfig(helper)
Definition: TrigMuonEfficiencyMonConfig.py:92
python.TrigMuonEfficiencyMonConfig.PlotConfig
def PlotConfig(monAlg, chain)
Definition: TrigMuonEfficiencyMonConfig.py:136
python.MuonSelectorToolsConfig.MuonSelectionToolCfg
def MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs)
Standard configuration of the MuonSelectionTool used in reconstruction & validation jobs The snippet ...
Definition: MuonSelectorToolsConfig.py:16
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