ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronD3PDObject.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#
4# @file egammaD3PDMaker/python/ElectronD3PDObject.py
5# @author scott snyder <snyder@bnl.gov>
6# @date 2009
7# @brief Configure electron D3PD object.
8#
9
10from egammaD3PDMaker.defineBlockAndAlg import defineBlockAndAlg
11from EventCommonD3PDMaker.DRAssociation import DRAssociation
12from TrackD3PDMaker.xAODTrackSummaryFiller import xAODTrackSummaryFiller
13from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject
14from D3PDMakerCoreComps.D3PDObject import DeferArg
15from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation
16from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation
17from D3PDMakerCoreComps.resolveSGKey import testSGKey
18from D3PDMakerCoreComps.resolveSGKey import resolveSGKey # noqa: F401
19from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags, configFlags # noqa: F401
20from AthenaConfiguration.ComponentFactory import CompFactory
21
22D3PD = CompFactory.D3PD
23
24
25ElectronD3PDObject = \
26 make_SGDataVector_D3PDObject ('xAOD::ElectronContainer',
27 D3PDMakerFlags.ElectronSGKey,
28 'el_', 'ElectronD3PDObject')
29
30# AuxPrefix args need to be deferred in order to add in the sgkey.
31auxprefix = DeferArg ('D3PDMakerFlags.EgammaUserDataPrefix + "_" +'
32 'resolveSGKey (configFlags, sgkey) + "_"',
33 globals())
34
35
36ElectronD3PDObject.defineBlock (0, 'Kinematics',
38 WriteE = True,
39 WriteEt = True,
40 WriteRect = True)
41ElectronD3PDObject.defineBlock (
42 0, 'Charge',
44 Vars = ['charge'])
45ElectronD3PDObject.defineBlock (
46 0, 'Author',
48 Vars = ['author'])
49ElectronD3PDObject.defineBlock (
50 0, 'Pass',
52 # These are present only for central electrons.
53 Vars = ['loose = Loose < int8_t: 0',
54 'medium = Medium < int8_t: 0',
55 'tight = Tight < int8_t : 0'
56 ])
57ElectronD3PDObject.defineBlock (
58 0, 'OQ',
60 Vars = ['OQ'])
61
62defineBlockAndAlg \
63 (ElectronD3PDObject,
64 999, 'MaxEcell',
66 'egammaMaxECellAlg',
67 AuxPrefix = auxprefix,
68 Vars = ['maxEcell_time',
69 'maxEcell_energy',
70 'maxEcell_onlId',
71 'maxEcell_gain',
72 'maxEcell_x',
73 'maxEcell_y',
74 'maxEcell_z',
75 ])
76
77defineBlockAndAlg \
78 (ElectronD3PDObject,
79 999, 'SumCellsGain',
81 'egammaSumCellsGainAlg',
82 AuxPrefix = auxprefix,
83 Vars = [
84 'Es0LowGain',
85 'Es0MedGain',
86 'Es0HighGain',
87 'Es1LowGain',
88 'Es1MedGain',
89 'Es1HighGain',
90 'Es2LowGain',
91 'Es2MedGain',
92 'Es2HighGain',
93 'Es3LowGain',
94 'Es3MedGain',
95 'Es3HighGain',
96 ])
97
98
99defineBlockAndAlg \
100 (ElectronD3PDObject,
101 999, 'NbCellsGain',
103 'egammaNbCellsGainAlg',
104 AuxPrefix = auxprefix,
105 Vars = [
106 'nbCells_s0LowGain',
107 'nbCells_s0MedGain',
108 'nbCells_s0HighGain',
109 'nbCells_s1LowGain',
110 'nbCells_s1MedGain',
111 'nbCells_s1HighGain',
112 'nbCells_s2LowGain',
113 'nbCells_s2MedGain',
114 'nbCells_s2HighGain',
115 'nbCells_s3LowGain',
116 'nbCells_s3MedGain',
117 'nbCells_s3HighGain',
118 ])
119
120
121if D3PDMakerFlags.DoTruth:
122 truthClassification = \
123 ElectronD3PDObject.defineBlock (1, 'TruthClassification',
125 DoBkgElecOrigin = True,
126 Classifier = D3PD.D3PDMCTruthClassifier())
127 def _truthClassificationHook (c, flags, acc, *args, **kw):
128 from TruthD3PDMaker.MCTruthClassifierConfig \
129 import D3PDMCTruthClassifierCfg
130 acc.merge (D3PDMCTruthClassifierCfg (flags))
131 c.Classifier = acc.getPublicTool ('D3PDMCTruthClassifier')
132 return
133 truthClassification.defineHook (_truthClassificationHook)
134 ElectronTruthPartAssoc = SimpleAssociation \
135 (ElectronD3PDObject,
137 prefix = 'truth_',
138 matched = 'matched',
139 blockname = 'TruthAssoc')
140 def _truthClassificationAssocHook (c, flags, acc, *args, **kw):
141 from TruthD3PDMaker.MCTruthClassifierConfig \
142 import D3PDMCTruthClassifierCfg
143 acc.merge (D3PDMCTruthClassifierCfg (flags))
144 c.Associator.Classifier = acc.getPublicTool ('D3PDMCTruthClassifier')
145 return
146 ElectronTruthPartAssoc.defineHook (_truthClassificationAssocHook)
147 ElectronTruthPartAssoc.defineBlock (0, 'TruthKin',
149 WriteE = True,
150 WriteM = False)
151 ElectronTruthPartAssoc.defineBlock (0, 'Truth',
152 # TruthD3PDMaker
154 PDGIDVariable = 'type')
155 ElectronTruthPartMotherAssoc = SimpleAssociation \
156 (ElectronTruthPartAssoc,
158 # TruthD3PDMaker
160 ('ElectronTruthPartMotherAssoc2'),
161 blockname = 'ElectronTruthPartMotherAssoc',
162 prefix = 'mother')
163 ElectronTruthPartMotherAssoc.defineBlock (0, 'MotherTruth',
164 # TruthD3PDMaker
166 PDGIDVariable = 'type')
167 ElectronTruthPartAssoc.defineBlock (0, 'TruthBrem',
168 # TruthD3PDMaker
170 ElectronTruthPartAssoc.defineBlock (0, 'TruthAssocIndex',
172 Target = 'mc_')
173
174
175ElectronD3PDObject.defineBlock (
176 1, 'HadLeakage',
178 Vars = ['Ethad = ethad < float: 0',
179 'Ethad1 = ethad1 < float: 0'])
180ElectronD3PDObject.defineBlock (
181 1, 'Layer1Shape',
183 Vars = ['f1',
184 'f1core',
185 'Emins1 = emins1 < float: 0',
186 'fside = fracs1',
187 'Emax2 = e2tsts1 < float: 0',
188 'ws3 = weta1',
189 'wstot = wtots1',
190 'emaxs1 < float: 0'])
191ElectronD3PDObject.defineBlock (1, 'Layer1ShapeExtra',
193ElectronD3PDObject.defineBlock (
194 1, 'Layer2Shape',
196 Vars = ['E233 = e233 < float: 0',
197 'E237 = e237 < float: 0',
198 'E277 = e277 < float: 0',
199 'weta2'])
200ElectronD3PDObject.defineBlock (
201 1, 'Layer3Shape',
203 Vars = ['f3', 'f3core'])
204ElectronD3PDObject.defineBlock (
205 1, 'Iso',
207 Vars = ['rphiallcalo = r33over37allcalo < float: 0',
208 'Etcone20 = etcone20 < float: 0',
209 'Etcone30 = etcone30 < float: 0',
210 'Etcone40 = etcone40 < float: 0',
211 'ptcone20 < float: 0',
212 'ptcone30 < float: 0',
213 'ptcone40 < float: 0',
214 ])
215ElectronD3PDObject.defineBlock (
216 2, 'IsoPtCorrected',
218 Vars = ['Etcone20_pt_corrected = etcone20_ptcorrected < float: 0 #pt-corrected isolation energy within DR=0.20 cone',
219 'Etcone30_pt_corrected = etcone30_ptcorrected < float: 0 #pt-corrected isolation energy within DR=0.30 cone',
220 'Etcone40_pt_corrected = etcone40_ptcorrected < float: 0 #pt-corrected isolation energy within DR=0.40 cone',
221 ])
222ElectronD3PDObject.defineBlock (
223 1, 'TrkMatch',
225 Vars = ['pos7 < float: 0',
226 'deltaeta1 = deltaEta1',
227 'deltaeta2 = deltaEta2',
228 'deltaphi2 = deltaPhi2',
229 'deltaphiRescaled = deltaPhiRescaled2',
230 ])
231
232
233ElectronD3PDObject.defineBlock (
234 1, 'TopoClusterIsolationCones',
236 Vars = ['topoEtcone20 = topoetcone20 < float: 0',
237 'topoEtcone30 = topoetcone30 < float: 0',
238 'topoEtcone40 = topoetcone40 < float: 0',
239 ])
240
241traversedMaterial = \
242 ElectronD3PDObject.defineBlock (2, 'TraversedMaterial',
244def _traversedMaterialExtrapolatorHook (c, flags, acc, *args, **kw):
245 from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
246 c.Extrapolator = acc.popToolsAndMerge (AtlasExtrapolatorCfg (flags))
247 return
248traversedMaterial.defineHook (_traversedMaterialExtrapolatorHook)
249
250ElectronD3PDObject.defineBlock (
251 2, 'PointingShape',
253 Vars = ['zvertex < float: 0',
254 'errz < float: 0',
255 'etap < float: 0',
256 'depth < float: 0'])
257
258
259from egammaD3PDMaker.egammaCluster import egammaCluster
260ElectronClusterAssoc = egammaCluster (ElectronD3PDObject,
261 allSamplings = True,
262 fwdEVars = True)
263
264
265
268
269
270ElectronTPAssoc = SimpleAssociation \
271 (ElectronD3PDObject,
273 matched = 'hastrack',
274 blockname = 'TrkInfo')
275
276TrackParticlePerigeeAssoc = SimpleAssociation \
277 (ElectronTPAssoc,
279 prefix = 'track')
280
281TrackParticlePerigeeAssoc.defineBlock (1, 'Trk',
282 D3PD.PerigeeFillerTool, # TrackD3PDMaker
283 FillMomentum = True)
284TrackParticleCovarAssoc = SimpleAssociation (TrackParticlePerigeeAssoc,
285 # TrackD3PDMaker
287TrackParticleCovarAssoc.defineBlock (3, 'TrkCovDiag',
288 # TrackD3PDMaker
290 IsTrackPerigee = True,
291 Error = False,
292 DiagCovariance = True)
293TrackParticleCovarAssoc.defineBlock (3, 'TrkCovOffDiag',
294 # TrackD3PDMaker
296 IsTrackPerigee = True,
297 Error = False,
298 OffDiagCovariance = True)
299
300
301ElectronTPAssoc.defineBlock (
302 2, 'TrkFitQuality',
304 Vars = ['chi2 = chiSquared < float:0',
305 'ndof = numberDoF < float:0'],
306 prefix = 'trackfit')
307
308xAODTrackSummaryFiller (ElectronTPAssoc, 1, 'IDHits',
309 IDSharedHits = True,
310 IDHits = True,
311 IDOutliers = True,
312 MuonHits = False,
313 HitSum = False,
314 HoleSum = False,
315 SCTInfoPlus = True,
316 PixelInfoPlus = True)
317
318ElectronTPAssoc.defineBlock (
319 1, 'TrackSummaryPID',
321 Vars = ['eProbabilityComb < float:0',
322 'eProbabilityHT < float:0',
323 'eProbabilityToT < float:0',
324 'eProbabilityBrem < float:0'])
325
326
327ElectronVertAssoc = SimpleAssociation \
328 (ElectronTPAssoc,
330 Fast = False,
331 prefix = 'vert')
332ElectronVertAssoc.defineBlock (
333 2, 'Vertex',
335 Vars = ['x < float:0 ', 'y < float:0', 'z < float:0'])
336
337
338from TrackD3PDMaker.TrackParticleImpactParameters \
339 import TrackParticleImpactParameters
340TrackParticleImpactParameters (ElectronTPAssoc)
341
342
343
344
345TPPerigeePairAssoc = SimpleAssociation \
346 (ElectronTPAssoc,
347 # TrackD3PDMaker
349 AssocGetter = D3PD.SGObjGetterTool
350 ('GSFAssocGetter',
351 SGKey = D3PDMakerFlags.GSFTrackAssocSGKey,
352 TypeName = 'TrackParticleAssocs'),
353 blockname = 'TPPerigeePairAssoc')
354
355UnRefittedTrackParticlePerigeeAssoc = SimpleAssociation \
356 (TPPerigeePairAssoc,
357 # TrackD3PDMaker
359 blockname = 'UnrefittedTrackPerigeeAssoc',
360 prefix = 'Unrefittedtrack_')
361
362UnRefittedTrackParticlePerigeeAssoc.defineBlock (1, 'UnrefitTrk',
363 # TrackD3PDMaker
365 FillMomentum = True)
366
367
368
371
372if D3PDMakerFlags.HaveEgammaUserData or D3PDMakerFlags.MakeEgammaUserData:
373 # `target' arg needs to be passed in from the caller;
374 # otherwise, we don't make this block.
375 def _jetAssocLevel (reqlev, args):
376 if reqlev < 2: return False
377 if 'target' not in args: return False
378 args['Target'] = args['target']
379 return True
380
381 EgammaJetDRAssoc = IndexMultiAssociation\
382 (ElectronD3PDObject,
384 '', # Overridden by the level function.
385 blockname='EgammaJetSignedIPAndPTRel',
386 prefix = 'jetcone_',
387 level = _jetAssocLevel,
388 DRCut=0.7,
389 VertexContainerName = D3PDMakerFlags.VertexSGKey)
390 def _trackToVertexHook (c, flags, acc, *args, **kw):
391 from TrkConfig.TrkVertexFitterUtilsConfig import TrackToVertexIPEstimatorCfg
392 c.Associator.TrackToVertexIPEstimator = acc.popToolsAndMerge (TrackToVertexIPEstimatorCfg (flags))
393 return
394 EgammaJetDRAssoc.defineHook (_trackToVertexHook)
395 EgammaJetDRAssoc.defineBlock \
396 (2,
397 'EgammaJetSignedIPAndPTRelKin',
399 WriteE = True)
400
401
402 EgammaTrackJetDRAssoc = IndexMultiAssociation\
403 (ElectronD3PDObject,
405 '', # Overridden by the level function.
406 blockname='EgammaTrackJetSignedIPAndPTRel',
407 prefix = 'jettrack_',
408 level = _jetAssocLevel,
409 DRCut=0.7,
410 VertexContainerName = D3PDMakerFlags.VertexSGKey)
411 EgammaTrackJetDRAssoc.defineHook (_trackToVertexHook)
412 EgammaTrackJetDRAssoc.defineBlock \
413 (2,
414 'EgammaTrackJetSignedIPAndPTRelKin',
416 WriteE = True)
417
418
419
420
421
424
425EleJetD3PDAssoc = DRAssociation (ElectronD3PDObject,
426 'DataVector<xAOD::Jet_v1>',
427 D3PDMakerFlags.JetSGKey,
428 0.2,
429 'jet_',
430 level = 2,
431 blockname = 'JetMatch')
432EleJetD3PDAssoc.defineBlock (2, 'JetKinematics',
434 WriteE = True)
435
436
437if D3PDMakerFlags.DoTruth and testSGKey (configFlags, D3PDMakerFlags.TruthJetSGKey):
438 JetTruthJetD3PDAssoc = DRAssociation (EleJetD3PDAssoc,
439 'DataVector<xAOD::Jet_v1>',
440 D3PDMakerFlags.TruthJetSGKey,
441 0.2,
442 'truth_',
443 level = 2,
444 blockname = 'TrueJetMatch')
445 JetTruthJetD3PDAssoc.defineBlock (2, 'TrueJetKinematics',
447 WriteE = True)
Copy aux data to D3PD.
Block filler tool for error and covariance matrix.
Work around MCTruthClassifier brain-damage.
For every electron find jets in a cone and store lifetime, signed IP, and PTRel of relation.
Associate from an egamma to its TrackParticle.
Choose the first result from a multiple association.
Block filler tool for a four-momentum.
Fill an index of an object within a container.
Associate from a Perigee to its ErrorMatrix.
Associate from a PerigeePair to the perigee for the original track.
Getter tool to retrieve single objects from StoreGate.
Associate from a TrackParticle to its default Perigee.
Associate from a VxCandidate to its Position ErrorMatrix.
Associate from a TrackParticle to its reconstructed vertex.
Associate from an electron/photon to a matched GenParticle via classification tool.
Block filler tool for the material traversed by a photon/electron until the entrance of the calorimet...
Fill in type/origin from MC classifier tool for an egamma.
_truthClassificationAssocHook(c, flags, acc, *args, **kw)
_jetAssocLevel(reqlev, args)
From UserData.
_trackToVertexHook(c, flags, acc, *args, **kw)
_traversedMaterialExtrapolatorHook(c, flags, acc, *args, **kw)
_truthClassificationHook(c, flags, acc, *args, **kw)