Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InttDefs.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file InttDefs.cc
1 
7 #include "InttDefs.h"
8 
9 uint8_t
11 {
12  TrkrDefs::hitsetkey tmp = (key >> InttDefs::kBitShiftLadderZIdOffset);
13  // clear the bits not associated with the ladderZId
14  uint8_t tmp1 = tmp;
15  tmp1 = (tmp1 << (8 - InttDefs::kBitShiftLadderZIdWidth));
16  tmp1 = (tmp1 >> (8 - InttDefs::kBitShiftLadderZIdWidth));
17  return tmp1;
18 }
19 
20 uint8_t
22 {
23  TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
24  return getLadderZId(tmp);
25 }
26 
27 uint8_t
29 {
30  TrkrDefs::hitsetkey tmp = (key >> InttDefs::kBitShiftLadderPhiIdOffset);
31  // clear the bits not associated with the ladderPhiId
32  uint8_t tmp1 = tmp;
33  tmp1 = (tmp1 << (8 - InttDefs::kBitShiftLadderPhiIdWidth));
34  tmp1 = (tmp1 >> (8 - InttDefs::kBitShiftLadderPhiIdWidth));
35  return tmp1;
36 }
37 
38 uint8_t
40 {
41  TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
42  return getLadderPhiId(tmp);
43 }
44 
45 int
47 {
48  TrkrDefs::hitsetkey tmp = (key >> InttDefs::kBitShiftTimeBucketIdOffset);
49  // clear the bits not associated with the TimeBucketId
50  uint16_t tmp1 = tmp;
51  tmp1 = (tmp1 << (16 - InttDefs::kBitShiftTimeBucketIdWidth));
52  tmp1 = (tmp1 >> (16 - InttDefs::kBitShiftTimeBucketIdWidth));
53 
54  int tmp2 = (int) tmp1 - crossingOffset; // get back to signed crossing
55 
56  return tmp2;
57 }
58 
59 int
61 {
62  TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
63  return getTimeBucketId(tmp);
64 }
65 
66 uint16_t
68 {
69  TrkrDefs::hitkey tmp = (key >> InttDefs::kBitShiftCol);
70  return tmp;
71 }
72 
73 uint16_t
75 {
76  TrkrDefs::hitkey tmp = (key >> InttDefs::kBitShiftRow);
77  return tmp;
78 }
79 
81 InttDefs::genHitKey(const uint16_t col, const uint16_t row)
82 {
83  TrkrDefs::hitkey key = (col << InttDefs::kBitShiftCol);
84  TrkrDefs::hitkey tmp = (row << InttDefs::kBitShiftRow);
85  key |= tmp;
86  return key;
87 }
88 
90 InttDefs::genHitSetKey(const uint8_t lyr, const uint8_t ladder_z_index, uint8_t ladder_phi_index, const int crossing_in)
91 {
93 
94  // offset crossing to make it positive, fit inside 10 bits
95  int crossing = crossing_in + crossingOffset;
96  if(crossing < 0) crossing = 0;
97  if(crossing > 1023) crossing = 1023;
98  unsigned int ucrossing = (unsigned int) crossing;
99 
100  TrkrDefs::hitsetkey tmp = ladder_z_index;
101  key |= (tmp << InttDefs::kBitShiftLadderZIdOffset);
102  tmp = ladder_phi_index;
103  key |= (tmp << InttDefs::kBitShiftLadderPhiIdOffset);
104  tmp = ucrossing;
105  key |= (tmp << InttDefs::kBitShiftTimeBucketIdOffset);
106 
107  return key;
108 }
109 
111 InttDefs::genClusKey(const uint8_t lyr, const uint8_t ladder_z_index, const uint8_t ladder_phi_index, const int crossing, const uint32_t clusid)
112 {
113  TrkrDefs::cluskey key = genHitSetKey(lyr, ladder_z_index, ladder_phi_index, crossing);
114  return TrkrDefs::genClusKey( key, clusid );
115 }
116 
119 {
120  // Note: this method uses the fact that the crossing is in the first 10 bits
122  // zero the crossing bits by shifting them out of the word, then shift back
123  tmp = (tmp >> InttDefs::kBitShiftTimeBucketIdWidth);
124  tmp = (tmp << InttDefs::kBitShiftTimeBucketIdWidth);
125  unsigned int zero_crossing = crossingOffset;
126  tmp |= (zero_crossing << InttDefs::kBitShiftTimeBucketIdOffset);
127 
128  return tmp;
129 }