ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronChainConfiguration.py
Go to the documentation of this file.
1#Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon.Logging import logging
4logging.getLogger().info("Importing %s",__name__)
5log = logging.getLogger(__name__)
6
7from ..Config.ChainConfigurationBase import ChainConfigurationBase
8from ..CommonSequences.CaloSequences import fastCaloSequenceGenCfg, fastCaloCalibSequenceGenCfg
9from ..CommonSequences.CaloSequences_FWD import fastCalo_FWDSequenceGenCfg
10from ..Electron.FastElectronMenuSequences import fastElectronSequenceGenCfg, fastElectron_LRTSequenceGenCfg
11from ..Electron.FastTrackingMenuSequences import fastTrackingSequenceGenCfg, fastTracking_LRTSequenceGenCfg
12from ..Electron.PrecisionCaloMenuSequences import precisionCaloSequenceGenCfg, precisionCalo_LRTSequenceGenCfg
13from ..Electron.PrecisionElectronMenuSequences import precisionElectronSequenceGenCfg, precisionElectron_LRTSequenceGenCfg
14from ..Electron.PrecisionElectronMenuSequences_GSF import precisionElectron_GSFSequenceGenCfg, precisionElectron_GSF_LRTSequenceGenCfg
15from TrigBphysHypo.TrigMultiTrkComboHypoConfig import NoMuonDiElecPrecisionGSFComboHypoCfg, DiElecPrecisionGSFComboHypoCfg, TrigMultiTrkComboHypoToolFromDict
16from ..Electron.PrecisionTrackingMenuSequences import precisionTrackingSequenceGenCfg, precisionTracking_LRTSequenceGenCfg
17from ..Electron.PrecisionTracks_GSFRefittedMenuSequences import precisionTracks_GSFRefittedSequenceGenCfg, precisionTracks_GSFRefitted_LRTSequenceGenCfg
18
19from AthenaConfiguration.ComponentFactory import CompFactory
20
21from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
22
23
24
25def _diElectronMassComboHypoToolFromDict(flags, chainDict, mass_range):
26 name = chainDict['chainName']
27 monTool = GenericMonitoringTool(flags, "MonTool_"+name,
28 HistPath = 'EgammaMassHypo/'+name)
29 monTool.defineHistogram('DphiOfProcessed', type='TH1F', path='EXPERT', title="PrecisionCalo Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
30 monTool.defineHistogram('MassOfProcessed', type='TH1F', path='EXPERT', title="Mass in accepted combinations [MeV]", xbins=75, xmin=0, xmax=150000)
31 monTool.defineHistogram('DphiOfAccepted', type='TH1F', path='EXPERT', title="PrecisionCalo Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
32 monTool.defineHistogram('MassOfAccepted', type='TH1F', path='EXPERT', title="Mass in accepted combinations [MeV]", xbins=75, xmin=0, xmax=150000)
33
34 tool = CompFactory.TrigEgammaTopoHypoTool(name,
35 AcceptAll = False,
36 ApplyMassCut = True,
37 LowerMassEgammaClusterCut = mass_range[0],
38 UpperMassEgammaClusterCut = mass_range[1],
39 MonTool = monTool)
40 return tool
41
42
44 return _diElectronMassComboHypoToolFromDict(flags, chainDict, (50000, 130000))
45
47 return _diElectronMassComboHypoToolFromDict(flags, chainDict, (1000, 5000))
48
50 return _diElectronMassComboHypoToolFromDict(flags, chainDict, (90000, 1400000))
51
52
53#----------------------------------------------------------------
54# Class to configure chain
55#----------------------------------------------------------------
56class ElectronChainConfiguration(ChainConfigurationBase):
57
58 def __init__(self, chainDict):
59 ChainConfigurationBase.__init__(self,chainDict)
60 self.chainDict = chainDict
61
62
63 # ----------------------
64 # Prepare the sequence
65 # ----------------------
66 def prepareSequence(self):
67 # This function prepares the list of step names from which assembleChainImpl would make the chain assembly from.
68
69 # --------------------
70 # define here the names of the steps and obtain the chainStep configuration
71 # --------------------
72
73 stepNames = [] # This will contain the name of the steps we will want to configure
74
75 # Step1
76 # Put first fast Calo. Two possible variants now:
77 # getFastCalo
78 # getFastCalo_fwd
79 # But first, we need to check whether this is a chain that will run smth at fast or precision. So if no L2IDAlg or IDinfo defined, just return this here
80
81 if not self.chainPart['IDinfo'] and not self.chainPart['L2IDAlg'] and not self.chainPart['isoInfo'] and not self.chainPart['addInfo']:
82 return stepNames
83
84 if "fwd" in self.chainPart['addInfo']:
85 stepNames += ['getFastCalo_fwd']
86
87 # Actually, if its fwd and etcut we will stop here (for now)
88 if "etcut" in self.chainPart['addInfo']:
89 return stepNames
90 else:
91 if 'calibringer' in self.chainPart['calibInfo']:
92 stepNames+=['getFastCaloCalib']
93 else:
94 stepNames += ['getFastCalo']
95
96 # Step2
97 # Now lets do Fast Electron. Possible Flavours:
98 # getFastTracking
99 # getFastTracking_lrt
100
101 if self.chainPart['lrtInfo']:
102 stepNames += ['getFastTracking_lrt']
103 else:
104 stepNames += ['getFastTracking']
105
106
107 # Step3
108 # Now lets do Fast Electron. Possible Flavours:
109 # getFastElectron
110 # getFastElectron_lrt
111
112 if self.chainPart['lrtInfo']:
113 stepNames += ['getFastElectron_lrt']
114 else:
115 stepNames += ['getFastElectron']
116
117
118 # Step4
119 # After Fast Electron we have to build PrecisionCalo for electorns. Current available variantas are:
120 # getPrecisionCaloElectron
121 # getPrecisionCaloElectron_lrt
122 # Now, we will add this if there is any IDInfo (i.e. any of dnn* or lh* in the chain name). Otherwise we wont run precision steps
123
124 if not self.chainPart['IDinfo'] and not self.chainPart['isoInfo'] and not self.chainPart['addInfo']:
125 log.debug("No IDInfo, no isoInfo and no addInfo. Returning here up to fastElectron")
126 return stepNames
127
128 if self.chainPart['lrtInfo']:
129 stepNames += ['getPrecisionCaloElectron_lrt']
130 else:
131 stepNames += ['getPrecisionCaloElectron']
132
133 # If its an etcut chain, we will not run precision Tracking Electron. Just precision Calo. So returning here if its an etcut chain unless its an etcut_idperf chaiin:
134
135 if 'etcut' in self.chainPart['addInfo'] and 'idperf' not in self.chainPart['idperfInfo']:
136 log.debug("This is an etcut chain. Returning here")
137 return stepNames
138
139 # Step5
140 # After precisionCalo Electron we have to do precision tracking next. Current available variantas are:
141 # getPrecisionTracking
142 # getPrecisionTracking_lrt
143
144 if self.chainPart['lrtInfo']:
145 stepNames += ['getPrecisionTracking_lrt']
146 else:
147 stepNames += ['getPrecisionTracking']
148
149 # Step6
150 # Now if a chain is configured to do gsf refitting we need to add another tracking step for the GSF refitting:
151 # getPrecisionTrack_GSFRefitted
152 # getPrecisionTrack_GSFRefitted_lrt
153
154 if "" in self.chainPart['gsfInfo'] and 'nogsf' not in self.chainPart['gsfInfo']:
155 if self.chainPart['lrtInfo']:
156 stepNames += ['getPrecisionTrack_GSFRefitted_lrt']
157 else:
158 stepNames += ['getPrecisionTrack_GSFRefitted']
159 # if its nogsf, then we need to add an addtional empty step to keep aligned the gsf chains (with the additional refitting)
160 else:
161 if 'idperf' not in self.chainPart['idperfInfo']:
162 # Only add an empty refiting step if its not an idperf - nonGSF. Otherwise the last step will be an empty step and that doesnt work
163 stepNames += ['getEmptyRefitStep']
164
165
166
167 # If its an idperf chain, we will not run precision Electron. Just precision Calo and Precision Tracking so returning here if its an etcut chain
168 if 'idperf' in self.chainPart['idperfInfo']:
169 log.debug("This is an idperf chain. Returning here")
170 return stepNames
171
172
173 # Step7
174 # and Finally! once we have precision tracking adn precision calo, we can build our electrons!. Current available variantas are:
175 # getPrecisionElectron
176 # getPrecisionGSFElectron
177 # getPrecisionElectron_lrt
178
179 if "nogsf" in self.chainPart['gsfInfo']:
180 if self.chainPart['lrtInfo']:
181 stepNames += ['getPrecisionElectron_lrt']
182 else:
183 stepNames += ['getPrecisionElectron']
184
185 else:
186 if self.chainPart['lrtInfo']:
187 stepNames += ['getPrecisionGSFElectron_lrt']
188 else:
189 stepNames += ['getPrecisionGSFElectron']
190
191 log.debug("Returning chain with all steps in the sequence")
192 return stepNames
193
194 # ----------------------
195 # Assemble the chain depending on information from chainName
196 # ----------------------
197 def assembleChainImpl(self, flags):
198 chainSteps = []
199 log.debug("Assembling chain for %s", self.chainName)
200
201 # This will contain the name of the steps we will want to configure
202 steps = self.prepareSequence()
203
204
205 # This is it, lets print the list of stepNames
206 log.debug("stepNames: %s", steps)
207 for step in steps:
208 log.debug('Adding electron trigger step %s', step)
209 is_probe_leg = self.chainPart['tnpInfo']=='probe'
210 chainstep = getattr(self, step)(flags, is_probe_leg=is_probe_leg)
211 chainSteps+=[chainstep]
212
213 myChain = self.buildChain(chainSteps)
214
215 return myChain
216
217 # -------------------------------
218 # Configuration of electron steps
219 # -------------------------------
220
221 def getFastCalo(self, flags, is_probe_leg=False):
222 stepName = "FastCalo_electron"
223 return self.getStep(flags, stepName,[fastCaloSequenceGenCfg], name='Electron', is_probe_leg=is_probe_leg)
224
225 def getFastCaloCalib(self, flags, is_probe_leg=False):
226 stepName = "FastCalo_electronCalib"
227 return self.getStep(flags, stepName,[fastCaloCalibSequenceGenCfg], name='Electron', is_probe_leg=is_probe_leg)
228
229 def getFastTracking(self, flags, is_probe_leg=False):
230 stepName = "fast_tracking"
231 return self.getStep(flags, stepName,[ fastTrackingSequenceGenCfg],is_probe_leg=is_probe_leg)
232
233 def getFastTracking_lrt(self, flags, is_probe_leg=False):
234 stepName = "fast_tracking_lrt"
235 return self.getStep(flags, stepName,[ fastTracking_LRTSequenceGenCfg],is_probe_leg=is_probe_leg)
236
237 def getFastElectron(self, flags, is_probe_leg=False):
238 if self.chainPart['idperfInfo']:
239 stepName = "fast_electron_empty"
240 return self.getEmptyStep(stepName)
241 else:
242 stepName = "fast_electron"
243 return self.getStep(flags, stepName,[fastElectronSequenceGenCfg],is_probe_leg=is_probe_leg)
244
245 def getFastElectron_lrt(self, flags, is_probe_leg=False):
246 if self.chainPart['idperfInfo']:
247 stepName = "fast_electron_lrt_empty"
248 return self.getEmptyStep(stepName)
249 else:
250 stepName = "fast_electron_lrt"
251 return self.getStep(flags, stepName,[fastElectron_LRTSequenceGenCfg],is_probe_leg=is_probe_leg)
252
253 def getPrecisionCaloElectron(self, flags, is_probe_leg=False):
254 if self.chainPart['extra'] == 'ion':
255 stepName = 'precisionCalo_ion_electron'
256 return self.getStep(flags, stepName, [precisionCaloSequenceGenCfg], ion=True, is_probe_leg=is_probe_leg)
257
258 stepName = "precisionCalo_electron"
259 return self.getStep(flags, stepName,[precisionCaloSequenceGenCfg], is_probe_leg=is_probe_leg)
260
261 def getPrecisionCaloElectron_lrt(self, flags, is_probe_leg=False):
262 stepName = "precisionCalo_electron_lrt"
263 return self.getStep(flags, stepName,[precisionCalo_LRTSequenceGenCfg],is_probe_leg=is_probe_leg)
264
265 def getPrecisionTracking(self, flags, is_probe_leg=False):
266 if self.chainPart['extra'] == 'ion':
267 stepName = 'precisionTracking_ion_electron'
268 return self.getStep(flags, stepName, [precisionTrackingSequenceGenCfg], ion=True, is_probe_leg=is_probe_leg)
269
270 stepName = "precisionTracking_electron"
271 return self.getStep(flags, stepName,[precisionTrackingSequenceGenCfg], is_probe_leg=is_probe_leg)
272
273 def getPrecisionTracking_lrt(self, flags, is_probe_leg=False):
274 stepName = "precisionTracking_electron_lrt"
275 return self.getStep(flags, stepName,[precisionTracking_LRTSequenceGenCfg],is_probe_leg=is_probe_leg)
276
277 def getPrecisionTrack_GSFRefitted(self, flags, is_probe_leg=False):
278 stepName = "PrecisionTrack_GSFRefitted_electron"
279 return self.getStep(flags, stepName,[precisionTracks_GSFRefittedSequenceGenCfg], is_probe_leg=is_probe_leg)
280
281 def getPrecisionTrack_GSFRefitted_lrt(self, flags, is_probe_leg=False):
282 stepName = "PrecisionTrack_GSFRefitted_electron_lrt"
283 return self.getStep(flags, stepName,[precisionTracks_GSFRefitted_LRTSequenceGenCfg], is_probe_leg=is_probe_leg)
284
285 def getPrecisionElectron(self, flags, is_probe_leg=False):
286
287 isocut = self.chainPart['isoInfo']
288 log.debug(' isolation cut = %s', isocut)
289
290 if "Zee" in self.chainDict['topo']:
291 stepName = "precision_electron_Zee"+str(isocut)
292 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectronSequenceGenCfg], comboTools=[diElectronZeeMassComboHypoToolFromDict], is_probe_leg=is_probe_leg)
293 elif "Jpsiee" in self.chainDict['topo']:
294 stepName = "precision_topoelectron_Jpsiee"+str(isocut)
295 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectronSequenceGenCfg], comboTools=[diElectronJpsieeMassComboHypoToolFromDict], is_probe_leg=is_probe_leg)
296 elif "Heg" in self.chainDict['topo']:
297 stepName = "precision_electron_Heg"+str(isocut)
298 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectronSequenceGenCfg], comboTools=[diEgammaHegMassComboHypoToolFromDict], is_probe_leg=is_probe_leg)
299 elif self.chainPart['extra'] == 'ion':
300 stepName = "precision_ion_electron" + str(isocut)
301 return self.getStep(flags, stepName,[precisionElectronSequenceGenCfg], ion=True, is_probe_leg=is_probe_leg)
302 else:
303 stepName = "precision_electron_nominal"+str(isocut)
304 return self.getStep(flags, stepName,[ precisionElectronSequenceGenCfg ], is_probe_leg=is_probe_leg)
305
306 def getPrecisionGSFElectron(self, flags, is_probe_leg=False):
307
308 isocut = self.chainPart['isoInfo']
309 log.debug(' isolation cut = %s', isocut)
310
311 if "Zee" in self.chainDict['topo']:
312 stepName = "precision_topoelectron_Zee_GSF"+str(isocut)
313 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectron_GSFSequenceGenCfg], comboTools=[diElectronZeeMassComboHypoToolFromDict], is_probe_leg=is_probe_leg)
314 elif "Jpsiee" in self.chainDict['topo']:
315 stepName = "precision_topoelectron_Jpsiee_GSF"+str(isocut)
316 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectron_GSFSequenceGenCfg], comboTools=[diElectronJpsieeMassComboHypoToolFromDict], is_probe_leg=is_probe_leg)
317 elif "bBeeM6000" in self.chainDict['topo']:
318 signatures = self.chainDict['signatures']
319 if signatures.count(signatures[0]) == len(signatures):
320 stepName = "noMuon_precision_electron_bBee_GSF"+str(isocut)
321 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectron_GSFSequenceGenCfg], comboHypoCfg=NoMuonDiElecPrecisionGSFComboHypoCfg, comboTools=[TrigMultiTrkComboHypoToolFromDict], is_probe_leg=is_probe_leg)
322 else:
323 stepName = "precision_electron_bBee_GSF"+str(isocut)
324 return self.getStep(flags, stepName,sequenceCfgArray=[precisionElectron_GSFSequenceGenCfg], comboHypoCfg=DiElecPrecisionGSFComboHypoCfg, comboTools=[TrigMultiTrkComboHypoToolFromDict], is_probe_leg=is_probe_leg)
325 else:
326 stepName = "precision_electron_GSF"+str(isocut)
327 return self.getStep(flags, stepName,[precisionElectron_GSFSequenceGenCfg], is_probe_leg=is_probe_leg)
328
329 def getPrecisionGSFElectron_lrt(self, flags, is_probe_leg=False):
330
331 isocut = self.chainPart['isoInfo']
332 log.debug(' isolation cut = %s', isocut)
333 stepName = "precision_electron_LRTGSF"+str(isocut)
334 return self.getStep(flags, stepName,[precisionElectron_GSF_LRTSequenceGenCfg], is_probe_leg=is_probe_leg)
335
336 def getPrecisionElectron_lrt(self, flags, is_probe_leg=False):
337
338 isocut = self.chainPart['isoInfo']
339 log.debug(' isolation cut = %s', isocut)
340 stepName = "precision_electron_lrt"+str(isocut)
341 return self.getStep(flags, stepName,[ precisionElectron_LRTSequenceGenCfg],is_probe_leg=is_probe_leg)
342
343 def getFastCalo_fwd(self, flags, is_probe_leg=False):
344 stepName = "FastCalo_FWD_electron"
345 return self.getStep(flags, stepName, [fastCalo_FWDSequenceGenCfg], name='Electron', is_probe_leg=is_probe_leg)
346
347 def getEmptyRefitStep(self, flags, is_probe_leg=False):
348 return self.getEmptyStep('nonGSFEmptyRefit')
349
350
_diElectronMassComboHypoToolFromDict(flags, chainDict, mass_range)