Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrDefs.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrDefs.cc
1 #include "TrkrDefs.h"
2 
3 #include <bitset>
4 
5 
6 void TrkrDefs::printBits(const TrkrDefs::hitsetkey key, std::ostream& os)
7 {
8  os << "key: " << std::bitset<32>(key) << std::endl;
9 }
10 
11 void TrkrDefs::printBits(const TrkrDefs::cluskey key, std::ostream& os)
12 {
13  os << "key: " << std::bitset<64>(key) << std::endl;
14 }
15 
16 uint8_t
18 {
19  TrkrDefs::hitsetkey tmp = (key >> kBitShiftTrkrId);
20  return tmp;
21 }
22 
23 uint8_t
25 {
26  TrkrDefs::hitsetkey tmp = (key >> kBitShiftClusId);
27  return getTrkrId(tmp);
28 }
29 
30 uint8_t
32 {
33  TrkrDefs::hitsetkey tmp = (key >> kBitShiftLayer);
34  return tmp;
35 }
36 
37 uint8_t
39 {
40  TrkrDefs::hitsetkey tmp = (key >> kBitShiftClusId);
41  return getLayer(tmp);
42 }
43 
44 uint32_t
46 {
47  return key;
48 }
49 
50 uint32_t
52 {
53  return (key >> kBitShiftClusId);
54 }
55 
58 {
59  return genHitSetKey(trkrId, 0);
60 }
61 
64 {
65  return genHitSetKey(static_cast<TrkrDefs::TrkrId>(trkrId + 1), 0) - 1;
66 }
67 
69 TrkrDefs::getHitSetKeyLo(const TrkrDefs::TrkrId trkrId, const uint8_t lyr)
70 {
71  return genHitSetKey(trkrId, lyr);
72 }
73 
75 TrkrDefs::getHitSetKeyHi(const TrkrDefs::TrkrId trkrId, const uint8_t lyr)
76 {
77  return genHitSetKey(trkrId, lyr + 1) - 1;
78 }
79 
82 {
83  const TrkrDefs::cluskey tmp = genHitSetKey(trkrId, 0);
84  return (tmp << kBitShiftClusId);
85 }
86 
89 {
90  const TrkrDefs::cluskey tmp = genHitSetKey(static_cast<TrkrDefs::TrkrId>(trkrId + 1), 0);
91  return (tmp << kBitShiftClusId) - 1;
92 }
93 
95 TrkrDefs::getClusKeyLo(const TrkrDefs::TrkrId trkrId, const uint8_t lyr)
96 {
97  const TrkrDefs::cluskey tmp = genHitSetKey(trkrId, lyr);
98  return (tmp << kBitShiftClusId);
99 }
100 
102 TrkrDefs::getClusKeyHi(const TrkrDefs::TrkrId trkrId, const uint8_t lyr)
103 {
104  const TrkrDefs::cluskey tmp = genHitSetKey(trkrId, lyr + 1);
105  return (tmp << kBitShiftClusId) - 1;
106 }
107 
109 TrkrDefs::genHitSetKey(const TrkrDefs::TrkrId trkrId, const uint8_t lyr)
110 {
111  TrkrDefs::hitsetkey tmp = trkrId;
112  TrkrDefs::hitsetkey key = tmp << kBitShiftTrkrId; // detector id
113  tmp = lyr;
114  key |= (tmp << kBitShiftLayer); // layer
115  return key;
116 }
117 
119 TrkrDefs::genClusKey(const TrkrDefs::hitsetkey hskey, const uint32_t clusid)
120 {
121  const TrkrDefs::cluskey tmp = hskey;
122  TrkrDefs::cluskey key = (tmp << TrkrDefs::kBitShiftClusId);
123  key |= clusid;
124  return key;
125 }
126 
128 {
129  const TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftPhiElement);
130  return tmp;
131 }
132 
133 
134 
136 {
137  const TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftZElement);
138  return tmp;
139 }
140 
142 {
143  const TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
144  return getPhiElement(tmp);
145 }
146 
148 {
149  const TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
150  return getZElement(tmp);
151 }