ATLAS Offline Software
ElectronD3PDObject.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 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 
10 from egammaD3PDMaker.defineBlockAndAlg import defineBlockAndAlg
11 from EventCommonD3PDMaker.DRAssociation import DRAssociation
12 from TrackD3PDMaker.xAODTrackSummaryFiller import xAODTrackSummaryFiller
13 from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject
14 from D3PDMakerCoreComps.D3PDObject import DeferArg
15 from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation
16 from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation
17 from D3PDMakerCoreComps.resolveSGKey import testSGKey
18 from D3PDMakerCoreComps.resolveSGKey import resolveSGKey # noqa: F401
19 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags, configFlags # noqa: F401
20 from AthenaConfiguration.ComponentFactory import CompFactory
21 
22 D3PD = CompFactory.D3PD
23 
24 
25 ElectronD3PDObject = \
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.
31 auxprefix = DeferArg ('D3PDMakerFlags.EgammaUserDataPrefix + "_" +'
32  'resolveSGKey (configFlags, sgkey) + "_"',
33  globals())
34 
35 
36 ElectronD3PDObject.defineBlock (0, 'Kinematics',
38  WriteE = True,
39  WriteEt = True,
40  WriteRect = True)
41 ElectronD3PDObject.defineBlock (
42  0, 'Charge',
44  Vars = ['charge'])
45 ElectronD3PDObject.defineBlock (
46  0, 'Author',
48  Vars = ['author'])
49 ElectronD3PDObject.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  ])
57 ElectronD3PDObject.defineBlock (
58  0, 'OQ',
60  Vars = ['OQ'])
61 
62 defineBlockAndAlg \
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 
77 defineBlockAndAlg \
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 
99 defineBlockAndAlg \
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 
121 if D3PDMakerFlags.DoTruth:
122  truthClassification = \
123  ElectronD3PDObject.defineBlock (1, 'TruthClassification',
125  DoBkgElecOrigin = True,
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 
175 ElectronD3PDObject.defineBlock (
176  1, 'HadLeakage',
178  Vars = ['Ethad = ethad < float: 0',
179  'Ethad1 = ethad1 < float: 0'])
180 ElectronD3PDObject.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'])
191 ElectronD3PDObject.defineBlock (1, 'Layer1ShapeExtra',
193 ElectronD3PDObject.defineBlock (
194  1, 'Layer2Shape',
196  Vars = ['E233 = e233 < float: 0',
197  'E237 = e237 < float: 0',
198  'E277 = e277 < float: 0',
199  'weta2'])
200 ElectronD3PDObject.defineBlock (
201  1, 'Layer3Shape',
203  Vars = ['f3', 'f3core'])
204 ElectronD3PDObject.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  ])
215 ElectronD3PDObject.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  ])
222 ElectronD3PDObject.defineBlock (
223  1, 'TrkMatch',
225  Vars = ['pos7 < float: 0',
226  'deltaeta1 = deltaEta1',
227  'deltaeta2 = deltaEta2',
228  'deltaphi2 = deltaPhi2',
229  'deltaphiRescaled = deltaPhiRescaled2',
230  ])
231 
232 
233 ElectronD3PDObject.defineBlock (
234  1, 'TopoClusterIsolationCones',
236  Vars = ['topoEtcone20 = topoetcone20 < float: 0',
237  'topoEtcone30 = topoetcone30 < float: 0',
238  'topoEtcone40 = topoetcone40 < float: 0',
239  ])
240 
241 traversedMaterial = \
242  ElectronD3PDObject.defineBlock (2, 'TraversedMaterial',
244 def _traversedMaterialExtrapolatorHook (c, flags, acc, *args, **kw):
245  from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
246  c.Extrapolator = acc.popToolsAndMerge (AtlasExtrapolatorCfg (flags))
247  return
248 traversedMaterial.defineHook (_traversedMaterialExtrapolatorHook)
249 
250 ElectronD3PDObject.defineBlock (
251  2, 'PointingShape',
253  Vars = ['zvertex < float: 0',
254  'errz < float: 0',
255  'etap < float: 0',
256  'depth < float: 0'])
257 
258 
259 from egammaD3PDMaker.egammaCluster import egammaCluster
260 ElectronClusterAssoc = egammaCluster (ElectronD3PDObject,
261  allSamplings = True,
262  fwdEVars = True)
263 
264 
265 
268 
269 
270 ElectronTPAssoc = SimpleAssociation \
271  (ElectronD3PDObject,
273  matched = 'hastrack',
274  blockname = 'TrkInfo')
275 
276 TrackParticlePerigeeAssoc = SimpleAssociation \
277  (ElectronTPAssoc,
279  prefix = 'track')
280 
281 TrackParticlePerigeeAssoc.defineBlock (1, 'Trk',
282  D3PD.PerigeeFillerTool, # TrackD3PDMaker
283  FillMomentum = True)
284 TrackParticleCovarAssoc = SimpleAssociation (TrackParticlePerigeeAssoc,
285  # TrackD3PDMaker
287 TrackParticleCovarAssoc.defineBlock (3, 'TrkCovDiag',
288  # TrackD3PDMaker
290  IsTrackPerigee = True,
291  Error = False,
292  DiagCovariance = True)
293 TrackParticleCovarAssoc.defineBlock (3, 'TrkCovOffDiag',
294  # TrackD3PDMaker
296  IsTrackPerigee = True,
297  Error = False,
298  OffDiagCovariance = True)
299 
300 
301 ElectronTPAssoc.defineBlock (
302  2, 'TrkFitQuality',
304  Vars = ['chi2 = chiSquared < float:0',
305  'ndof = numberDoF < float:0'],
306  prefix = 'trackfit')
307 
308 xAODTrackSummaryFiller (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 
318 ElectronTPAssoc.defineBlock (
319  1, 'TrackSummaryPID',
321  Vars = ['eProbabilityComb < float:0',
322  'eProbabilityHT < float:0',
323  'eProbabilityToT < float:0',
324  'eProbabilityBrem < float:0'])
325 
326 
327 ElectronVertAssoc = SimpleAssociation \
328  (ElectronTPAssoc,
330  Fast = False,
331  prefix = 'vert')
332 ElectronVertAssoc.defineBlock (
333  2, 'Vertex',
335  Vars = ['x < float:0 ', 'y < float:0', 'z < float:0'])
336 
337 
338 from TrackD3PDMaker.TrackParticleImpactParameters \
339  import TrackParticleImpactParameters
340 TrackParticleImpactParameters (ElectronTPAssoc)
341 
342 
343 
344 
345 TPPerigeePairAssoc = SimpleAssociation \
346  (ElectronTPAssoc,
347  # TrackD3PDMaker
349  AssocGetter = D3PD.SGObjGetterTool
350  ('GSFAssocGetter',
351  SGKey = D3PDMakerFlags.GSFTrackAssocSGKey,
352  TypeName = 'TrackParticleAssocs'),
353  blockname = 'TPPerigeePairAssoc')
354 
355 UnRefittedTrackParticlePerigeeAssoc = SimpleAssociation \
356  (TPPerigeePairAssoc,
357  # TrackD3PDMaker
359  blockname = 'UnrefittedTrackPerigeeAssoc',
360  prefix = 'Unrefittedtrack_')
361 
362 UnRefittedTrackParticlePerigeeAssoc.defineBlock (1, 'UnrefitTrk',
363  # TrackD3PDMaker
365  FillMomentum = True)
366 
367 
368 
371 
372 if 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 
425 EleJetD3PDAssoc = DRAssociation (ElectronD3PDObject,
426  'DataVector<xAOD::Jet_v1>',
427  D3PDMakerFlags.JetSGKey,
428  0.2,
429  'jet_',
430  level = 2,
431  blockname = 'JetMatch')
432 EleJetD3PDAssoc.defineBlock (2, 'JetKinematics',
434  WriteE = True)
435 
436 
437 if 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)
python.ElectronD3PDObject._trackToVertexHook
def _trackToVertexHook(c, flags, acc, *args, **kw)
Definition: ElectronD3PDObject.py:390
D3PD::egammaLayer1ExtraFillerTool
Definition: egammaLayer1ExtraFillerTool.h:26
D3PD::AuxDataFillerTool
Copy aux data to D3PD.
Definition: AuxDataFillerTool.h:35
D3PD::PerigeeFillerTool
Definition: PerigeeFillerTool.h:15
D3PD::ElectronTrackParticleAssociationTool
Associate from an egamma to its TrackParticle.
Definition: ElectronTrackParticleAssociationTool.h:33
D3PD::egammaTruthClassificationFillerTool
Fill in type/origin from MC classifier tool for an egamma.
Definition: egammaTruthClassificationFillerTool.h:37
D3PD::CovarianceFillerTool
Block filler tool for error and covariance matrix.
Definition: CovarianceFillerTool.h:31
D3PD::TruthParticleFillerTool
Definition: TruthParticleFillerTool.h:27
D3PD::SGObjGetterTool
Getter tool to retrieve single objects from StoreGate.
Definition: SGObjGetterTool.h:48
D3PD::PerigeeCovarianceAssociationTool
Associate from a Perigee to its ErrorMatrix.
Definition: PerigeeCovarianceAssociationTool.h:28
D3PD::TrackParticlePerigeeAtOOAssociationTool
Associate from a TrackParticle to its default Perigee.
Definition: TrackParticlePerigeeAtOOAssociationTool.h:32
python.ElectronD3PDObject._truthClassificationHook
def _truthClassificationHook(c, flags, acc, *args, **kw)
Definition: ElectronD3PDObject.py:127
D3PD::TrackParticleVertexAssociationTool
Associate from a TrackParticle to its reconstructed vertex.
Definition: TrackParticleVertexAssociationTool.h:37
D3PD::TruthParticleBremFillerTool
Fill the hasHardBrem flag.
Definition: TruthParticleBremFillerTool.h:28
D3PD::FirstAssociationTool
Choose the first result from a multiple association.
Definition: FirstAssociationTool.h:39
D3PD::ElectronJetDRAssociator
For every electron find jets in a cone and store lifetime, signed IP, and PTRel of relation.
Definition: ElectronJetDRAssociator.h:44
D3PD::PerigeePairOldPerigeeAssociationTool
Associate from a PerigeePair to the perigee for the original track.
Definition: PerigeePairOldPerigeeAssociationTool.h:27
python.ElectronD3PDObject._traversedMaterialExtrapolatorHook
def _traversedMaterialExtrapolatorHook(c, flags, acc, *args, **kw)
Definition: ElectronD3PDObject.py:244
D3PD::egammaGenParticleAssociationTool
Associate from an electron/photon to a matched GenParticle via classification tool.
Definition: egammaGenParticleAssociationTool.h:38
python.ElectronD3PDObject._jetAssocLevel
def _jetAssocLevel(reqlev, args)
From UserData.
Definition: ElectronD3PDObject.py:375
D3PD::FourMomFillerTool
Block filler tool for a four-momentum.
Definition: FourMomFillerTool.h:56
D3PD::TrackParticlePerigeePairAtOOAssociationTool
Associate from a VxCandidate to its Position ErrorMatrix.
Definition: TrackParticlePerigeePairAtOOAssociationTool.h:42
D3PD::TruthParticleParentAssociationTool
Associate all particles within a DR cut.
Definition: TruthParticleParentAssociationTool.h:37
D3PD::D3PDMCTruthClassifier
Work around MCTruthClassifier brain-damage.
Definition: D3PDMCTruthClassifier.h:43
python.ElectronD3PDObject._truthClassificationAssocHook
def _truthClassificationAssocHook(c, flags, acc, *args, **kw)
Definition: ElectronD3PDObject.py:140
D3PD::IndexFillerTool
Fill an index of an object within a container.
Definition: IndexFillerTool.h:32
D3PD::egammaTraversedMaterialFillerTool
Block filler tool for the material traversed by a photon/electron until the entrance of the calorimet...
Definition: egammaTraversedMaterialFillerTool.h:35