CMS 3D CMS Logo

rootio_HitPattern.cc
Go to the documentation of this file.
2 
3 /* This file contains the function used to read back v12 versions of HitPatterns from a ROOT file.
4  The function is called by a ROOT IO rule.
5  */
6 
7 using namespace reco;
8 
9 namespace {
10  constexpr unsigned short HitSize = 11;
11  constexpr unsigned short PatternSize = 50;
12  constexpr int MaxHitsV12 = (PatternSize * sizeof(uint16_t) * 8) / HitSize;
13 
14  auto getHitFromOldHitPattern(const uint16_t hitPattern[], const int position) {
15  const uint16_t bitEndOffset = (position + 1) * HitSize;
16  const uint8_t secondWord = (bitEndOffset >> 4);
17  const uint8_t secondWordBits = bitEndOffset & (16 - 1); // that is, bitEndOffset % 32
18  if (secondWordBits >= HitSize) {
19  // full block is in this word
20  const uint8_t lowBitsToTrash = secondWordBits - HitSize;
21  return (hitPattern[secondWord] >> lowBitsToTrash) & ((1 << HitSize) - 1);
22  }
23  const uint8_t firstWordBits = HitSize - secondWordBits;
24  const uint16_t firstWordBlock = hitPattern[secondWord - 1] >> (16 - firstWordBits);
25  const uint16_t secondWordBlock = hitPattern[secondWord] & ((1 << secondWordBits) - 1);
26  return firstWordBlock + (secondWordBlock << firstWordBits);
27  }
28 
29  auto hitTypeFromOldHitPattern(const uint16_t pattern) {
30  // for this version we just have to add a 0 bit to the top of the pattern
31  constexpr unsigned short HitTypeMask = 0x3;
32  constexpr unsigned short HitTypeOffset = 0;
33 
34  constexpr uint16_t VALID_CONST = (uint16_t)TrackingRecHit::valid;
35  constexpr uint16_t MISSING_CONST = (uint16_t)TrackingRecHit::missing;
36  constexpr uint16_t INACTIVE_CONST = (uint16_t)TrackingRecHit::inactive;
37  constexpr uint16_t BAD_CONST = (uint16_t)TrackingRecHit::bad;
38 
39  const uint16_t rawHitType = (pattern >> HitTypeOffset) & HitTypeMask;
40 
42  switch (rawHitType) {
43  case VALID_CONST:
44  hitType = TrackingRecHit::valid;
45  break;
46  case MISSING_CONST:
47  hitType = TrackingRecHit::missing;
48  break;
49  case INACTIVE_CONST:
50  hitType = TrackingRecHit::inactive;
51  break;
52  case BAD_CONST:
53  hitType = TrackingRecHit::bad;
54  break;
55  }
56  return hitType;
57  };
58 } // namespace
59 
61  uint8_t hitCount,
62  uint8_t beginTrackHits,
63  uint8_t endTrackHits,
64  uint8_t beginInner,
65  uint8_t endInner,
66  uint8_t beginOuter,
67  uint8_t endOuter,
68  HitPattern* newObj) {
69  newObj->clear();
70  bool ret = true;
71  for (int i = 0; i < MaxHitsV12; i++) {
72  uint16_t pattern = getHitFromOldHitPattern(oldHitPattern, i);
73  if (pattern == 0) {
74  break;
75  }
76  if (!newObj->appendHit(pattern, hitTypeFromOldHitPattern(pattern))) {
77  ret = false;
78  break;
79  }
80  }
81  newObj->hitCount = hitCount;
82  newObj->beginTrackHits = beginTrackHits;
83  newObj->endTrackHits = endTrackHits;
84  newObj->beginInner = beginInner;
85  newObj->endInner = endInner;
86  newObj->beginOuter = beginOuter;
87  newObj->endOuter = endOuter;
88  return ret;
89 }
ret
prodAgent to be discontinued
uint8_t endInner
Definition: HitPattern.h:502
bool appendHit(const TrackingRecHit &hit, const TrackerTopology &ttopo)
Definition: HitPattern.cc:224
uint8_t beginInner
Definition: HitPattern.h:501
uint8_t beginTrackHits
Definition: HitPattern.h:499
uint8_t endTrackHits
Definition: HitPattern.h:500
uint8_t hitCount
Definition: HitPattern.h:497
uint8_t beginOuter
Definition: HitPattern.h:503
static bool fillNewHitPatternWithOldHitPattern_v12(const uint16_t oldHitPattern[], uint8_t hitCount, uint8_t beginTrackHits, uint8_t endTrackHits, uint8_t beginInner, uint8_t endInner, uint8_t beginOuter, uint8_t endOuter, reco::HitPattern *newObj)
fixed size matrix
static int position[264][3]
Definition: ReadPGInfo.cc:289
uint8_t endOuter
Definition: HitPattern.h:504