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)
 

Variables

 log
 

Function Documentation

◆ defineEfficiencyHistograms()

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

Definition at line 159 of file TrigMuonEfficiencyMonConfig.py.

159 def defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain):
160 
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)
165 
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)
169 
170  if monAlg.doL2SA:
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)
175 
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)
179 
180  if monAlg.doL2CB:
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)
185 
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)
189 
190  if monAlg.doEFSA:
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)
195 
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)
199 
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)
204 
205  if monAlg.doEFCB:
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)
210 
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)
214 
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)
219 
220  if monAlg.doEFSAFS:
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)
225 
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)
229 
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)
234 
235  if monAlg.doEFCBFS:
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)
240 
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)
244 
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)
249 
250 
251  if monAlg.doEFIso:
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)
256 
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)
260 
261 
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.)
266 
267 
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.)
271 

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

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

◆ PlotConfig()

def python.TrigMuonEfficiencyMonConfig.PlotConfig (   monAlg,
  chain 
)

Definition at line 135 of file TrigMuonEfficiencyMonConfig.py.

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

◆ regex()

def python.TrigMuonEfficiencyMonConfig.regex (   pat)

Definition at line 9 of file TrigMuonEfficiencyMonConfig.py.

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

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

49 
50  from AthenaConfiguration.ComponentFactory import CompFactory
51 
52 
53  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
54  moniAccess = getHLTMonitoringAccess(helper.flags)
55  Chains = moniAccess.monitoredChains(signatures="muonMon",monLevels=["shifter","t0","val"])
56  MonitoredChains = [c for c in Chains if 'HLT_mu' in c] # this makes sure we don't consider 2mu, 3mu, 4mu chains
57 
58  # if mon groups not found fall back to hard-coded trigger monitoring list
59  if len(MonitoredChains) == 0:
60  # HLT_mu6_L1MU6 is test chain for small statistics, so it will be removed.
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']
62 
63 
64  singlemu_chains_sorted = get_singlemu_chain_closest_to(MonitoredChains, 24, 'ivarmedium', 14)
65  tagandprobe_chain = singlemu_chains_sorted[0]
66  log.info(f'Using {tagandprobe_chain} as tag and event trigger in ttbar tag&probe')
67 
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)))
72 
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
81 
82  GroupName = 'Eff_ttbar_'+chain
83  histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ttbar/'+chain)
84 
85  PlotConfig(monAlg, chain)
86  defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain)
87 
88  return
89 
90 

◆ TrigMuonEfficiencyMonZTPConfig()

def python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonZTPConfig (   helper)

Definition at line 91 of file TrigMuonEfficiencyMonConfig.py.

92 
93  from AthenaConfiguration.ComponentFactory import CompFactory
94 
95 
96  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
97  moniAccess = getHLTMonitoringAccess(helper.flags)
98  Chains = moniAccess.monitoredChains(signatures="muonMon",monLevels=["shifter","t0","val"])
99  MonitoredChains = [c for c in Chains if 'HLT_mu' in c] # this makes sure we don't consider 2mu, 3mu, 4mu chains
100 
101  # if mon groups not found fall back to hard-coded trigger monitoring list
102  if len(MonitoredChains) == 0:
103  # HLT_mu6_L1MU6 is test chain for small statistics, so it will be removed.
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']
105 
106 
107  singlemu_chains_sorted = get_singlemu_chain_closest_to(MonitoredChains, 24, 'ivarmedium', 14)
108  tagandprobe_chain = singlemu_chains_sorted[0]
109  log.info(f'Using {tagandprobe_chain} as tag and event trigger in Z tag&probe')
110 
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)))
115 
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
124 
125  GroupName = 'Eff_ZTP_'+chain
126  histGroup = helper.addGroup(monAlg, GroupName, 'HLT/MuonMon/Efficiency/ZTP/'+chain)
127 
128  PlotConfig(monAlg, chain)
129  defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain)
130 
131  return
132 
133 
134 

Variable Documentation

◆ log

python.TrigMuonEfficiencyMonConfig.log

Definition at line 7 of file TrigMuonEfficiencyMonConfig.py.

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:9
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:17
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:48
python.TrigMuonEfficiencyMonConfig.defineEfficiencyHistograms
def defineEfficiencyHistograms(monAlg, histGroup, GroupName, chain)
Definition: TrigMuonEfficiencyMonConfig.py:159
python.TrigMuonEfficiencyMonConfig.TrigMuonEfficiencyMonZTPConfig
def TrigMuonEfficiencyMonZTPConfig(helper)
Definition: TrigMuonEfficiencyMonConfig.py:91
python.TrigMuonEfficiencyMonConfig.PlotConfig
def PlotConfig(monAlg, chain)
Definition: TrigMuonEfficiencyMonConfig.py:135
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
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
readCCLHist.float
float
Definition: readCCLHist.py:83
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356