ATLAS Offline Software
JetEfficiencyMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
5  '''Function to configure LVL1 JetEfficiency algorithm in the monitoring system.'''
6 
7  # get the component factory - used for getting the algorithms
8  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9  from AthenaConfiguration.ComponentFactory import CompFactory
10  result = ComponentAccumulator()
11 
12 
13  from AthenaConfiguration.Enums import Format
14 
16  if flags.Input.Format is Format.POOL and not flags.Input.isMC and not any(["AOD" in a for a in flags.Input.ProcessingTags]):
17  from JetRecConfig.JetRecConfig import JetRecCfg
18  from JetRecConfig.StandardSmallRJets import AntiKt4EMPFlow
19  result.merge( JetRecCfg(flags,AntiKt4EMPFlow) )
20 
21  from eflowRec.PFCfg import PFGlobalFlowElementLinkingCfg
22  if flags.DQ.Environment == "AOD":
23  result.merge(PFGlobalFlowElementLinkingCfg(flags, useMuonTopoClusters=True))
24  else:
25  result.merge(PFGlobalFlowElementLinkingCfg(flags))
26  from eflowRec.PFCfg import PFGlobalFlowElementLinkingCfg
27  result.merge(PFGlobalFlowElementLinkingCfg(flags))
28  from METReconstruction.METAssociatorCfg import METAssociatorCfg
29  result.merge(METAssociatorCfg(flags, 'AntiKt4EMPFlow'))
30  from METUtilities.METMakerConfig import getMETMakerAlg
31  metCA=ComponentAccumulator()
32  metCA.addEventAlgo(getMETMakerAlg('AntiKt4EMPFlow'))
33  result.merge(metCA)
34 
35 
36  # make the athena monitoring helper
37  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
38  helper = L1CaloMonitorCfgHelper(flags,CompFactory.JetEfficiencyMonitorAlgorithm,'JetEfficiencyMonAlg')
39  groupName = 'JetEfficiencyMonitor' # the monitoring group name is also used for the package name
40  JetEfficiencyMonAlg = helper.alg
41  JetEfficiencyMonAlg.PackageName = groupName
42 
43 
44 
48 
49  # We can choose if we want to use pass before prescale, or not when defining our trigger efficiency
50  # generally only want to use pass before prescale when considering the efficiency of a trigger for
51  # internal evaluation of how triggers are behaving
52  # the prescaling is an important feature of real utility if a
53  passedb4Prescale = True
54  JetEfficiencyMonAlg.PassedBeforePrescale = passedb4Prescale
55 
56 
60 
61  #define the various reference triggers
62  hltRandom_reference_triggers = ['HLT_j0_perf_L1RD0_FILLED', 'HLT_j0_perf_pf_ftf_L1RD0_FILLED']
63  JetEfficiencyMonAlg.HLTRandomReferenceTriggers = hltRandom_reference_triggers
64 
65  muon_reference_triggers = ["L1_MU14FCH", "L1_MU18VFCH", "L1_MU8F_TAU20IM", "L1_2MU8F", "L1_MU8VF_2MU5VF", "L1_3MU3VF", "L1_MU5VF_3MU3VF", "L1_4MU3V", "L1_2MU5VF_3MU3V", "L1_RD0_FILLED"]
66  JetEfficiencyMonAlg.MuonReferenceTriggers = muon_reference_triggers
67 
68  JetEfficiencyMonAlg.BootstrapReferenceTrigger='L1_J15'
69 
70  trigPath = 'Developer/JetEfficiency/'
71  ExpertTrigPath = 'Expert/Efficiency/'
72  distributionPath = 'Distributions/'
73  noRefPath = 'NoReferenceTrigger/'
74  muonRefPath = 'MuonReferenceTrigger/'
75  randomRefPath = 'RandomHLTReferenceTrigger/'
76  bsRefPath = 'BootstrapReferenceTrigger/'
77  GeV = 1000
78 
79  # add monitoring algorithm to group, with group name and main directory
80  single_triggers = []
81  multijet_triggers = []
82  LR_triggers = []
83 
84  gfex_SR_triggers = ['L1_gJ20p0ETA25', 'L1_gJ50p0ETA25', 'L1_gJ100p0ETA25', 'L1_gJ400p0ETA25' ]
85  gfex_LR_triggers = ['L1_gLJ80p0ETA25', 'L1_gLJ100p0ETA25', 'L1_gLJ140p0ETA25', 'L1_gLJ160p0ETA25']
86 
87  jfex_SR_triggers = ['L1_jJ30','L1_jJ40','L1_jJ50', 'L1_jJ60', 'L1_jJ80','L1_jJ90', 'L1_jJ125','L1_jJ140','L1_jJ160', 'L1_jJ180']
88  jfex_LR_triggers = ['L1_SC111-CjJ40']
89 
90 
91  all_SR_singletriggers = single_triggers + gfex_SR_triggers + jfex_SR_triggers
92  all_LR_singletriggers = LR_triggers + gfex_LR_triggers + jfex_LR_triggers
93 
94  JetEfficiencyMonAlg.SmallRadiusJetTriggers_phase1 = all_SR_singletriggers
95  JetEfficiencyMonAlg.LargeRadiusJetTriggers_phase1 = all_LR_singletriggers
96  JetEfficiencyMonAlg.multiJet_LegacySmallRadiusTriggers = multijet_triggers
97 
98  reference_paths = {"Muon" : muonRefPath, "RandomHLT": randomRefPath, "No": noRefPath, "Bootstrap": bsRefPath}
99  references = ["Muon", "No", "Bootstrap"] #"RandomHLT"
100 
101 
102  trigger_group_list = {"gfex_SR_triggers" : gfex_SR_triggers,
103  "gfex_LR_triggers" : gfex_LR_triggers,
104  "jfex_SR_triggers" : jfex_SR_triggers,
105  "jfex_LR_triggers" : jfex_LR_triggers }
106  trigger_groups = list(trigger_group_list.keys())
107 
108  xlabel_for_prop = { "SRpt" :'pT [MeV]', "SReta" : '#eta', "LRpt" :'pT [MeV]', "LReta" : '#eta'}
109  nbins = {"SRpt": 220, "SReta" :32, "LRpt": 220, "LReta" :32}
110  binmin = {"SRpt": -50, "SReta" :-3.3, "LRpt": -50, "LReta" :-3.3}
111  binmax = {"SRpt": 1800*GeV, "SReta" :3.3, "LRpt": 1800*GeV, "LReta" :3.3}
112  properties = ["SRpt","LRpt"]
113 
114 
115  plotDistrubutions = False
116  if plotDistrubutions:
117  helper.defineHistogram('raw_pt',title='pT for all leading offline jets (with no trigger requirments);PT [MeV];Events', fillGroup=groupName, path=trigPath + distributionPath, xbins=nbins["SRpt"], xmin=binmin["SRpt"], xmax=binmax["SRpt"])
118 
119  helper.defineHistogram('raw_eta', title='Eta Distribution for all leading offline jets (with no trigger requirments);#eta; Count', fillGroup=groupName, path=trigPath + distributionPath, xbins=nbins["SReta"], xmin=binmin["SReta"], xmax=binmax["SReta"])
120 
121  plateau_dict = {} #in case there are low stats for some of the triggers, we could modify the threshold ranges for some triggers
122  #gives warning if we dont reach platau by first value, gives error if we dont reach it by second value
123  threshold_dict = {"L1_gJ20p0ETA25" : [55e3, 75e3], #hits 50% at 50 for a good run, 100% around 75
124  "L1_gJ50p0ETA25" : [110e3, 180e3], #hits 50% at 109 for a good run, 100% around 180
125  "L1_gJ100p0ETA25" : [195e3, 3000e3],#hits 50% at 185 for a good run, 100% around 300
126  "L1_gJ400p0ETA25" : [620e3, 900e3],#hits 50% at 611 for a good run, 100% around 900
127  "L1_gLJ80p0ETA25" : [125e3, 200e3],#hits 50% at 113 for a good run, 100% around 200
128  "L1_gLJ100p0ETA25" : [150e3, 240e3],#hits 50% at 137 for a good run, 100% around 240
129  "L1_gLJ140p0ETA25" : [210e3, 315e3],#hits 50% at 197 for a good run, 100% around 315
130  "L1_gLJ160p0ETA25" : [240e3, 260e3],#hits 50% at 225 for a good run, 100% around 350
131  "L1_jJ30" : [50e3, 85e3],#hits 50% at 46 for a good run, 100% around 85
132  "L1_jJ40" : [55e3, 90e3],#hits 50% at 47 for a good run, 100% around 90
133  "L1_jJ50" : [60e3, 100e3],#hits 50% at 53 for a good run, 100% around 100
134  "L1_jJ60" : [90e3, 130e3],#hits 50% at 85 for a good run, 100% around 130
135  "L1_jJ80" : [90e3, 155e3],#hits 50% at 86 for a good run, 100% around 155
136  "L1_jJ90" : [110e3, 185e3],#hits 50% at 105 for a good run, 100% around 185
137  "L1_jJ125" : [145e3, 230e3],#hits 50% at 140 for a good run, 100% around 230
138  "L1_jJ140" : [160e3, 225e3],#hits 50% at 150 for a good run, 100% around 255
139  "L1_jJ160" : [180e3, 260e3],#hits 50% at 170 for a good run, 100% around 260
140  "L1_jJ180" : [235e3, 320e3],#hits 50% at 223 for a good run, 100% around 320
141  "L1_SC111-CjJ40": [195e3, 300e3],#hits 50% at 190 for a good run, 100% around 300
142  }
143 
144 
145  for tgroup in trigger_groups: #iterate through the trigger groups
146  for t in trigger_group_list[tgroup]: #iterate through the triggers within subgroups
147  if "g" in t: pathAdd = "gFEX/"
148  elif "j" in t: pathAdd = "jFEX/"
149  #add algorithm that flags if the efficiency is not reaching 100%
150  # assemble thresholdConfig dict
151  thresholdConfig = {"Plateau":plateau_dict.get(t,[0.99,0.95])}
152  xMaxConfig = min(threshold_dict[t][1]*2.5, binmax["SRpt"]) #set the x maximum of the fit to be 6 times the upper limit, to help the fit work better
153  if t in threshold_dict: thresholdConfig["Threshold"] = threshold_dict[t]
154  helper.defineDQAlgorithm("JetEfficiency_"+t,
155  hanConfig={"libname":"libdqm_algorithms.so","name":"Simple_fermi_Fit_TEff", "xmax":xMaxConfig, "ImproveFit":1}, # this line is always the same
156  thresholdConfig=thresholdConfig
157  )
158  for p in properties:
159  for r in references: #iteratate through the refernce trigger options
160  eff_plot_title = t+';'+xlabel_for_prop[p]+'; Efficiency '
161 
162  #Using the muon reference trigger selection, as our least biased trigger selection inside the web displkay. Others still exist in the HIST file for now
163  if r == "Muon" and p in ["SRpt", "LRpt"]:
164  helper.defineHistogram(f"bool_{r}_{t}, val_{p};{p}_{t}", type='TEfficiency', title=eff_plot_title, fillGroup=groupName, path=ExpertTrigPath + pathAdd+ reference_paths[r], xbins=nbins[p], xmin=binmin[p], xmax=binmax[p], hanConfig={"algorithm":"JetEfficiency_"+t})
165  else:
166  helper.defineHistogram(f"bool_{r}_{t}, val_{p};{p}_{t}", type='TEfficiency', title=eff_plot_title, fillGroup=groupName, path=trigPath + pathAdd+ reference_paths[r], xbins=nbins[p], xmin=binmin[p], xmax=binmax[p])
167 
168 
169 
170  acc = helper.result()
171  result.merge(acc)
172  print("flags.DQ.Environment = " + flags.DQ.Environment )
173  return result
174 
175 
176 
177 if __name__=='__main__':
178  # set debug level for whole job
179  from AthenaCommon.Logging import log
180  from AthenaCommon.Constants import INFO #DEBUG
181  log.setLevel(INFO)
182 
183  # set input file and config options
184  from AthenaConfiguration.AllConfigFlags import initConfigFlags
185  flags = initConfigFlags()
186 
187  import glob
188 
189  inputs = glob.glob('/eos/atlas/atlastier0/rucio/data18_13TeV/physics_Main/00354311/data18_13TeV.00354311.physics_Main.recon.ESD.f1129/data18_13TeV.00354311.physics_Main.recon.ESD.f1129._lb0013._SFO-8._0001.1')
190 
191 
192  flags.Input.Files = inputs
193  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1.root'
194 
195  flags.lock()
196 
197  flags.dump() # print all the configs
198 
199  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
200  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
201  cfg = MainServicesCfg(flags)
202  cfg.merge(PoolReadCfg(flags))
203 
204  JetEfficiencyMonitorCfg = JetEfficiencyMonitoringConfig(flags)
205  cfg.merge(JetEfficiencyMonitorCfg)
206 
207 
208  # message level for algorithm
209  JetEfficiencyMonitorCfg.getEventAlgo('JetEfficiencyMonAlg').OutputLevel = 1 # 1/2 INFO/DEBUG
210  # options - print all
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
METMakerConfig.getMETMakerAlg
def getMETMakerAlg(suffix, jetSelection="Tier0", jetColl="")
Definition: METMakerConfig.py:60
METAssociatorCfg
Definition: METAssociatorCfg.py:1
python.JetRecConfig.JetRecCfg
def JetRecCfg(flags, jetdef, returnConfiguredDef=False)
Top level functions returning ComponentAccumulator out of JetDefinition.
Definition: JetRecConfig.py:36
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
JetEfficiencyMonitorAlgorithm.JetEfficiencyMonitoringConfig
def JetEfficiencyMonitoringConfig(flags)
Definition: JetEfficiencyMonitorAlgorithm.py:4
PFCfg.PFGlobalFlowElementLinkingCfg
def PFGlobalFlowElementLinkingCfg(inputFlags, **kwargs)
Definition: PFCfg.py:472