Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MvtxDefs.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MvtxDefs.cc
1 #include "MvtxDefs.h"
2 
3 uint8_t
5 {
6  TrkrDefs::hitsetkey tmp = (key >> MvtxDefs::kBitShiftStaveIdOffset);
7  // zero the bits not in the stave id field
8  uint8_t tmp1 = tmp;
9  tmp1 = (tmp1 << (8 - MvtxDefs::kBitShiftStaveIdWidth));
10  tmp1 = (tmp1 >> (8 - MvtxDefs::kBitShiftStaveIdWidth));
11  return tmp1;
12 }
13 
14 uint8_t
16 {
17  TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
18  return getStaveId(tmp);
19 }
20 
21 uint8_t
23 {
24  TrkrDefs::hitsetkey tmp = (key >> MvtxDefs::kBitShiftChipIdOffset);
25  uint8_t tmp1 = tmp;
26  tmp1 = (tmp1 << (8 - MvtxDefs::kBitShiftChipIdWidth));
27  tmp1 = (tmp1 >> (8 - MvtxDefs::kBitShiftChipIdWidth));
28  return tmp1;
29 }
30 
31 uint8_t
33 {
34  TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
35  return getChipId(tmp);
36 }
37 
38 int
40 {
41  TrkrDefs::hitsetkey tmp = (key >> MvtxDefs::kBitShiftStrobeIdOffset);
42  uint8_t tmp1 = tmp;
43  tmp1 = (tmp1 << (8 - MvtxDefs::kBitShiftStrobeIdWidth));
44  tmp1 = (tmp1 >> (8 - MvtxDefs::kBitShiftStrobeIdWidth));
45 
46  int tmp2 = (int) tmp1 - strobeOffset; // get back to the signed strobe
47 
48  return tmp2;
49 }
50 
51 int
53 {
54  TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
55  return getStrobeId(tmp);
56 }
57 
58 uint16_t
60 {
61  TrkrDefs::hitkey tmp = (key >> MvtxDefs::kBitShiftCol);
62  return tmp;
63 }
64 
65 uint16_t
67 {
68  TrkrDefs::hitkey tmp = (key >> MvtxDefs::kBitShiftRow);
69  return tmp;
70 }
71 
73 MvtxDefs::genHitKey(const uint16_t col, const uint16_t row)
74 {
75  TrkrDefs::hitkey key = (col << MvtxDefs::kBitShiftCol);
76  TrkrDefs::hitkey tmp = (row << MvtxDefs::kBitShiftRow);
77  key |= tmp;
78  return key;
79 }
80 
82 MvtxDefs::genHitSetKey(const uint8_t lyr, const uint8_t stave, const uint8_t chip, const int strobe_in)
83 {
85 
86  // offset strobe to make it positive, fit inside 5 bits
87  int strobe = strobe_in + strobeOffset;
88  if(strobe < 0) strobe = 0;
89  if(strobe > 31) strobe = 31;
90  unsigned int ustrobe = (unsigned int) strobe;
91 
92  TrkrDefs::hitsetkey tmp = stave;
93  key |= (tmp << MvtxDefs::kBitShiftStaveIdOffset);
94  tmp = chip;
95  key |= (tmp << MvtxDefs::kBitShiftChipIdOffset);
96  tmp = ustrobe;
97  key |= (tmp << MvtxDefs::kBitShiftStrobeIdOffset);
98  return key;
99 }
100 
102 MvtxDefs::genClusKey(const uint8_t lyr, const uint8_t stave, const uint8_t chip, const int strobe, const uint32_t clusid)
103 {
104  TrkrDefs::hitsetkey key = genHitSetKey(lyr, stave, chip, strobe);
105  //return TrkrDefs::genClusKey( key, clusid );
106  return TrkrDefs::genClusKey(key,clusid);
107 }
108 
111 {
112  // Note: this method uses the fact that the crossing is in the first 5 bits
114  // zero the crossing bits by shifting them out of the word, then shift back
115  tmp = (tmp >> MvtxDefs::kBitShiftStrobeIdWidth);
116  tmp = (tmp << MvtxDefs::kBitShiftStrobeIdWidth);
117  unsigned int zero_strobe = strobeOffset;
118  tmp |= (zero_strobe << MvtxDefs::kBitShiftStrobeIdOffset);
119 
120  return tmp;
121 }