ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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.

93  : m_side(side), m_phi(phi), m_straw(straw) {
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 };

◆ 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 };

◆ ~strawMap()

strawMap::~strawMap ( )

Definition at line 115 of file TRT_StrawMap.h.

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

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 };

◆ barrelStrawNumber()

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

Definition at line 284 of file TRT_StrawMap.h.

284  {
285 
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, // layer 0, 329 straws, strawlayers 0-18
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, // layer 1, 520 straws, strawLayers 0-23
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 }; // layer 2
289 
290  if (LayerNumber==1) strawlayerNumber+= 19;
291  else if (LayerNumber==2) strawlayerNumber+= 43;
292 
293  return ( numberOfStraws[strawlayerNumber+1] - strawNumber -1 );
294 };

◆ clean_up()

void strawMap::clean_up ( )
private

Definition at line 267 of file TRT_StrawMap.h.

267  {
268 
269  printf("strawMap::clean_up - delete all tables\n\n");
270 
271  delete[] m_strawToLayer; m_strawToLayer = 0;
274 
278 
280 
281  return;
282 };

◆ 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 };

◆ ec_chip()

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

Definition at line 307 of file TRT_StrawMap.h.

307  {
308  // endcap only, return 0-12
309 
310  assert( std::abs(side)==2 );
311 
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];
317  if (!count) {
318  count++;
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];
326  }
327 
328  int chip = (strawNumber - strawNumber%4) / 2;
329  if (strawLayerNumber%8 >= 4) chip++;
330 
331  int nominal_reversed = 1 - ( (phi - phi%8)/8 ) %2 ;
332  int *map = 0;
333  if (side==2) map = nominal_reversed ? map_A8 : map_A0;
334  if (side==-2) map = nominal_reversed ? map_C8 : map_C0;
335  if (not map) {
336  throw std::runtime_error("map pointer is null in TRT_StrawMap.h");
337  }
338  chip = map[chip];
339  return chip;
340 }

◆ endcapStrawNumber()

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

Definition at line 296 of file TRT_StrawMap.h.

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

◆ 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  auto asdblr = this->ASDBLR();
200  if (asdblr < 0){
201  throw std::runtime_error("asdblr is less than zero");
202  }
203  return ( (this->DTMROC()) * 2 + (asdblr) );
204 };

◆ initialize()

void strawMap::initialize ( )
private

Definition at line 206 of file TRT_StrawMap.h.

206  {
207 
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");
214  }
215 
216  int table_length = 1642; // N straws in barrel
217  m_strawToDTMROC_barrel = new int[table_length];
218  m_strawToASDBLR_barrelSideA = new int[table_length];
219  m_strawToASDBLR_barrelSideC = new int[table_length];
220  for (int i=0; i<table_length; i++) {
224  }
225  m_strawToHVpad_barrel = new int[table_length];
226 
227  table_length = 5482; // N straws in barrel + end-caps
228  m_strawToStrawLayer = new int[table_length];
229  m_strawToLayer = new int[table_length];
230  m_strawToStrawWithinLayer = new int[table_length];
231 
232  for (int i=0; i<table_length; i++) {
233  m_strawToLayer[i] = 0;
234  m_strawToStrawLayer[i] = 0;
236  }
237 
238  int index[15];
239  int count(0);
240  char filename[1000]; sprintf(filename, "%s", PathResolver::find_file("TRT_CalibAlgs/TRT_StrawMap.txt", "DATAPATH").c_str());
241  FILE *f = fopen(filename, "r");
242  if (!f) {
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");
245  std::abort();
246  }
247  //what are these numbers, what are valid ranges?
248  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) {
249  assert(index[0]>=0 && index[0]<5482);
250  m_strawToLayer[index[0]] = index[1];
253  if (index[0]<1642) {
258  }
259  count++;
260  }
261  printf("read %d lines from file %s\n", count, filename);
262  fclose(f);
263 
264  return;
265 };

◆ 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 };

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:
strawMap::m_strawToHVpad_barrel
static int * m_strawToHVpad_barrel
Definition: TRT_StrawMap.h:63
strawMap::barrelStrawNumber
int barrelStrawNumber(int strawNumber, int strawlayerNumber, int LayerNumber)
Definition: TRT_StrawMap.h:284
strawMap::m_strawToLayer
static int * m_strawToLayer
Definition: TRT_StrawMap.h:65
strawMap::m_side
int m_side
Definition: TRT_StrawMap.h:55
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
strawMap::initialize
void initialize()
Definition: TRT_StrawMap.h:206
strawMap::m_straw
int m_straw
Definition: TRT_StrawMap.h:57
strawMap::m_strawToStrawLayer
static int * m_strawToStrawLayer
Definition: TRT_StrawMap.h:66
index
Definition: index.py:1
strawMap::strawLayer
int strawLayer() const
Definition: TRT_StrawMap.h:44
strawMap::m_instance_count
static int m_instance_count
Definition: TRT_StrawMap.h:69
strawMap::ASDBLR
int ASDBLR()
Definition: TRT_StrawMap.h:135
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
strawMap::DTMROC
int DTMROC()
Definition: TRT_StrawMap.h:120
lumiFormat.i
int i
Definition: lumiFormat.py:85
hist_file_dump.f
f
Definition: hist_file_dump.py:135
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
strawMap::endcapStrawNumber
int endcapStrawNumber(int strawNumber, int strawLayerNumber, int layerNumber)
Definition: TRT_StrawMap.h:296
strawMap::straw
int straw() const
Definition: TRT_StrawMap.h:41
strawMap::side
int side() const
Definition: TRT_StrawMap.h:39
strawMap::m_phi
int m_phi
Definition: TRT_StrawMap.h:56
strawMap::phi
int phi() const
Definition: TRT_StrawMap.h:40
strawMap::TTCgroup
int TTCgroup()
Definition: TRT_StrawMap.h:153
strawMap::m_strawToASDBLR_barrelSideC
static int * m_strawToASDBLR_barrelSideC
Definition: TRT_StrawMap.h:61
strawMap::strawWithinLayer
int strawWithinLayer() const
Definition: TRT_StrawMap.h:45
strawMap::m_strawToStrawWithinLayer
static int * m_strawToStrawWithinLayer
Definition: TRT_StrawMap.h:67
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
strawMap::m_strawToDTMROC_barrel
static int * m_strawToDTMROC_barrel
Definition: TRT_StrawMap.h:59
strawMap::clean_up
void clean_up()
Definition: TRT_StrawMap.h:267
strawMap::ec_chip
int ec_chip(int side, int phi, int layerNumber, int strawLayerNumber, int strawNumber)
Definition: TRT_StrawMap.h:307
strawMap::m_strawToASDBLR_barrelSideA
static int * m_strawToASDBLR_barrelSideA
Definition: TRT_StrawMap.h:60
strawMap::layer
int layer() const
Definition: TRT_StrawMap.h:43