5 #ifndef __STRAW_MAP_H__
6 #define __STRAW_MAP_H__
76 int ec_chip(
int side,
int phi,
int layerNumber,
int strawLayerNumber,
int strawNumber);
99 assert( std::abs(
side)==1 || std::abs(
side)==2 );
100 assert(
phi>=0 &&
phi<32 );
111 assert( std::abs(
side)==1 || std::abs(
side)==2 );
112 assert(
phi>=0 &&
phi<32 );
124 assert( std::abs(
m_side)==2 );
125 int layerNumber = this->
layer();
130 chip += 12 * ( this->
TTCgroup() - 9 );
140 assert(std::abs(
m_side)==2);
145 int asdblr = (strawNumber%4 - strawNumber%2) / 2;
146 if (!(asdblr==0||asdblr==1)) printf(
"ASDBLR error: %d\n", asdblr);
147 if (strawLayerNumber%8 >= 4) asdblr = 1 - asdblr;
148 if (
m_side<0) asdblr = 1 - asdblr;
155 if (std::abs(
m_side)==1) {
168 const int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
171 int chip = this->
DTMROC();
173 for (
int i=0;
i<9;
i++) {
175 if (chip <
count)
return i;
181 }
else if (std::abs(
m_side)==2) {
198 assert( std::abs(
m_side)==2 );
199 auto asdblr = this->
ASDBLR();
201 throw std::runtime_error(
"asdblr is less than zero");
203 return ( (this->
DTMROC()) * 2 + (asdblr) );
208 printf(
"strawMap::initialize - initialize table containters\n");
209 static int count_initialize(0); count_initialize++;
210 if (count_initialize>2) {
211 printf(
"strawMap::initialize - if you are seeing a lot of this messages, \n");
212 printf(
" create one dummy instance of strawMap class that lives \n");
213 printf(
" from start till the end of your programm. \n");
216 int table_length = 1642;
220 for (
int i=0;
i<table_length;
i++) {
232 for (
int i=0;
i<table_length;
i++) {
243 printf(
"TRT_StrawMap::initialize() ERROR: failed to open the mapping file %s \n",
filename);
244 printf(
"TRT_StrawMap::initialize() ERROR: you need to fix the file name / link, WILL CRASH THE CODE NOW\n");
269 printf(
"strawMap::clean_up - delete all tables\n\n");
286 const int numberOfStraws[74] = { 0, 15, 31, 47, 63, 79, 96, 113, 130, 147, 164, 182, 200, 218, 236, 254, 273, 292, 311, 329,
287 348, 368, 388, 408, 428, 448, 469, 490, 511, 532, 553, 575, 597, 619, 641, 663, 686, 709, 732, 755, 778, 802, 826, 849,
288 872, 896, 920, 944, 968, 993, 1018, 1043, 1068, 1093, 1119, 1145, 1171, 1197, 1223, 1250, 1277, 1304, 1331, 1358, 1386, 1414, 1442, 1470, 1498, 1527, 1556, 1585, 1614, 1642 };
290 if (LayerNumber==1) strawlayerNumber+= 19;
291 else if (LayerNumber==2) strawlayerNumber+= 43;
293 return ( numberOfStraws[strawlayerNumber+1] - strawNumber -1 );
298 int board = layerNumber;
299 if (board<6) { board *= 2;
if (strawLayerNumber>7) board++; }
302 int straw = board * 192 + strawNumber * 8 + strawLayerNumber % 8 ;
310 assert( std::abs(
side)==2 );
312 static int count = 0;
313 static int *map_A0 =
new int[12];
314 static int *map_A8 =
new int[12];
315 static int *map_C0 =
new int[12];
316 static int *map_C8 =
new int[12];
319 int chipIndexToChipHardware_A0[] = {2, 1, 3, 0, 6, 5, 7, 4, 10, 9, 11, 8};
320 int chipIndexToChipHardware_A8[] = {8, 11, 9, 10, 4, 7, 5, 6, 0, 3, 1, 2};
321 int chipIndexToChipHardware_C0[] = {1, 2, 0, 3, 5, 6, 4, 7, 9, 10, 8, 11};
322 int chipIndexToChipHardware_C8[] = {11, 8, 10, 9, 7, 4, 6, 5, 3, 0, 2, 1};
323 int *map_list[] = {map_A0, map_A8, map_C0, map_C8};
324 int *chip_list[] = {chipIndexToChipHardware_A0, chipIndexToChipHardware_A8, chipIndexToChipHardware_C0, chipIndexToChipHardware_C8};
325 for (
int i=0;
i<4;
i++)
for (
int j=0; j<12; j++) map_list[
i][j] = chip_list[
i][j];
328 int chip = (strawNumber - strawNumber%4) / 2;
329 if (strawLayerNumber%8 >= 4) chip++;
331 int nominal_reversed = 1 - ( (
phi -
phi%8)/8 ) %2 ;
333 if (
side==2) map = nominal_reversed ? map_A8 : map_A0;
334 if (
side==-2) map = nominal_reversed ? map_C8 : map_C0;
336 throw std::runtime_error(
"map pointer is null in TRT_StrawMap.h");
342 #endif // __STRAW_MAP_H__