10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wunused-function"
13 {62, 60, 46, 44, 30, 28, 14, 12},
14 {63, 61, 47, 45, 31, 29, 15, 13},
15 {58, 56, 42, 40, 26, 24, 10, 8},
16 {59, 57, 43, 41, 27, 25, 11, 9},
17 {54, 52, 38, 36, 22, 20, 6, 4},
18 {55, 53, 39, 37, 23, 21, 7, 5},
19 {50, 48, 34, 32, 18, 16, 2, 0},
20 {51, 49, 35, 33, 19, 17, 3, 1}};
49 static const int epd_phimap[31] = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
50 static const int epd_rmap[31] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15};
54 static int phimap[64];
55 static int etamap[64];
56 static int etabinoffset[4];
57 static int ifirst = 1;
60 for (
int j = 0;
j < 8;
j++)
62 for (
int k = 0;
k < 8;
k++)
65 phimap[emcadc[
j][
k]] =
k;
74 const int channels_per_sector = 64;
75 const int supersector = 64 * 12;
76 const int nchannelsperpacket = 64 * 3;
77 const int maxphibin = 7;
78 const int maxetabin = 23;
79 int supersectornumber = towerIndex / supersector;
80 int packet = (towerIndex % supersector) / nchannelsperpacket;
81 if (packet < 0 || packet > 3)
83 std::cout <<
"Attempting to access channel with invalid value in EMCal " << packet << std::endl;
86 int interfaceboard = ((towerIndex % supersector) % nchannelsperpacket) / channels_per_sector;
87 int interfaceboard_channel = ((towerIndex % supersector) % nchannelsperpacket) % channels_per_sector;
88 int localphibin = phimap[interfaceboard_channel];
89 if (packet == 0 || packet == 1)
91 localphibin = maxphibin - localphibin;
93 int localetabin = etamap[interfaceboard_channel];
94 int packet_etabin = localetabin + 8 * interfaceboard;
95 if (packet == 0 || packet == 1)
97 packet_etabin = maxetabin - packet_etabin;
99 unsigned int globaletabin = packet_etabin + etabinoffset[packet];
100 unsigned int globalphibin = localphibin + supersectornumber * 8;
101 unsigned int key = globalphibin + (globaletabin << 16U);
107 unsigned int key = phibin + (etabin << 16U);
113 const int etabinoffset[4] = {24, 0, 48, 72};
114 const int etabinmap[4] = {1, 0, 2, 3};
115 const int channels_per_sector = 64;
116 const int supersector = 64 * 12;
117 const int nchannelsperpacket = 64 * 3;
118 const int maxphibin = 7;
119 const int maxetabin = 23;
121 unsigned int etabin = tower_key >> 16U;
122 unsigned int phibin = tower_key - (etabin << 16U);
123 int packet = etabinmap[(int) etabin / 24];
124 int localetabin = etabin - etabinoffset[packet];
125 int localphibin = phibin % 8;
126 int supersectornumber = phibin / 8;
128 if (packet == 0 || packet == 1)
130 localetabin = maxetabin - localetabin;
132 ib = localetabin / 8;
133 unsigned int index = 0;
134 if (packet == 0 || packet == 1)
136 localphibin = maxphibin - localphibin;
138 localetabin = localetabin % 8;
139 unsigned int localindex =
emcadc[localetabin][localphibin];
140 index = localindex + channels_per_sector * ib + packet * nchannelsperpacket + supersector * supersectornumber;
146 static int phimap[64];
147 static int etamap[64];
148 static int etabinoffset[4];
149 static int phibinoffset[4];
150 static int ifirst = 1;
153 for (
int j = 0;
j < 8;
j++)
155 for (
int k = 0;
k < 2;
k++)
158 phimap[hcaladc[
j][
k]] =
k;
163 etabinoffset[2] = 16;
173 const int channels_per_sector = 16;
174 const int supersector = 16 * 4 * 3;
175 const int nchannelsperpacket = channels_per_sector * 4;
178 int supersectornumber = towerIndex / supersector;
179 int packet = (towerIndex % supersector) / nchannelsperpacket;
180 if (packet < 0 || packet > 3)
182 std::cout <<
"Attempting to access channel with invalid value ih HCAL " << packet << std::endl;
185 int interfaceboard = ((towerIndex % supersector) % nchannelsperpacket) / channels_per_sector;
186 int interfaceboard_channel = ((towerIndex % supersector) % nchannelsperpacket) % channels_per_sector;
187 int localphibin = phimap[interfaceboard_channel] + phibinoffset[interfaceboard];
188 int localetabin = etamap[interfaceboard_channel];
189 int packet_etabin = localetabin;
190 unsigned int globaletabin = packet_etabin + etabinoffset[packet];
191 unsigned int globalphibin = localphibin + supersectornumber * 8;
192 unsigned int key = globalphibin + (globaletabin << 16U);
199 unsigned int key = phibin + (etabin << 16U);
205 int channels_per_sector = 16;
206 int supersector = 16 * 4 * 3;
207 int nchannelsperpacket = channels_per_sector * 4;
208 int etabinoffset[3] = {0, 8, 16};
209 int phibinoffset[4] = {0, 2, 4, 6};
210 unsigned int etabin = tower_key >> 16U;
211 unsigned int phibin = tower_key - (etabin << 16U);
212 int packet = etabin / 8;
213 int localetabin = etabin - etabinoffset[packet];
214 int localphibin = phibin % 8;
215 int supersectornumber = phibin / 8;
216 int ib = localphibin / 2;
217 unsigned int index = 0;
218 localphibin = localphibin - phibinoffset[
ib];
219 unsigned int localindex =
hcaladc[localetabin][localphibin];
220 index = localindex + channels_per_sector * ib + packet * nchannelsperpacket + supersector * supersectornumber;
227 unsigned int etabin = key >> 16U;
228 unsigned int phibin = key - (etabin << 16U);
235 unsigned int etabin = key >> 16U;
241 int channels_per_sector = 31;
242 int supersector = channels_per_sector * 12;
243 unsigned int supersectornumber = towerIndex / supersector;
244 int sector = ((towerIndex % supersector)) / channels_per_sector;
245 int channel = ((towerIndex % supersector)) % channels_per_sector;
246 unsigned int key = channel + (sector << 5U) + (supersectornumber << 9U);
253 if (rbin == 0 && phibin > 11)
255 std::cout << __PRETTY_FUNCTION__ <<
" encode_epd invalid phibin value: " << phibin <<
" where max valid phibin is 11" << std::endl;
259 unsigned int sector = phibin / 2;
268 channel =
epdchnlmap[rbin][phibin - 2 * sector];
271 unsigned int key = channel + (sector << 5U) + (arm << 9U);
277 int channels_per_sector = 31;
278 int supersector = channels_per_sector * 12;
279 unsigned int ns_sector = tower_key >> 9U;
280 unsigned int sector = (tower_key - (ns_sector << 9U)) >> 5U;
281 unsigned int channel = tower_key - (ns_sector << 9U) - (sector << 5U);
282 unsigned int index = ns_sector * supersector + sector * channels_per_sector +
channel;
289 unsigned int arm = key >> 9U;
296 unsigned int sector = (key - (arm << 9U)) >> 5U;
304 unsigned int channel = key - (sector << 5U) - (arm << 9U);
314 unsigned int channel = key - (sector << 5U) - (arm << 9U);
328 std::cout <<
"Attempting to access zdc channel with invalid number " << towerIndex << std::endl;
331 unsigned int key = towerIndex;
364 std::cout <<
"Attempting to access smd channel with invalid number " << towerIndex << std::endl;
367 unsigned int Xpos[2] = {0, 6};
368 unsigned int Ypos[2] = {7, 14};
369 unsigned int Xneg[2] = {15, 23};
370 unsigned int Yneg[2] = {22, 29};
371 unsigned int xyBit = 0;
372 unsigned int fingerIndex = UINT_MAX;
373 unsigned int sideBit = 0;
374 if (towerIndex >= Xpos[0] && towerIndex <= Xpos[1])
377 fingerIndex = towerIndex - Xpos[0];
380 if (towerIndex >= Ypos[0] && towerIndex <= Ypos[1])
383 fingerIndex = towerIndex - Ypos[0];
386 if (towerIndex >= Xneg[0] && towerIndex <= Xneg[1])
389 fingerIndex = towerIndex - Xneg[0];
392 if (towerIndex >= Yneg[0] && towerIndex <= Yneg[1])
395 fingerIndex = towerIndex - Yneg[0];
398 unsigned int key = (sideBit << 4) + (xyBit << 3) + fingerIndex;
405 unsigned int index = 999;
406 for (
unsigned int i = 0;
i < 30;
i++)
420 unsigned int index = 999;
421 for (
unsigned int i = 0;
i < 16;
i++)
435 if (key & 8)
return 1;
442 if (key & (1 << 4))
return 1;
448 if (key & (1 << 3))
return 0;
460 unsigned int arm = pmtIndex / 128;
461 unsigned int type = (pmtIndex % 16) / 8;
462 unsigned int channel = (pmtIndex % 8) + ((pmtIndex / 16) * 8);
463 if (channel > 63) channel -= 64;
465 unsigned int key = (arm << 7) | (type << 6) |
channel;
472 unsigned int arm = (key >> 7) & 0x1;
473 unsigned int type = (key >> 6) & 0x1;
474 unsigned int channel = key & 0x3f;
476 unsigned int index = (arm * 128) + (type * 8) + (channel % 8) + (channel / 8) * 16;
483 return (key >> 7) & 0x1;
493 return (key >> 6) & 0x1;
531 #pragma GCC diagnostic pop