EIC 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 
98 PHG4CellDefs::ScintillatorSlatBinning::genkey(const unsigned short detid, const unsigned short icolumn, const unsigned short irow)
99 {
101  return key;
102 }
103 
104 unsigned short int
106 {
107  unsigned short int rowbin = generic_lower_16bit_key(key, scintillatorslatbinning);
108  return rowbin;
109 }
110 
111 unsigned short int
113 {
114  unsigned short int columnbin = generic_upper_16bit_key(key, scintillatorslatbinning);
115  return columnbin;
116 }
118 PHG4CellDefs::EtaXsizeBinning::genkey(const unsigned short detid, const unsigned short ixbin, const unsigned short ieta)
119 {
121  return key;
122 }
123 
124 unsigned short int
126 {
127  unsigned short int etabin = generic_lower_16bit_key(key, etaxsizebinning);
128  return etabin;
129 }
130 
131 unsigned short int
133 {
134  unsigned short int etabin = generic_upper_16bit_key(key, etaxsizebinning);
135  return etabin;
136 }
137 
139 PHG4CellDefs::MVTXBinning::genkey(const unsigned short detid, const unsigned int bit32_index)
140 {
141  PHG4CellDefs::keytype key = generic_32bit_genkey(detid, mvtxbinning, bit32_index);
142  return key;
143 }
144 
145 unsigned int
147 {
148  unsigned int index = generic_32bit_key(key,mvtxbinning);
149  return index;
150 }
151 
153 PHG4CellDefs::TPCBinning::genkey(const unsigned short detid, const unsigned short mod, const unsigned short pad)
154 {
155  PHG4CellDefs::keytype key = generic_16bit_genkey(detid, tpcbinning, mod, pad);
156  return key;
157 }
158 
159 unsigned short
161 {
162  unsigned short radbin = generic_lower_16bit_key(key, tpcbinning);
163  return radbin;
164 }
165 
166 unsigned short
168 {
169  unsigned short phibin = generic_upper_16bit_key(key, tpcbinning);
170  return phibin;
171 }
172 
173 
174 
175 bool
177 {
178  keytype tmp = (key >> bitshift_binning) & 0xFFFF;
179  if (tmp == binning)
180  {
181  return true;
182  }
183  return false;
184 }
185 
186 short
188 {
189  keytype tmp = (key >> bitshift_binning) & 0xFFFF;
190  short int i = tmp;
191  return i;
192 }
193 
194 short int
196 {
197  keytype tmp = (key >> bitshift_layer);
198  return tmp;
199 }
200 
201 unsigned short
203 {
204  // check correct binning first
205  PHG4CellDefs::keytype tmp = binning;
206  tmp = (tmp << PHG4CellDefs::bitshift_binning);
207  if ((key & tmp) == tmp)
208  {
209  unsigned short int low16bitkey = (key & 0xFFFF);
210  return low16bitkey;
211  }
212  cout << PHWHERE << " could not decode 0x" << hex << key << dec << endl;
213  cout << "key 0x" << hex << key << ", binning: 0x" << tmp
214  << " and: " << (key & tmp) << dec << endl;
215  exit(1);
216 }
217 
218 unsigned short
220 {
221  // check correct binning first
222  PHG4CellDefs::keytype tmp = binning;
223  tmp = (tmp << PHG4CellDefs::bitshift_binning);
224  if ((key & tmp) == tmp)
225  {
226  PHG4CellDefs::keytype keytmp = key >> PHG4CellDefs::bitshift_upperkey;
227  unsigned short int hi16bitkey = (keytmp & 0xFFFF);
228  return hi16bitkey;
229  }
230  cout << PHWHERE << " could not decode 0x" << hex << key << dec << endl;
231  exit(1);
232 }
233 
234 unsigned int
236 {
237  // check correct binning first
238  PHG4CellDefs::keytype tmp = binning;
239  tmp = (tmp << PHG4CellDefs::bitshift_binning);
240  if ((key & tmp) == tmp)
241  {
242  unsigned int bit32key = (key & 0xFFFFFFFF);
243  return bit32key;
244  }
245  cout << PHWHERE << " could not decode 0x" << hex << key << dec << endl;
246  exit(1);
247 }
248 
249 
251 generic_16bit_genkey(const unsigned short detid, const PHG4CellDefs::CellBinning binning, const unsigned short upper16bits, const unsigned short lower16bits)
252 {
253  PHG4CellDefs::keytype tmp = detid;
254  PHG4CellDefs::keytype key = tmp << PHG4CellDefs::bitshift_layer; // layer/detector id used by extrating ranges
255  tmp = binning;
256  key |= (tmp << PHG4CellDefs::bitshift_binning); // binning method used to decode the key
257  tmp = upper16bits;
258  key |= (tmp << PHG4CellDefs::bitshift_upperkey); // upper bits used by column, so we can easily extract
259  // slats by column which are combined to towers
260  key |= lower16bits;
261  return key;
262 }
263 
265 generic_32bit_genkey(const unsigned short detid, const PHG4CellDefs::CellBinning binning, const unsigned int bit32)
266 {
267  PHG4CellDefs::keytype tmp = detid;
268  PHG4CellDefs::keytype key = tmp << PHG4CellDefs::bitshift_layer; // layer/detector id used by extrating ranges
269  tmp = binning;
270  key |= (tmp << PHG4CellDefs::bitshift_binning); // binning method used to decode the key
271  key |= bit32;
272  return key;
273 }
274