ATLAS Offline Software
xAODTrackD3PDObject.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from D3PDMakerCoreComps.flagTestLOD import flagTestLOD
4 from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject
5 from D3PDMakerCoreComps.IndexAssociation import IndexAssociation
6 from TrackD3PDMaker.PerigeeAssociation import PerigeeAssociation
7 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
8 from AthenaConfiguration.ComponentFactory import CompFactory
9 
10 D3PD = CompFactory.D3PD
11 
12 
13 def xAODTrackD3PDObject(_label='trkTrack',
14  _prefix='trkTrack_',
15  _sgkey='TrackParticleCandidate',
16  _object_name='TrackD3PDObject',
17  vertexTarget='vx',
18  vertexPrefix='vx_',
19  vertexSGKey='VxPrimaryCandidate',
20  flags = D3PDMakerFlags.Track):
21 
22  object = make_SGDataVector_D3PDObject (
23  'xAOD::TrackParticleContainer',
24  _sgkey,
25  _prefix,
26  _object_name,
27  default_allowMissing = True,
28  default_label = _label,
29  allow_args = ['storeTrackMomentum',
30  'trackParametersAtGlobalPerigeeLevelOfDetails',
31  'trackParametersAtPrimaryVertexLevelOfDetails',
32  'trackParametersAtBeamSpotLevelOfDetails',
33  'storeDiagonalCovarianceAsErrors',
34  'storeTrackFitQuality',
35  'storeTrackPredictionAtBLayer',
36  'storeTrackInfo',
37  'storeVertexAssociation',
38  'storeTrackSummary',
39  ])
40 
41 
42  PerigeeAssoc = PerigeeAssociation\
43  (object,
45  "GlobalPerigee",
46  fillMomName = 'storeTrackMomentum',
47  levelName = 'trackParametersAtGlobalPerigeeLevelOfDetails')
48 
49  perigeeBLPrediction = \
50  PerigeeAssoc.defineBlock (flagTestLOD('storeTrackPredictionAtBLayer', flags),
51  _prefix+'BLayerInfo',
53  def _pixelLayerToolHook (c, flags, acc, *args, **kw):
54  from InDetConfig.InDetTestPixelLayerConfig import InDetTestPixelLayerToolInnerCfg
55  c.InDetTestPixelLayerTool = acc.popToolsAndMerge (InDetTestPixelLayerToolInnerCfg (flags))
56  return
57  perigeeBLPrediction.defineHook (_pixelLayerToolHook)
58 
59  # perigee at Primary Vertex
60  PerigeeAtPVAssoc = PerigeeAssociation(object, # noqa: F841
62  "PerigeeAtPV",
63  suffix='_wrtPV',
64  levelName = 'trackParametersAtPrimaryVertexLevelOfDetails')
65  def _trackToVertexHook (c, flags, acc, *args, **kw):
66  from TrackToVertex.TrackToVertexConfig import InDetTrackToVertexCfg
67  c.Associator.TrackToVertexTool = acc.popToolsAndMerge (InDetTrackToVertexCfg (flags))
68  return
69  PerigeeAtPVAssoc.defineHook (_trackToVertexHook)
70 
71  # perigee at Beam Spot
72  PerigeeAtBSAssoc = PerigeeAssociation(object, # noqa: F841
74  "PerigeeAtBS",
75  suffix='_wrtBS',
76  levelName = 'trackParametersAtBeamSpotLevelOfDetails')
77  PerigeeAtBSAssoc.defineHook (_trackToVertexHook)
78 
79  object.defineBlock(flagTestLOD('storeTrackFitQuality', flags),
80  _prefix+'FitQuality',
82  Vars = ['chiSquared',
83  'numberDoF'])
84 
85  # Track Summary
86  class SumVars:
87  HitSum = 1 << 0
88  HoleSum = 1 << 1
89  IDHits = 1 << 2
90  IDHoles = 1 << 3
91  IDSharedHits = 1 << 4
92  IDOutliers = 1 << 5
93  PixelInfoPlus = 1 << 6
94  SCTInfoPlus = 1 << 7
95  TRTInfoPlus = 1 << 8
96  InfoPlus = 1 << 9
97  ExpectBLayer = 1 << 10
98  MuonHits = 1 << 11
99  DBMHits = 1 << 12
100 
101 
102  varsTable = [
103  # ID hits
104  [IDHits, 'nBLHits', 'numberOfInnermostPixelLayerHits'],
105  [IDHits + HitSum, 'nPixHits', 'numberOfPixelHits' ],
106  [IDHits + HitSum, 'nSCTHits', 'numberOfSCTHits' ],
107  [IDHits + HitSum, 'nTRTHits', 'numberOfTRTHits' ],
108  [IDHits, 'nTRTHighTHits', 'numberOfTRTHighThresholdHits'],
109  [IDHits, 'nTRTXenonHits', 'numberOfTRTXenonHits'],
110 
111  # ID holes + dead sensors - needed for appropriate cutting
112  [IDHoles + HoleSum, 'nPixHoles', 'numberOfPixelHoles' ],
113  [IDHoles + HoleSum, 'nSCTHoles', 'numberOfSCTHoles' ],
114  [IDHoles + HoleSum, 'nTRTHoles', 'numberOfTRTHoles' ],
115  [IDHoles, 'nPixelDeadSensors', 'numberOfPixelDeadSensors' ],
116  [IDHoles, 'nSCTDeadSensors', 'numberOfSCTDeadSensors' ],
117 
118  # ID shared & Split hits
119  [IDSharedHits, 'nBLSharedHits', 'numberOfInnermostPixelLayerSharedHits'],
120  [IDSharedHits, 'nPixSharedHits', 'numberOfPixelSharedHits'],
121  [IDSharedHits, 'nSCTSharedHits', 'numberOfSCTSharedHits'],
122  [IDSharedHits, 'nBLayerSplitHits', 'numberOfInnermostPixelLayerSplitHits'],
123  [IDSharedHits, 'nPixSplitHits', 'numberOfPixelSplitHits'],
124 
125  # ID outliers
126  [IDOutliers, 'nBLayerOutliers', 'numberOfInnermostPixelLayerOutliers' ],
127  [IDOutliers, 'nPixelOutliers', 'numberOfPixelOutliers' ],
128  [IDOutliers, 'nSCTOutliers', 'numberOfSCTOutliers' ],
129  [IDOutliers, 'nTRTOutliers', 'numberOfTRTOutliers'],
130  [IDOutliers, 'nTRTHighTOutliers', 'numberOfTRTHighThresholdOutliers'],
131 
132  # Pixel info plus
133  [PixelInfoPlus, 'nContribPixelLayers', 'numberOfContribPixelLayers' ],
134  [PixelInfoPlus, 'nGangedPixels', 'numberOfGangedPixels' ],
135  [PixelInfoPlus, 'nGangedFlaggedFakes', 'numberOfGangedFlaggedFakes' ],
136  [PixelInfoPlus, 'nPixelSpoiltHits', 'numberOfPixelSpoiltHits' ],
137 
138  # SCT info plus
139  [SCTInfoPlus, 'nSCTDoubleHoles', 'numberOfSCTDoubleHoles' ],
140  [SCTInfoPlus, 'nSCTSpoiltHits', 'numberOfSCTSpoiltHits' ],
141 
142  # TRT info plus
143  [TRTInfoPlus, 'nTRTDeadStraws', 'numberOfTRTDeadStraws' ],
144  [TRTInfoPlus, 'nTRTTubeHits', 'numberOfTRTTubeHits' ],
145  [TRTInfoPlus, 'nTRTSharedHits', 'numberOfTRTSharedHits' ],
146  [TRTInfoPlus, 'nTRTHTHitsTotal', 'numberOfTRTHighThresholdHitsTotal' ],
147 
148  # Info plus
149  [InfoPlus, 'nOutliersOnTrack', 'numberOfOutliersOnTrack'],
150  [InfoPlus, 'standardDeviationOfChi2OS',],
151 
152  # Expect BLayer hit
153  [ExpectBLayer, 'expectInnermostPixelLayerHit'],
154 
155  # Muon hits
156  [MuonHits + HitSum, 'numberOfPrecisionLayers'],
157  [MuonHits + HitSum, 'numberOfPrecisionHoleLayers'],
158  [MuonHits + HitSum, 'numberOfPhiLayers'],
159  [MuonHits + HitSum, 'numberOfPhiHoleLayers'],
160  [MuonHits + HitSum, 'numberOfTriggerEtaLayers'],
161  [MuonHits + HitSum, 'numberOfTriggerEtaHoleLayers'],
162  ]
163 
164 
165  @classmethod
166  def varlist (cls,
167  FullInfo,
168  IDHits,
169  IDHoles,
170  IDSharedHits,
171  IDOutliers,
172  PixelInfoPlus,
173  SCTInfoPlus,
174  TRTInfoPlus,
175  InfoPlus,
176  ExpectBLayer,
177  MuonHits,
178  DBMHits,
179  HitSum,
180  HoleSum,
181  ElectronPID,
182  PixeldEdx):
183  ret = []
184  mask = 0
185  if FullInfo: mask = ~0
186  if IDHits: mask |= cls.IDHits
187  if IDHoles: mask |= cls.IDHoles
188  if IDSharedHits: mask |= cls.IDSharedHits
189  if IDOutliers: mask |= cls.IDOutliers
190  if PixelInfoPlus: mask |= cls.PixelInfoPlus
191  if SCTInfoPlus: mask |= cls.SCTInfoPlus
192  if TRTInfoPlus: mask |= cls.TRTInfoPlus
193  if InfoPlus: mask |= cls.InfoPlus
194  if ExpectBLayer: mask |= cls.ExpectBLayer
195  if MuonHits: mask |= cls.MuonHits
196  if DBMHits: mask |= cls.DBMHits
197  if HitSum: mask |= cls.HitSum
198  if HoleSum: mask |= cls.HoleSum
199 
200  for v in cls.varsTable:
201  if (v[0] & mask) != 0:
202  var = v[1]
203  enum = v[2] if len(v) >= 3 else var
204  ret.append (var + ' = ' + enum)
205 
206  if ElectronPID or FullInfo:
207  ret.append ('eProbabilityComb')
208  ret.append ('eProbabilityHT')
209 
210  if PixeldEdx or FullInfo:
211  ret.append ('pixeldEdx')
212  ret.append ('numberOfUsedHitsdEdx')
213  ret.append ('numberOfIBLOverflowsdEdx')
214  return ret
215 
216 
217  sumvarlist = SumVars.varlist (
218  FullInfo = flags.storeTrackSummaryFlags.FullInfo,
219  IDHits = flags.storeTrackSummaryFlags.IDHits,
220  IDHoles = flags.storeTrackSummaryFlags.IDHoles,
221  IDSharedHits = flags.storeTrackSummaryFlags.IDSharedHits,
222  IDOutliers = flags.storeTrackSummaryFlags.IDOutliers,
223  PixelInfoPlus = flags.storeTrackSummaryFlags.PixelInfoPlus,
224  SCTInfoPlus = flags.storeTrackSummaryFlags.SCTInfoPlus,
225  TRTInfoPlus = flags.storeTrackSummaryFlags.TRTInfoPlus,
226  InfoPlus = flags.storeTrackSummaryFlags.InfoPlus,
227  ExpectBLayer = flags.storeTrackSummaryFlags.ExpectBLayer,
228  MuonHits = flags.storeTrackSummaryFlags.MuonHits,
229  DBMHits = flags.storeTrackSummaryFlags.DBMHits,
230  HitSum = flags.storeTrackSummaryFlags.HitSum,
231  HoleSum = flags.storeTrackSummaryFlags.HoleSum,
232  ElectronPID = flags.storeTrackSummaryFlags.ElectronPID,
233  PixeldEdx = flags.storeTrackSummaryFlags.PixeldEdx,
234  )
235 
236  object.defineBlock (flagTestLOD('storeTrackSummary', flags),
237  _prefix + 'TrackSummary',
239  Vars = sumvarlist)
240 
241 
242  # Track Info
243  object.defineBlock (flagTestLOD('storeTrackInfo', flags),
244  _prefix + 'TrackInfo',
246  Vars = ['trackFitter',
247  'particleHypothesis',
248  'trackProperties',
249  'patternRecoInfo'])
250 
251  # Vertex association
252  VertexAssoc = IndexAssociation(object, # noqa: F841
254  vertexTarget,
255  prefix = vertexPrefix,
256  VxSGKey = vertexSGKey,
257  level = flagTestLOD('storeVertexAssociation', flags))
258 
259  return object
260 
261 
262 xAODTrackParticleD3PDObject = xAODTrackD3PDObject()
python.ElectronD3PDObject._trackToVertexHook
def _trackToVertexHook(c, flags, acc, *args, **kw)
Definition: ElectronD3PDObject.py:390
D3PD::AuxDataFillerTool
Copy aux data to D3PD.
Definition: AuxDataFillerTool.h:35
D3PD::TrackParticlePerigeeAtOOAssociationTool
Associate from a TrackParticle to its default Perigee.
Definition: TrackParticlePerigeeAtOOAssociationTool.h:32
D3PD::TrackParticlePerigeeAtBSAssociationTool
Associate from a VxCandidate to its perigee at the beam spot.
Definition: TrackParticlePerigeeAtBSAssociationTool.h:33
python.xAODTrackD3PDObject.xAODTrackD3PDObject
def xAODTrackD3PDObject(_label='trkTrack', _prefix='trkTrack_', _sgkey='TrackParticleCandidate', _object_name='TrackD3PDObject', vertexTarget='vx', vertexPrefix='vx_', vertexSGKey='VxPrimaryCandidate', flags=D3PDMakerFlags.Track)
Definition: xAODTrackD3PDObject.py:13
D3PD::TrackParticleVertexAssociationTool
Associate from a TrackParticle to its reconstructed vertex.
Definition: TrackParticleVertexAssociationTool.h:37
python.flagTestLOD.flagTestLOD
def flagTestLOD(expr, flags, hook=None)
Definition: flagTestLOD.py:20
python.PerigeeAssociation.PerigeeAssociation
def PerigeeAssociation(parent, associator, blockname, suffix='', flags=D3PDMakerFlags.Track, fillMomName='False', levelName=None, **kw)
Definition: PerigeeAssociation.py:23
D3PD::PerigeeBLPredictionFillerTool
Fill expectHitInBLayer from a Perigee.
Definition: PerigeeBLPredictionFillerTool.h:29
python.IndexAssociation.IndexAssociation
def IndexAssociation(parent, assoctool, target, prefix='', level=0, blockname=None, allowMissing=False, containerIndexName='', **kw)
Definition: IndexAssociation.py:17
D3PD::TrackParticlePerigeeAtPVAssociationTool
Associate from a VxCandidate to its perigee at primary vertex.
Definition: TrackParticlePerigeeAtPVAssociationTool.h:33