Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CellDefs.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CellDefs.cc
1 #include "PHG4CellDefs.h"
2 
3 #include <phool/phool.h>
4 
5 #include <cstdlib> // for exit
6 #include <iostream>
7 
8 using namespace std;
9 
10 unsigned short
12 
13 unsigned short
15 
16 unsigned int
18 
20 generic_16bit_genkey(const unsigned short detid, const PHG4CellDefs::CellBinning binning, const unsigned short upper16bits, const unsigned short lower16bits);
21 
23 generic_32bit_genkey(const unsigned short detid, const PHG4CellDefs::CellBinning binning, const unsigned int bit32);
24 
26 PHG4CellDefs::SizeBinning::genkey(const unsigned short detid, const unsigned short zbin, const unsigned short iphi)
27 {
28  PHG4CellDefs::keytype key = generic_16bit_genkey(detid, sizebinning, zbin, iphi);
29  return key;
30 }
31 
32 unsigned short int
34 {
35  unsigned short int phibin = generic_lower_16bit_key(key, sizebinning);
36  return phibin;
37 }
38 
39 unsigned short int
41 {
42  unsigned short int zbin = generic_upper_16bit_key(key, sizebinning);
43  return zbin;
44 }
45 
47 PHG4CellDefs::EtaPhiBinning::genkey(const unsigned short detid, const unsigned short iphi, const unsigned short ieta)
48 {
50  return key;
51 }
52 
53 unsigned short int
55 {
56  unsigned short int etabin = generic_lower_16bit_key(key, etaphibinning);
57  return etabin;
58 }
59 
60 unsigned short int
62 {
63  unsigned short int phibin = generic_upper_16bit_key(key, etaphibinning);
64  return phibin;
65 }
66 
68 PHG4CellDefs::SpacalBinning::genkey(const unsigned short etabin, const unsigned short phibin, const unsigned short fiberid)
69 {
70  PHG4CellDefs::keytype key = generic_16bit_genkey(etabin, spacalbinning, phibin, fiberid);
71  return key;
72 }
73 
74 unsigned short int
76 {
77  unsigned long long tmp = key >> 48;
78  unsigned short int etabin = tmp;
79  return etabin;
80 }
81 
82 unsigned short int
84 {
85  unsigned short int phibin = generic_upper_16bit_key(key, spacalbinning);
86  return phibin;
87 }
88 
89 unsigned short int
91 {
92  unsigned short int fiberid = generic_lower_16bit_key(key, spacalbinning);
93  return fiberid;
94 }
95 
96 // yes the arguments are flipped but it is consistent later on
97 // changing this would just be a real headache
98 // cppcheck-suppress funcArgOrderDifferent
99 PHG4CellDefs::keytype PHG4CellDefs::ScintillatorSlatBinning::genkey(const unsigned short detid, const unsigned short icolumn, const unsigned short irow)
100 {
102  return key;
103 }
104 
105 unsigned short int
107 {
108  unsigned short int rowbin = generic_lower_16bit_key(key, scintillatorslatbinning);
109  return rowbin;
110 }
111 
112 unsigned short int
114 {
115  unsigned short int columnbin = generic_upper_16bit_key(key, scintillatorslatbinning);
116  return columnbin;
117 }
119 PHG4CellDefs::EtaXsizeBinning::genkey(const unsigned short detid, const unsigned short ixbin, const unsigned short ieta)
120 {
122  return key;
123 }
124 
125 unsigned short int
127 {
128  unsigned short int etabin = generic_lower_16bit_key(key, etaxsizebinning);
129  return etabin;
130 }
131 
132 unsigned short int
134 {
135  unsigned short int etabin = generic_upper_16bit_key(key, etaxsizebinning);
136  return etabin;
137 }
138 
140 PHG4CellDefs::MVTXBinning::genkey(const unsigned short detid, const unsigned int bit32_index)
141 {
142  PHG4CellDefs::keytype key = generic_32bit_genkey(detid, mvtxbinning, bit32_index);
143  return key;
144 }
145 
146 unsigned int
148 {
149  unsigned int index = generic_32bit_key(key, mvtxbinning);
150  return index;
151 }
152 
154 PHG4CellDefs::TPCBinning::genkey(const unsigned short detid, const unsigned short mod, const unsigned short pad)
155 {
156  PHG4CellDefs::keytype key = generic_16bit_genkey(detid, tpcbinning, mod, pad);
157  return key;
158 }
159 
160 unsigned short
162 {
163  unsigned short radbin = generic_lower_16bit_key(key, tpcbinning);
164  return radbin;
165 }
166 
167 unsigned short
169 {
170  unsigned short phibin = generic_upper_16bit_key(key, tpcbinning);
171  return phibin;
172 }
173 
175 {
176  keytype tmp = (key >> bitshift_binning) & 0xFFFF;
177  if (tmp == binning)
178  {
179  return true;
180  }
181  return false;
182 }
183 
185 {
186  keytype tmp = (key >> bitshift_binning) & 0xFFFF;
187  short int i = tmp;
188  return i;
189 }
190 
191 short int
193 {
194  keytype tmp = (key >> bitshift_layer);
195  return tmp;
196 }
197 
198 unsigned short
200 {
201  // check correct binning first
202  PHG4CellDefs::keytype tmp = binning;
203  tmp = (tmp << PHG4CellDefs::bitshift_binning);
204  if ((key & tmp) == tmp)
205  {
206  unsigned short int low16bitkey = (key & 0xFFFF);
207  return low16bitkey;
208  }
209  cout << PHWHERE << " could not decode 0x" << hex << key << dec << endl;
210  cout << "key 0x" << hex << key << ", binning: 0x" << tmp
211  << " and: " << (key & tmp) << dec << endl;
212  exit(1);
213 }
214 
215 unsigned short
217 {
218  // check correct binning first
219  PHG4CellDefs::keytype tmp = binning;
220  tmp = (tmp << PHG4CellDefs::bitshift_binning);
221  if ((key & tmp) == tmp)
222  {
223  PHG4CellDefs::keytype keytmp = key >> PHG4CellDefs::bitshift_upperkey;
224  unsigned short int hi16bitkey = (keytmp & 0xFFFF);
225  return hi16bitkey;
226  }
227  cout << PHWHERE << " could not decode 0x" << hex << key << dec << endl;
228  exit(1);
229 }
230 
231 unsigned int
233 {
234  // check correct binning first
235  PHG4CellDefs::keytype tmp = binning;
236  tmp = (tmp << PHG4CellDefs::bitshift_binning);
237  if ((key & tmp) == tmp)
238  {
239  unsigned int bit32key = (key & 0xFFFFFFFF);
240  return bit32key;
241  }
242  cout << PHWHERE << " could not decode 0x" << hex << key << dec << endl;
243  exit(1);
244 }
245 
247 generic_16bit_genkey(const unsigned short detid, const PHG4CellDefs::CellBinning binning, const unsigned short upper16bits, const unsigned short lower16bits)
248 {
249  PHG4CellDefs::keytype tmp = detid;
250  PHG4CellDefs::keytype key = tmp << PHG4CellDefs::bitshift_layer; // layer/detector id used by extrating ranges
251  tmp = binning;
252  key |= (tmp << PHG4CellDefs::bitshift_binning); // binning method used to decode the key
253  tmp = upper16bits;
254  key |= (tmp << PHG4CellDefs::bitshift_upperkey); // upper bits used by column, so we can easily extract
255  // slats by column which are combined to towers
256  key |= lower16bits;
257  return key;
258 }
259 
261 generic_32bit_genkey(const unsigned short detid, const PHG4CellDefs::CellBinning binning, const unsigned int bit32)
262 {
263  PHG4CellDefs::keytype tmp = detid;
264  PHG4CellDefs::keytype key = tmp << PHG4CellDefs::bitshift_layer; // layer/detector id used by extrating ranges
265  tmp = binning;
266  key |= (tmp << PHG4CellDefs::bitshift_binning); // binning method used to decode the key
267  key |= bit32;
268  return key;
269 }