ATLAS Offline Software
Loading...
Searching...
No Matches
strawMap Class Reference

#include <TRT_StrawMap.h>

Collaboration diagram for strawMap:

Public Member Functions

 strawMap (int side, int phi, int straw)
 strawMap (int side, int phi, int layer, int strawLayer, int strawWithinStrawLayer)
 ~strawMap ()
int side () const
int phi () const
int straw () const
int layer () const
int strawLayer () const
int strawWithinLayer () const
int DTMROC ()
int ASDBLR ()
int TTCgroup ()
int HVpad ()

Private Member Functions

void initialize ()
void clean_up ()
int barrelStrawNumber (int strawNumber, int strawlayerNumber, int LayerNumber)
int endcapStrawNumber (int strawNumber, int strawLayerNumber, int layerNumber)
int ec_chip (int side, int phi, int layerNumber, int strawLayerNumber, int strawNumber)

Private Attributes

int m_side
int m_phi
int m_straw

Static Private Attributes

static int * m_strawToDTMROC_barrel = 0
static int * m_strawToASDBLR_barrelSideA = 0
static int * m_strawToASDBLR_barrelSideC = 0
static int * m_strawToHVpad_barrel = 0
static int * m_strawToLayer = 0
static int * m_strawToStrawLayer = 0
static int * m_strawToStrawWithinLayer = 0
static int m_instance_count = 0

Detailed Description

Definition at line 30 of file TRT_StrawMap.h.

Constructor & Destructor Documentation

◆ strawMap() [1/2]

strawMap::strawMap ( int side,
int phi,
int straw )

Definition at line 93 of file TRT_StrawMap.h.

94
97
98 assert( straw>=0 && straw<5482 );
99 assert( std::abs(side)==1 || std::abs(side)==2 );
100 assert( phi>=0 && phi<32 );
101};
void initialize()
int side() const
int phi() const
static int * m_strawToDTMROC_barrel
int straw() const
static int m_instance_count

◆ strawMap() [2/2]

strawMap::strawMap ( int side,
int phi,
int layer,
int strawLayer,
int strawWithinStrawLayer )

Definition at line 103 of file TRT_StrawMap.h.

103 : m_side(side), m_phi(phi) {
104
107
108 m_straw = (std::abs(side)==1) ? barrelStrawNumber(strawWithinStrawLayer, strawLayer, layer) : endcapStrawNumber(strawWithinStrawLayer, strawLayer, layer);
109
110 assert( m_straw>=0 && m_straw<5482 );
111 assert( std::abs(side)==1 || std::abs(side)==2 );
112 assert( phi>=0 && phi<32 );
113};
int barrelStrawNumber(int strawNumber, int strawlayerNumber, int LayerNumber)
int strawLayer() const
int layer() const
int endcapStrawNumber(int strawNumber, int strawLayerNumber, int layerNumber)

◆ ~strawMap()

strawMap::~strawMap ( )

Definition at line 115 of file TRT_StrawMap.h.

115 {
117 if (m_instance_count==0) clean_up();
118};
void clean_up()

Member Function Documentation

◆ ASDBLR()

int strawMap::ASDBLR ( )

Definition at line 135 of file TRT_StrawMap.h.

135 {
136
138 else if (m_side==-1) return m_strawToASDBLR_barrelSideC[m_straw];
139
140 assert(std::abs(m_side)==2);
141
142 int strawNumber = this->strawWithinLayer();
143 int strawLayerNumber = this->strawLayer();
144
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;
149
150 return asdblr;
151};
int strawWithinLayer() const
static int * m_strawToASDBLR_barrelSideC
static int * m_strawToASDBLR_barrelSideA

◆ barrelStrawNumber()

int strawMap::barrelStrawNumber ( int strawNumber,
int strawlayerNumber,
int LayerNumber )
private

Definition at line 287 of file TRT_StrawMap.h.

287 {
288
289 const int numberOfStraws[74] = { 0, 15, 31, 47, 63, 79, 96, 113, 130, 147, 164, 182, 200, 218, 236, 254, 273, 292, 311, 329, // layer 0, 329 straws, strawlayers 0-18
290 348, 368, 388, 408, 428, 448, 469, 490, 511, 532, 553, 575, 597, 619, 641, 663, 686, 709, 732, 755, 778, 802, 826, 849, // layer 1, 520 straws, strawLayers 0-23
291 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 }; // layer 2
292
293 if (LayerNumber==1) strawlayerNumber+= 19;
294 else if (LayerNumber==2) strawlayerNumber+= 43;
295
296 return ( numberOfStraws[strawlayerNumber+1] - strawNumber -1 );
297};

◆ clean_up()

void strawMap::clean_up ( )
private

Definition at line 270 of file TRT_StrawMap.h.

270 {
271
272 printf("strawMap::clean_up - delete all tables\n\n");
273
274 delete[] m_strawToLayer; m_strawToLayer = 0;
277
281
283
284 return;
285};
static int * m_strawToLayer
static int * m_strawToHVpad_barrel
static int * m_strawToStrawLayer
static int * m_strawToStrawWithinLayer

◆ DTMROC()

int strawMap::DTMROC ( )

Definition at line 120 of file TRT_StrawMap.h.

120 {
121
122 if (std::abs(m_side)==1) return m_strawToDTMROC_barrel[m_straw];
123
124 assert( std::abs(m_side)==2 ); // end-caps
125 int layerNumber = this->layer();
126 int strawLayerNumber = this->strawLayer();
127 int strawNumber = this->strawWithinLayer();
128
129 int chip = ec_chip( m_side, m_phi, layerNumber, strawLayerNumber, strawNumber); // returns 0-11
130 chip += 12 * ( this->TTCgroup() - 9 ); // increment according to the board number
131 chip += 104;
132 return chip;
133};
int TTCgroup()
int ec_chip(int side, int phi, int layerNumber, int strawLayerNumber, int strawNumber)

◆ ec_chip()

int strawMap::ec_chip ( int side,
int phi,
int layerNumber,
int strawLayerNumber,
int strawNumber )
private

Definition at line 310 of file TRT_StrawMap.h.

310 {
311 // endcap only, return 0-12
312
313 assert( std::abs(side)==2 );
314
315 static int count = 0;
316 static int *map_A0 = new int[12];
317 static int *map_A8 = new int[12];
318 static int *map_C0 = new int[12];
319 static int *map_C8 = new int[12];
320 if (!count) {
321 count++;
322 int chipIndexToChipHardware_A0[] = {2, 1, 3, 0, 6, 5, 7, 4, 10, 9, 11, 8};
323 int chipIndexToChipHardware_A8[] = {8, 11, 9, 10, 4, 7, 5, 6, 0, 3, 1, 2};
324 int chipIndexToChipHardware_C0[] = {1, 2, 0, 3, 5, 6, 4, 7, 9, 10, 8, 11};
325 int chipIndexToChipHardware_C8[] = {11, 8, 10, 9, 7, 4, 6, 5, 3, 0, 2, 1};
326 int *map_list[] = {map_A0, map_A8, map_C0, map_C8};
327 int *chip_list[] = {chipIndexToChipHardware_A0, chipIndexToChipHardware_A8, chipIndexToChipHardware_C0, chipIndexToChipHardware_C8};
328 for (int i=0; i<4; i++) for (int j=0; j<12; j++) map_list[i][j] = chip_list[i][j];
329 }
330
331 int chip = (strawNumber - strawNumber%4) / 2;
332 if (strawLayerNumber%8 >= 4) chip++;
333
334 int nominal_reversed = 1 - ( (phi - phi%8)/8 ) %2 ;
335 int *map = 0;
336 if (side==2) map = nominal_reversed ? map_A8 : map_A0;
337 if (side==-2) map = nominal_reversed ? map_C8 : map_C0;
338 if (not map) {
339 throw std::runtime_error("map pointer is null in TRT_StrawMap.h");
340 }
341 chip = map[chip];
342 return chip;
343}
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ endcapStrawNumber()

int strawMap::endcapStrawNumber ( int strawNumber,
int strawLayerNumber,
int layerNumber )
private

Definition at line 299 of file TRT_StrawMap.h.

299 {
300
301 int board = layerNumber;
302 if (board<6) { board *= 2; if (strawLayerNumber>7) board++; }
303 else { board += 6; }
304
305 int straw = board * 192 + strawNumber * 8 + strawLayerNumber % 8 ;
306 straw += 1642;
307 return straw;
308};

◆ HVpad()

int strawMap::HVpad ( )

Definition at line 196 of file TRT_StrawMap.h.

196 {
197 if (std::abs(m_side)==1) return m_strawToHVpad_barrel[m_straw];
198 assert( std::abs(m_side)==2 ); // end-caps
199 int asdblr = this->ASDBLR();
200 if (asdblr < 0){
201 throw std::runtime_error("asdblr is less than zero");
202 }
203 //overflow guarded against in the above lines
204 //coverity[return_overflow]
205 return ( (this->DTMROC()) * 2 + (asdblr) );
206};
int DTMROC()
int ASDBLR()

◆ initialize()

void strawMap::initialize ( )
private

Definition at line 208 of file TRT_StrawMap.h.

208 {
209
210 printf("strawMap::initialize - initialize table containters\n");
211 static int count_initialize(0); count_initialize++;
212 if (count_initialize>2) {
213 printf("strawMap::initialize - if you are seeing a lot of this messages, \n");
214 printf(" create one dummy instance of strawMap class that lives \n");
215 printf(" from start till the end of your programm. \n");
216 }
217
218 int table_length = 1642; // N straws in barrel
219 m_strawToDTMROC_barrel = new int[table_length];
220 m_strawToASDBLR_barrelSideA = new int[table_length];
221 m_strawToASDBLR_barrelSideC = new int[table_length];
222 for (int i=0; i<table_length; i++) {
226 }
227 m_strawToHVpad_barrel = new int[table_length];
228
229 table_length = 5482; // N straws in barrel + end-caps
230 m_strawToStrawLayer = new int[table_length];
231 m_strawToLayer = new int[table_length];
232 m_strawToStrawWithinLayer = new int[table_length];
233
234 for (int i=0; i<table_length; i++) {
235 m_strawToLayer[i] = 0;
238 }
239
240 int index[15];
241 int count(0);
242 char filename[1000]; sprintf(filename, "%s", PathResolver::find_file("TRT_CalibAlgs/TRT_StrawMap.txt", "DATAPATH").c_str());
243 FILE *f = fopen(filename, "r");
244 if (!f) {
245 printf("TRT_StrawMap::initialize() ERROR: failed to open the mapping file %s \n", filename);
246 printf("TRT_StrawMap::initialize() ERROR: you need to fix the file name / link, WILL CRASH THE CODE NOW\n");
247 std::abort();
248 }
249 //what are these numbers, what are valid ranges?
250 while(fscanf(f, "%d %d %d %d %d %d %d %d\n", index, index+1, index+2, index+3, index+4, index+5, index+6, index+7)==8) {
251 assert(index[0]>=0 && index[0]<5482);
252 //coverity[tainted_data]
253 m_strawToLayer[index[0]] = index[1];
256 if (index[0]<1642) {
261 }
262 count++;
263 }
264 printf("read %d lines from file %s\n", count, filename);
265 fclose(f);
266
267 return;
268};
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
str index
Definition DeMoScan.py:362

◆ layer()

int strawMap::layer ( ) const
inline

Definition at line 43 of file TRT_StrawMap.h.

43{ return m_strawToLayer[m_straw]; };

◆ phi()

int strawMap::phi ( ) const
inline

Definition at line 40 of file TRT_StrawMap.h.

40{ return m_phi; }

◆ side()

int strawMap::side ( ) const
inline

Definition at line 39 of file TRT_StrawMap.h.

39{ return m_side; }

◆ straw()

int strawMap::straw ( ) const
inline

Definition at line 41 of file TRT_StrawMap.h.

41{ return m_straw; }

◆ strawLayer()

int strawMap::strawLayer ( ) const
inline

Definition at line 44 of file TRT_StrawMap.h.

44{ return m_strawToStrawLayer[m_straw]; };

◆ strawWithinLayer()

int strawMap::strawWithinLayer ( ) const
inline

Definition at line 45 of file TRT_StrawMap.h.

◆ TTCgroup()

int strawMap::TTCgroup ( )

Definition at line 153 of file TRT_StrawMap.h.

153 {
154
155 if (std::abs(m_side)==1) { // barrel
156
157 // return logical board index:
158 // 0 for Board 1S (has 10 chips) 0 - 9
159 // 1 for 1L (11) 10 - 20
160 // 2 for 2S (15) 21 - 35
161 // 3 for 2L, first 9 chips 36 - 44
162 // 4 for 2L, second 9 chips 45 - 53
163 // 5 for 3S, first 11 54 - 64
164 // 6 for 3S, second 12 65 - 76
165 // 7 for 3L, first 13 77 - 89
166 // 8 for 3L, second 14 90 - 103
167
168 const int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
169 int count = 0;
170
171 int chip = this->DTMROC();
172
173 for (int i=0; i<9; i++) {
174 count += list[i];
175 if (chip < count) return i;
176 }
177
178 assert(count==104);
179 return -1;
180
181 } else if (std::abs(m_side)==2) { // end-caps
182
183 int straw = m_straw - 1642;
184 int board = 9;
185 while (straw>=192) { // the number of straws per triplet board
186 straw -= 192;
187 board++;
188 }
189 return board;
190 }
191
192 assert(0);
193 return -1;
194};
list(name, path='/')
Definition histSizes.py:38

Member Data Documentation

◆ m_instance_count

int strawMap::m_instance_count = 0
staticprivate

Definition at line 69 of file TRT_StrawMap.h.

◆ m_phi

int strawMap::m_phi
private

Definition at line 56 of file TRT_StrawMap.h.

◆ m_side

int strawMap::m_side
private

Definition at line 55 of file TRT_StrawMap.h.

◆ m_straw

int strawMap::m_straw
private

Definition at line 57 of file TRT_StrawMap.h.

◆ m_strawToASDBLR_barrelSideA

int * strawMap::m_strawToASDBLR_barrelSideA = 0
staticprivate

Definition at line 60 of file TRT_StrawMap.h.

◆ m_strawToASDBLR_barrelSideC

int * strawMap::m_strawToASDBLR_barrelSideC = 0
staticprivate

Definition at line 61 of file TRT_StrawMap.h.

◆ m_strawToDTMROC_barrel

int * strawMap::m_strawToDTMROC_barrel = 0
staticprivate

Definition at line 59 of file TRT_StrawMap.h.

◆ m_strawToHVpad_barrel

int * strawMap::m_strawToHVpad_barrel = 0
staticprivate

Definition at line 63 of file TRT_StrawMap.h.

◆ m_strawToLayer

int * strawMap::m_strawToLayer = 0
staticprivate

Definition at line 65 of file TRT_StrawMap.h.

◆ m_strawToStrawLayer

int * strawMap::m_strawToStrawLayer = 0
staticprivate

Definition at line 66 of file TRT_StrawMap.h.

◆ m_strawToStrawWithinLayer

int * strawMap::m_strawToStrawWithinLayer = 0
staticprivate

Definition at line 67 of file TRT_StrawMap.h.


The documentation for this class was generated from the following file: