TrackSummary.h 15.3 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
7
8
9
10
11
12
13
/***************************************************************************
Summary.h  -  description
-------------------
begin                : Tue Feb 17 2004
email                : edward.moyse@cern.ch
***************************************************************************/

#ifndef TRKTRACKSUMMARY_H
#define TRKTRACKSUMMARY_H

14
15
#include "TrkTrackSummary/InDetTrackSummary.h"
#include "TrkTrackSummary/MuonTrackSummary.h"
16
#include <atomic>
17
18
19
20
#include <bitset>
#include <iostream>
#include <memory>
#include <vector>
21
22

class MsgStream;
23
24
class TrackSummaryCnv_p1;
class TrackSummaryCnv_p2;
25
26

namespace InDet {
27
class InDetTrackSummaryHelperTool;
28
29
30
}

namespace Muon {
31
class MuonTrackSummaryHelperTool;
32
33
34
35
}

namespace Trk {

36
37
38
// forward declarations
class Track;
class TrackSummaryTool;
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/** enumerates the different types of information stored in Summary. Use in
get(const SummaryType type), for for example, summary.get(numOfPixelHits) When
adding a new transient information type, please make sure to increase
numberOfTrackSummaryTypes.*/
enum SummaryType
{
  // --- Inner Detector
  //!< number of contributing layers of the pixel detector

  numberOfContribPixelLayers = 29,
  //!< these are the hits in the first pixel layer, i.e. b-layer
  numberOfBLayerHits = 0,
  //!< number of blayer outliers
  numberOfBLayerOutliers = 31,
  //!< number of Pixel b-layer hits shared by several tracks.
  numberOfBLayerSharedHits = 16,
  //!< number of Pixel b-layer hits split by cluster splitting
  numberOfBLayerSplitHits = 43,
  //!< Do we expect a b-layer hit for this track?
  expectBLayerHit = 42,
  //!< Do we expect a 0th-layer hit for this track?
  expectInnermostPixelLayerHit = 52,
  //!< these are the hits in the 0th pixel layer?
  numberOfInnermostPixelLayerHits = 53,
  //!< number of 0th layer outliers
  numberOfInnermostPixelLayerOutliers = 54,
  //!< number of Pixel 0th layer hits shared by several tracks.
  numberOfInnermostPixelLayerSharedHits = 55,
  //!< number of Pixel 0th layer hits split by cluster splitting
  numberOfInnermostLayerSplitHits = 56,
  //!< Do we expect a 1st-layer hit for this track?
  expectNextToInnermostPixelLayerHit = 57,
  //!< these are the hits in the 1st pixel layer
  numberOfNextToInnermostPixelLayerHits = 58,
  //!< number of 1st pixel layer outliers
  numberOfNextToInnermostPixelLayerOutliers = 59,
  //!< number of Pixel 1st layer hits shared by several tracks.
  numberOfNextToInnermostPixelLayerSharedHits = 60,
  //!< number of Pixel 1st layer hits split by cluster splitting
  numberOfNextToInnermostLayerSplitHits = 61,
  //!< these are the pixel hits, including the b-layer
  numberOfPixelHits = 2,
  //!< these are the pixel outliers, including the b-layer
  numberOfPixelOutliers = 41,
  //!< number of pixel layers on track with absence of hits
  numberOfPixelHoles = 1,
  //!< number of Pixel all-layer hits shared by several tracks.
  numberOfPixelSharedHits = 17,
  //!< number of Pixel all-layer hits split by cluster splitting
  numberOfPixelSplitHits = 44,
  //!< number of pixels which have a ganged ambiguity.
  numberOfGangedPixels = 14,
  //!< number of Ganged Pixels flagged as fakes
  numberOfGangedFlaggedFakes = 32,
  //!< number of dead pixel sensors crossed
  numberOfPixelDeadSensors = 33,
  //!< number of pixel hits with broad errors (width/sqrt(12))
  numberOfPixelSpoiltHits = 35,
  //!< number of DBM Hits
  numberOfDBMHits = 63,
  //!< number of hits in SCT
  numberOfSCTHits = 3,
  //!< number of SCT outliers
  numberOfSCTOutliers = 39,
  //!< number of SCT holes
  numberOfSCTHoles = 4,
  //!< number of Holes in both sides of a SCT module
  numberOfSCTDoubleHoles = 28,
  //!< number of SCT hits shared by several tracks.
  numberOfSCTSharedHits = 18,
  numberOfSCTDeadSensors = 34,
  //!< number of TRT hits
  numberOfSCTSpoiltHits = 36,
  numberOfTRTHits = 5,
  //!< number of TRT outliers
  numberOfTRTOutliers = 19,
  //!< number of TRT holes
  numberOfTRTHoles = 40,
  //!< number of TRT hits which pass the high
  //!< threshold (only xenon counted)
  //!< total number of TRT hits which pass the high threshold
  numberOfTRTHighThresholdHits = 6,
  //!< total number of TRT hits which pass the high threshold
  numberOfTRTHighThresholdHitsTotal = 64,
  //!< number of TRT hits used for dE/dx computation
  numberOfTRTHitsUsedFordEdx = 65,
  //!< number of TRT high threshold outliers (only xenon counted)
  numberOfTRTHighThresholdOutliers = 20,
  //!< number of dead TRT straws crossed
  numberOfTRTDeadStraws = 37,
  //!< number of TRT tube hits
  numberOfTRTTubeHits = 38,
  //!< number of TRT hits on track in straws with xenon
  numberOfTRTXenonHits = 46,
  //!< number of TRT hits used by more than one track
  numberOfTRTSharedHits = 62,

  // --- Muon Spectrometer
  //!< number of mdt hits
  numberOfMdtHits = 7,
  //!< tgc, rpc and csc measure both phi and eta coordinate
  numberOfTgcPhiHits = 8,
  numberOfTgcEtaHits = 9,
  numberOfCscPhiHits = 10,
  numberOfCscEtaHits = 11,
  numberOfRpcPhiHits = 12,
  numberOfRpcEtaHits = 13,
  //! number of CSC Eta measurements missing from the track
  numberOfCscEtaHoles = 21,
  //! number of CSC Phi measurements missing from the track
  numberOfCscPhiHoles = 22,
  //! number of RPC Eta measurements missing from the track
  numberOfRpcEtaHoles = 23,
  //! number of RPC Phi measurements missing from the track
  numberOfRpcPhiHoles = 24,
  //! number of MDT measurements missing from the track
  numberOfMdtHoles = 25,
  //! number of TGC Eta measurements missing from the track
  numberOfTgcEtaHoles = 26,
  //! number of TGC Phi measurements missing from the track
  numberOfTgcPhiHoles = 27,

  // New Small Wheel
  //! number of TGC Eta measurements missing from the track
  numberOfStgcEtaHits = 67,
  //! number of TGC Phi measurements missing from the track
  numberOfStgcPhiHits = 68,
  //! number of TGC Eta measurements missing from the track
  numberOfMmHits = 69,
  //! number of TGC Eta measurements missing from the track
  numberOfStgcEtaHoles = 70,
  //! number of TGC Phi measurements missing from the track
  numberOfStgcPhiHoles = 71,
  //! number of TGC Eta measurements missing from the track
  numberOfMmHoles = 72,
  //! number of unspoilt CSC eta measurements (all CSC phi measurements
  //! are by definition spoilt). See Muon::CscClusterStatus for
  //! definitions of 'spoiled' hits.
  numberOfCscUnspoiltEtaHits = 45,
  //! number of non-deweighted MDT hits.  Only here as
  //! a placeholder, will be filled only on xAOD::Muon
  // --- all
  numberOfGoodMdtHits = 66,
  //!< number of measurements flaged as outliers in TSOS
  numberOfOutliersOnTrack = 15,
  //!< 100 times the standard deviation of the chi2 from the surfaces
  standardDeviationOfChi2OS = 30,

  // reserved: added to keep synchronisation with xAOD::TrackSummary in
  // anticipation of the two being merged

  //!< Electron probability from combining the below
  //!< probabilities [float].
  eProbabilityComb_res = 47,
  //!< Electron probability from  High Threshold (HT) information [float].
  eProbabilityHT_res = 48,
  //!< Electron probability from Time-Over-Threshold
  //!< (ToT) information [float].
  eProbabilityToT_res = 49,
  //!< Electron probability from Brem fitting (DNA) [float].
  eProbabilityBrem_res = 50,
  //!< the dE/dx estimate, calculated using the pixel clusters [?]
  pixeldEdx_res = 51,
  //!< Electron probability from NN [float]
  eProbabilityNN_res = 73,
  //!< TRT track occupancy.
  TRTTrackOccupancy_res = 74,
  //!< dEdx from TRT ToT measurement.
  TRTdEdx_res = 75,

  // -- numbers...
  numberOfTrackSummaryTypes = 76
};
213

214
// summary types that are stored as float values
215
216
217
218
219
static const std::vector<unsigned int> floatSummaryTypes = {
  eProbabilityComb_res,  eProbabilityHT_res, eProbabilityToT_res,
  eProbabilityBrem_res,  pixeldEdx_res,      eProbabilityNN_res,
  TRTTrackOccupancy_res, TRTdEdx_res
};
220

221
// Troels.Petersen@cern.ch:
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
enum eProbabilityType
{
  eProbabilityComb =
    0, //!< Electron probability from combining the below probabilities.
  eProbabilityHT =
    1, //!< Electron probability from High Threshold (HT) information.
  eProbabilityToT =
    2, //!< Electron probability from Time-Over-Threshold (ToT) information.
  eProbabilityBrem = 3,  //!< Electron probability from Brem fitting (DNA).
  eProbabilityNN = 4,    //!< Electron probability from NN.
  TRTTrackOccupancy = 5, //!< TRT track occupancy.
  TRTdEdx = 6,           //!< dEdx from TRT ToT measurement.
  eProbabilityNumberOfTRTHitsUsedFordEdx =
    7, //!< Number of TRT hits used for dEdx measurement.
  numberOfeProbabilityTypes = 8
};
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
static const std::vector<float> eProbabilityDefault(numberOfeProbabilityTypes,
                                                    0.5);

/** enumerates the various detector types currently accessible from the isHit()
method. \todo work out how to add muons to this*/
enum DetectorType
{
  pixelBarrel0 = 0, //!< there are three or four pixel barrel layers (R1/R2)
  pixelBarrel1 = 1,
  pixelBarrel2 = 2,
  pixelBarrel3 = 3,

  pixelEndCap0 = 4, //!< three pixel discs (on each side)
  pixelEndCap1 = 5,
  pixelEndCap2 = 6,

  sctBarrel0 = 7, //!< four sct barrel layers
  sctBarrel1 = 8,
  sctBarrel2 = 9,
  sctBarrel3 = 10,

  sctEndCap0 = 11, //!< and 9 sct discs (on each side)
  sctEndCap1 = 12,
  sctEndCap2 = 13,
  sctEndCap3 = 14,
  sctEndCap4 = 15,
  sctEndCap5 = 16,
  sctEndCap6 = 17,
  sctEndCap7 = 18,
  sctEndCap8 = 19,

  trtBarrel = 20,
  trtEndCap = 21,

  DBM0 = 22,
  DBM1 = 23,
  DBM2 = 24,

  numberOfDetectorTypes = 25

}; // not complete yet
280
281
282

/**A summary of the information contained by a track.

283
284
285
If there is information missing, or if I could add useful methods then let me
know. I have deliberately tried to keep this as simple as possible, whilst
allowing for future expansion.
286

287
288
289
A recent addition is the isHit() method. This is analogous to the old 'hit
patterns' in that you can use it to check if a specific sub-detector element has
been hit by the track.
290
291
292
293

For example, you could do:
if (summary.isHit(Trk::pixelBarrel0) ) callSomething();

294
295
296
Please note that this class does NO error checking - i.e. it would be possible
for someone to fill this object in an inconsistent manner and it would not be
caught.
297
298
299
300
301
302

@author Edward.Moyse@cern.ch
*/
class TrackSummary
{
public:
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
  friend class InDet::InDetTrackSummaryHelperTool;
  friend class Muon::MuonTrackSummaryHelperTool;
  friend class Trk::TrackSummaryTool;

  /** Value set in the cxx file to -1. If any of the values returned by
  get(const SummaryType& type)==SummaryTypeNotSet then this means that the
  information has not been filled. i.e. ID information cannot be filled if the
  TrackSummaryTool does not have access to the InDetTrackSummaryHelperTool*/
  static const int SummaryTypeNotSet;

  /**needed by POOL*/
  TrackSummary();

  /**ctor should probably only be called by TrkSummaryTool.
  @param information The vector passed should be complete
  i.e. it should be the size required by m_numSummaryTypes, and any undefined
  values should be set to -1. The vector should be filled using SummaryType to
  select the position of the information.
  @param hitPattern this bitset should be filled using the DetectorType enum.
  True indicates that a sub-detector was hit*/
  TrackSummary(const std::vector<int>& information,
               const std::vector<float>& eProbability,
               std::bitset<numberOfDetectorTypes>& hitPattern,
               float dedx = -1,
               int nhitsuseddedx = -1,
               int nhitsoverflowdedx = -1);

  /** copy ctor*/
  TrackSummary(const TrackSummary& rhs);
  /** assignment operator */
  TrackSummary& operator=(const TrackSummary&);
  /** Move ctor*/
  TrackSummary(TrackSummary&& rhs) noexcept = default;
  /** Move assignment operator */
  TrackSummary& operator=(TrackSummary&&) noexcept = default;

  virtual ~TrackSummary();

  /** adds the values of the passed TrackSummary to this TrackSummary. Mainly
   intended for adding Muon and ID TrackSummaries, when making a combined Track
   for example WARNING: may not make much sense for e.g.
   Trk::numberOfContribPixelLayers*/
  TrackSummary& operator+=(const TrackSummary& ts);

  /** returns the summary information for the passed SummaryType.
  @param type Use the provided enums to access it, i.e. by
  summary.get(numberOfPixelHits)
  @return returns -1 if the enum is undefined (i.e. the information was not
  available in the Track, or (more likely) Trk::TrkTrackSummaryTool is not
  filling it yet)*/
  int get(const SummaryType& type) const;

  /** returns the probability information for the passed ProbabilityType.
  @param type Use the provided enums to access it, i.e. by
  summary.getPID(eProbabilityComb)
  @return returns -1 if the enum is undefined (i.e. the information was not
  available in the Track, or (more likely) Trk::TrkTrackSummaryTool is not
  filling it yet)*/
  // Troels.Petersen@cern.ch:
  float getPID(const eProbabilityType& PIDtype) const;

  /** returns the dE/dx estimate, calculated using the pixel clusters */
  float getPixeldEdx() const;

  int numberOfUsedHitsdEdx() const;

  int numberOfOverflowHitsdEdx() const;

  unsigned long getHitPattern() const;

  /** returns true if the detector type 'type' is hit.
  @param type Please use the DetectorType enum to access the information  (the
  internal positions may change!)
  @return true if sub-detector 'type' is hit*/
  bool isHit(const DetectorType& type) const;

  /** returns a const pointer to the InDetTrackSummary if available */
  const InDetTrackSummary* indetTrackSummary() const;

  /** returns a pointer to a modifiable (non-const)  InDetTrackSummary if
   * available */
  InDetTrackSummary* indetTrackSummary();

  /** returns a pointer to the MuonTrackSummary if available */
  const MuonTrackSummary* muonTrackSummary() const;

  /** returns  pointer to a modifiable (non-const) MuonTrackSummary if available
   */
  MuonTrackSummary* muonTrackSummary();

  /**return number of parameters currently created*/
  static unsigned int numberOfInstantiations();

  /** Update unset summary information.
   * @param type the type of the summary information to be updated.
   * @param new_value the value to be set for the given type.
   * @return false in case the information was set alread.
400
   */
401
  bool update(Trk::SummaryType type, int new_value);
402

403
private: // data members
404
405
406
407
408
  friend class ::TrackSummaryCnv_p1;
  friend class ::TrackSummaryCnv_p2;

  /** vector containing the persistent summary information. */
  std::vector<int> m_information;
409

410
411
412
  /** vector containing the persistent summary information. */
  // Troels.Petersen@cern.ch:
  std::vector<float> m_eProbability;
413

414
415
  /** contains the dE/dx information, calculated using the pixel clusters */
  float m_dedx;
416

417
  int m_nhitsdedx;
418

419
  int m_nhitsoverflowdedx;
420

421
422
  /**contains the 'hit pattern'*/
  unsigned long m_idHitPattern;
423

424
425
  /** number of objects of this type in memory */
  static std::atomic<unsigned int> s_numberOfInstantiations;
426

427
428
  /** pointer to the InDetTrackSummary */
  std::unique_ptr<InDetTrackSummary> m_indetTrackSummary;
429

430
431
  /** pointer to the MuonTrackSummary */
  std::unique_ptr<MuonTrackSummary> m_muonTrackSummary;
432
433
434
};

/**output. This dumps the values of each of the possible summary enums*/
435
436
MsgStream&
operator<<(MsgStream& out, const TrackSummary& trackSum);
437
438

/**output. This dumps the values of each of the possible summary enums*/
439
440
std::ostream&
operator<<(std::ostream& out, const TrackSummary& trackSum);
441
}
442
#include "TrkTrackSummary/TrackSummary.icc"
443

444
445
#endif