ATLAS Offline Software
PhotonD3PDObject.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/PhotonD3PDObject.py
5 # @author Haifeng Li <Haifeng.Li@cern.ch>, scott snyder <snyder@bnl.gov>
6 # @date 13 Aug. 2009
7 # @brief Configure photon D3PD object.
8 #
9 
10 from egammaD3PDMaker.defineBlockAndAlg import defineBlockAndAlg
11 from EventCommonD3PDMaker.DRAssociation import DRAssociation
12 from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject
13 from D3PDMakerCoreComps.D3PDObject import DeferArg
14 from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation
15 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
16 from D3PDMakerConfig.D3PDMakerFlags import configFlags # noqa: F401
17 from D3PDMakerCoreComps.resolveSGKey import testSGKey
18 from D3PDMakerCoreComps.resolveSGKey import resolveSGKey # noqa: F401
19 from TrackD3PDMaker.xAODTrackSummaryFiller import xAODTrackSummaryFiller
20 from D3PDMakerCoreComps.ContainedVectorMultiAssociation import ContainedVectorMultiAssociation
21 from AthenaConfiguration.ComponentFactory import CompFactory
22 
23 D3PD = CompFactory.D3PD
24 
25 
26 
27 PhotonD3PDObject = \
28  make_SGDataVector_D3PDObject ('xAOD::PhotonContainer',
29  D3PDMakerFlags.PhotonSGKey,
30  'ph_', 'PhotonD3PDObject')
31 
32 # AuxPrefix args need to be deferred in order to add in the sgkey.
33 auxprefix = DeferArg ('D3PDMakerFlags.EgammaUserDataPrefix + "_" +'
34  'resolveSGKey (configFlags, sgkey) + "_"',
35  globals())
36 
37 
38 PhotonD3PDObject.defineBlock (0, 'Kinematics',
40  WriteE = True,
41  WriteEt = True,
42  WriteRect = True)
43 PhotonD3PDObject.defineBlock (
44  0, 'Author',
46  Vars = ['author'])
47 PhotonD3PDObject.defineBlock (
48  0, 'Pass',
50  Vars = ['loose = Loose',
51  'tight = Tight'
52  ])
53 PhotonD3PDObject.defineBlock (
54  0, 'OQ',
56  Vars = ['OQ'])
57 
58 PhotonD3PDObject.defineBlock (0, 'Conversion0',
60  )
61 
62 defineBlockAndAlg \
63  (PhotonD3PDObject,
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 defineBlockAndAlg \
77  (PhotonD3PDObject,
78  999, 'SumCellsGain',
80  'egammaSumCellsGainAlg',
81  AuxPrefix = auxprefix,
82  Vars = [
83  'Es0LowGain',
84  'Es0MedGain',
85  'Es0HighGain',
86  'Es1LowGain',
87  'Es1MedGain',
88  'Es1HighGain',
89  'Es2LowGain',
90  'Es2MedGain',
91  'Es2HighGain',
92  'Es3LowGain',
93  'Es3MedGain',
94  'Es3HighGain',
95  ])
96 defineBlockAndAlg \
97  (PhotonD3PDObject,
98  999, 'NbCellsGain',
100  'egammaNbCellsGainAlg',
101  AuxPrefix = auxprefix,
102  Vars = [
103  'nbCells_s0LowGain',
104  'nbCells_s0MedGain',
105  'nbCells_s0HighGain',
106  'nbCells_s1LowGain',
107  'nbCells_s1MedGain',
108  'nbCells_s1HighGain',
109  'nbCells_s2LowGain',
110  'nbCells_s2MedGain',
111  'nbCells_s2HighGain',
112  'nbCells_s3LowGain',
113  'nbCells_s3MedGain',
114  'nbCells_s3HighGain',
115  ])
116 
117 
118 if D3PDMakerFlags.DoTruth:
119  truthClassification = \
120  PhotonD3PDObject.defineBlock (1, 'TruthClassification',
123  def _truthClassificationHook (c, flags, acc, *args, **kw):
124  from TruthD3PDMaker.MCTruthClassifierConfig \
125  import D3PDMCTruthClassifierCfg
126  acc.merge (D3PDMCTruthClassifierCfg (flags))
127  c.Classifier = acc.getPublicTool ('D3PDMCTruthClassifier')
128  return
129  truthClassification.defineHook (_truthClassificationHook)
130  PhotonTruthPartAssoc = SimpleAssociation \
131  (PhotonD3PDObject,
133  prefix = 'truth_',
134  matched = 'matched',
135  blockname = 'TruthAssoc',
136  DRVar = 'deltaRRecPhoton')
137  def _truthClassificationAssocHook (c, flags, acc, *args, **kw):
138  from TruthD3PDMaker.MCTruthClassifierConfig \
139  import D3PDMCTruthClassifierCfg
140  acc.merge (D3PDMCTruthClassifierCfg (flags))
141  c.Associator.Classifier = acc.getPublicTool ('D3PDMCTruthClassifier')
142  return
143  PhotonTruthPartAssoc.defineHook (_truthClassificationAssocHook)
144  PhotonTruthPartAssoc.defineBlock (0, 'TruthKin',
146  WriteE = True,
147  WriteM = False)
148  PhotonTruthPartAssoc.defineBlock (0, 'Truth',
149  # TruthD3PDMaker
151  PDGIDVariable = 'type')
152  PhotonTruthPartMotherAssoc = SimpleAssociation \
153  (PhotonTruthPartAssoc,
155  # TruthD3PDMaker
157  ('PhotonTruthPartMotherAssoc2'),
158  blockname = 'PhotonTruthPartMotherAssoc',
159  prefix = 'mother')
160  PhotonTruthPartMotherAssoc.defineBlock (0, 'MotherTruth',
161  # TruthD3PDMaker
163  PDGIDVariable = 'type')
164  PhotonTruthPartAssoc.defineBlock (0, 'TruthAssocIndex',
166  Target = 'mc_')
167 
168 
169 
170 PhotonD3PDObject.defineBlock (
171  1, 'HadLeakage',
173  Vars = ['Ethad = ethad',
174  'Ethad1 = ethad1'])
175 PhotonD3PDObject.defineBlock (
176  1, 'Layer0Shape',
178  Vars = ['E033 = e033 < float : 0'])
179 PhotonD3PDObject.defineBlock (
180  1, 'Layer1Shape',
182  Vars = ['f1',
183  'f1core',
184  'Emins1 = emins1',
185  'fside = fracs1',
186  'Emax2 = e2tsts1',
187  'ws3 = weta1',
188  'wstot = wtots1',
189  'E132 = e132 < float : 0',
190  'E1152 = e1152 < float : 0',
191  'emaxs1'])
192 PhotonD3PDObject.defineBlock (1, 'Layer1ShapeExtra',
194 PhotonD3PDObject.defineBlock (
195  1, 'Layer2Shape',
197  Vars = ['E233 = e233',
198  'E237 = e237',
199  'E277 = e277',
200  'weta2'])
201 PhotonD3PDObject.defineBlock (
202  1, 'Layer3Shape',
204  Vars = ['f3', 'f3core'])
205 PhotonD3PDObject.defineBlock (
206  1, 'Iso',
208  Vars = ['rphiallcalo = r33over37allcalo',
209  'Etcone20 = etcone20 < float: 0',
210  'Etcone30 = etcone30 < float: 0',
211  'Etcone40 = etcone40 < float: 0',
212  'ptcone20 < float: 0',
213  'ptcone30 < float: 0',
214  'ptcone40 < float: 0',
215  ])
216 PhotonD3PDObject.defineBlock (
217  2, 'IsoPtCorrected',
219  Vars = ['Etcone20_pt_corrected = etcone20_ptcorrected < float: 0 #pt-corrected isolation energy within DR=0.20 cone',
220  'Etcone30_pt_corrected = etcone30_ptcorrected < float: 0 #pt-corrected isolation energy within DR=0.30 cone',
221  'Etcone40_pt_corrected = etcone40_ptcorrected < float: 0 #pt-corrected isolation energy within DR=0.40 cone',
222  ])
223 PhotonD3PDObject.defineBlock (1, 'Conversion',
225 PhotonD3PDObject.defineBlock (1, 'Retaphi',
227 
228 
229 
230 PhotonD3PDObject.defineBlock (
231  1, 'TopoClusterIsolationCones',
233  Vars = ['topoEtcone20 = topoetcone20_core57cells,topoetcone20',
234  'topoEtcone30 = topoetcone30_core57cells,topoetcone30',
235  'topoEtcone40 = topoetcone40_core57cells,topoetcone40',
236  ])
237 
238 traversedMaterial = \
239  PhotonD3PDObject.defineBlock (2, 'TraversedMaterial',
241 def _traversedMaterialExtrapolatorHook (c, flags, acc, prefix, *args, **kw):
242  from TrkConfig.AtlasExtrapolatorConfig import AtlasExtrapolatorCfg
243  c.Extrapolator = acc.popToolsAndMerge (AtlasExtrapolatorCfg (flags))
244  return
245 traversedMaterial.defineHook (_traversedMaterialExtrapolatorHook)
246 
247 
248 PhotonD3PDObject.defineBlock (
249  2, 'Pointing',
251  Vars = ['zvertex < float:0 ',
252  'errz < float:0 ',
253  'etap < float: 0',
254  'depth < float: 0'])
255 
256 from egammaD3PDMaker.egammaCluster import egammaCluster
257 PhotonClusterAssoc = egammaCluster (PhotonD3PDObject)
258 
259 
260 PhotonD3PDObject.defineBlock (
261  1, 'ConvDeltaEtaPhi',
263  Vars = ['convMatchDeltaEta1',
264  'convMatchDeltaEta2',
265  'convMatchDeltaPhi1',
266  'convMatchDeltaPhi2',
267  ])
268 
269 
270 #----------------------------------------------
271 # This part gets all conversion vertices
272 # associated with the photon. So it makes vector<vector<vector<T>>>'s, again with the
273 # index pointing towards the trk_ block.
274 #
275 
276 # Associate the photon with secondary vertices
277 ConversionVertexAssociation = ContainedVectorMultiAssociation (
278  PhotonD3PDObject,
280  prefix='vx_')
281 ConversionVertexAssociation.defineBlock (
282  10, 'ConversionVertexPosition',
284  Vars = ['x < float:0 ', 'y < float:0', 'z < float:0'])
285 ConversionVertexAssociation.defineBlock (
286  10, 'ConversionVertexKinematics',
287  # TrackD3PDMaker
289 
290 
291 ConversionVertexTrackParticleAssociation = \
292  ContainedVectorMultiAssociation (ConversionVertexAssociation,
293  # TrackD3PDMaker
295  prefix = 'convTrk_')
296 
297 
298 # `target' arg needs to be passed in from the caller;
299 # otherwise, we don't make this block.
300 def _cvAssocLevel (reqlev, args):
301  if reqlev < 10: return False
302  if 'target' not in args: return False
303  args['Target'] = args['target']
304  del args['target']
305  return True
306 ConversionVertexTrackParticleAssociation.defineBlock (
307  _cvAssocLevel, "ConversionVertexTrackIndex",
309  # Target will be filled in by level function.
310  Target = '')
311 
312 ConversionVertexTrackParticleAssociation.defineBlock (
313  10, 'ConversionVertexTrackInfo',
315  Vars = ['fitter = trackFitter < unsigned char: 0',
316  'patternReco = patternRecoInfo < unsigned long: 0',
317  'trackProperties < unsigned char: 0',
318  'particleHypothesis < unsigned char: 0',
319  ])
320 
321 xAODTrackSummaryFiller (ConversionVertexTrackParticleAssociation,
322  10, 'CoversionTrackSummary',
323  IDHits = True,
324  IDHoles = True,
325  IDSharedHits = True,
326  IDOutliers = True,
327  PixelInfoPlus = True,
328  SCTInfoPlus = True,
329  TRTInfoPlus = True,
330  InfoPlus = True,
331  MuonHits = False,
332  MuonHoles = False,
333  ExpectBLayer = True,
334  HitSum = False,
335  HoleSum = False,
336  )
337 ConversionVertexTrackParticleAssociation.defineBlock (
338  10, 'ConversionTrackSummaryPID',
340  Vars = ['eProbabilityComb',
341  'eProbabilityHT',
342  'eProbabilityToT < float:0',
343  'eProbabilityBrem < float:0'])
344 ConversionVertexTrackParticleAssociation.defineBlock (
345  10, 'ConversionTrackFitQuality',
347  Vars = ['chi2 = chiSquared',
348  'ndof = numberDoF'])
349 
350 
351 
352 
355 
356 if D3PDMakerFlags.HaveEgammaUserData or D3PDMakerFlags.MakeEgammaUserData:
357  if D3PDMakerFlags.DoTruth:
358  defineBlockAndAlg \
359  (PhotonD3PDObject,
360  0, 'UDTruthFlags',
362  'PhotonTruth',
363  AuxPrefix = auxprefix,
364  Vars = ['truth_isConv',
365  'truth_isBrem',
366  'truth_isFromHardProc',
367  'truth_isPhotonFromHardProc',
368  ])
369 
370  defineBlockAndAlg \
371  (PhotonD3PDObject,
372  1, 'UDTruthConv',
374  'PhotonTruth',
375  AuxPrefix = auxprefix,
376  Vars = ['truth_Rconv',
377  'truth_zconv',
378  ])
379 
380  defineBlockAndAlg (PhotonD3PDObject,
381  1, 'UDLayer1Shape',
383  'egammaDeltaEmax2',
384  AuxPrefix = auxprefix,
385  Vars = ['deltaEmax2',
386  ])
387 
388 
389 
390 
393 
394 PhotonJetD3PDAssoc = DRAssociation (PhotonD3PDObject,
395  'DataVector<xAOD::Jet_v1>',
396  D3PDMakerFlags.JetSGKey,
397  0.2,
398  'jet_',
399  level = 2,
400  blockname = 'JetMatch')
401 PhotonJetD3PDAssoc.defineBlock (2, 'JetKinematics',
403  WriteE = True)
404 
405 
406 if D3PDMakerFlags.DoTruth and testSGKey (configFlags, D3PDMakerFlags.TruthJetSGKey):
407  JetTruthJetD3PDAssoc = DRAssociation (PhotonJetD3PDAssoc,
408  'DataVector<xAOD::Jet_v1>',
409  D3PDMakerFlags.TruthJetSGKey,
410  0.2,
411  'truth_',
412  level = 2,
413  blockname = 'TrueJetMatch')
414  JetTruthJetD3PDAssoc.defineBlock (2, 'TrueJetKinematics',
416  WriteE = True)
417 
418 
419 
420 
421 
424 
425 
426 PhotonTopoD3PDAssoc = DRAssociation (PhotonD3PDObject,
427  'DataVector<xAOD::CaloCluster_v1>',
428  D3PDMakerFlags.ClusterSGKey,
429  0.1,
430  'topo',
431  level = 2,
432  blockname = 'TopoMatch')
433 PhotonTopoD3PDAssoc.defineBlock (2, 'TopoKinematics',
435  WriteM = False)
D3PD::egammaRetaphiFillerTool
Definition: egammaRetaphiFillerTool.h:26
D3PD::egammaLayer1ExtraFillerTool
Definition: egammaLayer1ExtraFillerTool.h:26
D3PD::AuxDataFillerTool
Copy aux data to D3PD.
Definition: AuxDataFillerTool.h:35
D3PD::egammaTruthClassificationFillerTool
Fill in type/origin from MC classifier tool for an egamma.
Definition: egammaTruthClassificationFillerTool.h:37
python.PhotonD3PDObject._cvAssocLevel
def _cvAssocLevel(reqlev, args)
Definition: PhotonD3PDObject.py:300
D3PD::egammaConversion0FillerTool
Block filler tool for photon conversion information, for LOD 0.
Definition: egammaConversion0FillerTool.h:29
D3PD::TruthParticleFillerTool
Definition: TruthParticleFillerTool.h:27
python.PhotonD3PDObject._truthClassificationAssocHook
def _truthClassificationAssocHook(c, flags, acc, *args, **kw)
Definition: PhotonD3PDObject.py:137
python.PhotonD3PDObject._traversedMaterialExtrapolatorHook
def _traversedMaterialExtrapolatorHook(c, flags, acc, prefix, *args, **kw)
Definition: PhotonD3PDObject.py:241
D3PD::VertexKineFillerTool
Block filler tool for vertex kinematics, from attached tracks.
Definition: VertexKineFillerTool.h:29
D3PD::FirstAssociationTool
Choose the first result from a multiple association.
Definition: FirstAssociationTool.h:39
D3PD::egammaConversionFillerTool
Block filler tool for photon conversion information.
Definition: egammaConversionFillerTool.h:29
D3PD::VertexTrackParticleAssociationTool
Definition: VertexTrackParticleAssociationTool.h:28
D3PD::egammaGenParticleAssociationTool
Associate from an electron/photon to a matched GenParticle via classification tool.
Definition: egammaGenParticleAssociationTool.h:38
D3PD::ConversionVertexAssociationTool
Associate from a conversion to its vertex.
Definition: ConversionVertexAssociationTool.h:34
D3PD::FourMomFillerTool
Block filler tool for a four-momentum.
Definition: FourMomFillerTool.h:56
python.PhotonD3PDObject._truthClassificationHook
def _truthClassificationHook(c, flags, acc, *args, **kw)
Definition: PhotonD3PDObject.py:123
D3PD::TruthParticleParentAssociationTool
Associate all particles within a DR cut.
Definition: TruthParticleParentAssociationTool.h:37
D3PD::D3PDMCTruthClassifier
Work around MCTruthClassifier brain-damage.
Definition: D3PDMCTruthClassifier.h:43
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