ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_StrawNeighbourSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
12
13
14
16
19
20#include "Identifier/Identifier.h"
22
26
27//Geometry db
31#include "GaudiKernel/ISvcLocator.h"
32#include "GaudiKernel/GaudiException.h"
33
34//Geomodel
37
38#include <cstdio>
39#include <fstream>
40#include <iostream>
41#include <sstream>
42
43
45 ISvcLocator* pSvcLocator )
46 : base_class(name,pSvcLocator),
47 m_detStore("DetectorStore",name),
48 m_trtid(nullptr)
49{
50 declareProperty("DetectorStore",m_detStore);
51}
52
53
55= default;
56
57
59{
60 ATH_MSG_DEBUG("TRT_StrawNeighbourSvc initialize method called");
61
62 if (StatusCode::SUCCESS!=m_detStore.retrieve()) {
63 msg(MSG::FATAL) << "Couldn't retrieve " << m_detStore << endmsg;
64 return StatusCode::FAILURE;
65 }
66
67 // Get the TRT ID helper
68 if (StatusCode::SUCCESS!=m_detStore->retrieve(m_trtid,"TRT_ID")) {
69 msg(MSG::FATAL) << "Problem retrieving TRTID helper" << endmsg;
70 return StatusCode::FAILURE;
71 }
72
73
74 int chipConversionSocketToChip_m1[]={0,1,2,3,4,21,7,6,5,20,19,8,9,16,17,18,10,15,14,13,12,11};
75 for(int j=0; j<22; j++) m_chipConversionSocketToChip_m1[j]=chipConversionSocketToChip_m1[j];
76 int chipConversionChipToSocket_m1[] = {0,1,2,3,4,8,7,6,11,12,16,21,20,19,18,17,13,14,15,10,9,5};
77 for(int j=0; j<22; j++) m_chipConversionChipToSocket_m1[j]=chipConversionChipToSocket_m1[j];
78
79 int chipConversionSocketToChip_m2[] = {0,5,4,3,2,1,33,6,7,8,9,32,31,12,11,10,27,28,29,30,13,14,26,25,24,23,22,15,16,17,18,19,20,21};
80 for(int j=0; j<34; j++) m_chipConversionSocketToChip_m2[j]=chipConversionSocketToChip_m2[j];
81 int chipConversionChipToSocket_m2[] = {0,5,4,3,2,1,7,8,9,10,15,14,13,20,21,27,28,29,30,31,32,33,26,25,24,23,22,16,17,18,19,12,11,6};
82 for(int j=0; j<34; j++) m_chipConversionChipToSocket_m2[j]=chipConversionChipToSocket_m2[j];
83
84 int chipConversionSocketToChip_m3[] = {0,1,2,3,4,5,6,50,11,10,9,8,7,49,12,13,14,15,48,47,46,18,17,16,42,43,44,45,19,20,41,40,39,38,37,22,21,31,32,33,34,35,36,23,30,29,28,27,26,25,24};
85 for(int j=0; j<51; j++) m_chipConversionSocketToChip_m3[j]=chipConversionSocketToChip_m3[j];
86 int chipConversionChipToSocket_m3[] = {0,1,2,3,4,5,6,12,11,10,9,8,14,15,16,17,23,22,21,28,29,36,35,43,50,49,48,47,46,45,44,37,38,39,40,41,42,34,33,32,31,30,24,25,26,27,20,19,18,13,7};
87 for(int j=0; j<51; j++) m_chipConversionChipToSocket_m3[j]=chipConversionChipToSocket_m3[j];
88
89 if (1) { // initialize endcap chip maps, sasa 27 July 2009
90
91 int chipIndexToChipHardware_A0[] = {2, 1, 3, 0, 6, 5, 7, 4, 10, 9, 11, 8};
92 int chipIndexToChipHardware_A8[] = {8, 11, 9, 10, 4, 7, 5, 6, 0, 3, 1, 2};
93 int chipIndexToChipHardware_C0[] = {1, 2, 0, 3, 5, 6, 4, 7, 9, 10, 8, 11};
94 int chipIndexToChipHardware_C8[] = {11, 8, 10, 9, 7, 4, 6, 5, 3, 0, 2, 1};
96 int *chip_list[] = {chipIndexToChipHardware_A0, chipIndexToChipHardware_A8, chipIndexToChipHardware_C0, chipIndexToChipHardware_C8};
97 for (int i=0; i<4; i++) for (int j=0; j<12; j++) map_list[i][j] = chip_list[i][j];
98 }
99
100
101
102 //Geometry db
103 // RDBAccessSvc (Interface to the DD database).
104 SmartIF<IRDBAccessSvc> iAccessSvc{service("RDBAccessSvc")};
105 if ( !iAccessSvc ) {
106 msg(MSG::FATAL) << "Could not initialize RDBAccessSvc!" << endmsg;
107 throw GaudiException("Could not initalize RDBAccessSvc","TRT_GeoModel",StatusCode::FAILURE);
108 }
109
110 SmartIF<IGeoModelSvc> geoModel{service("GeoModelSvc")};
111 if ( !geoModel ) {
112 msg(MSG::FATAL) << "Could not locate GeoModelSvc" << endmsg;
113 throw GaudiException("Could not locate GeoModelSvc","TRT_GeoModel",StatusCode::FAILURE);
114 }
115 DecodeVersionKey versionKey(geoModel, "TRT");
116 const std::string& detectorKey = versionKey.tag();
117 const std::string& detectorNode = versionKey.node();
118 IRDBRecordset_ptr RDB_TRTElec = iAccessSvc->getRecordsetPtr("TRTBarElecToStrawRel",detectorKey,detectorNode);
119
120 if (RDB_TRTElec->size()==0) {
121 RDB_TRTElec = iAccessSvc->getRecordsetPtr("TRTBarElecToStrawRel","TRTBarElecToStrawRel-02");
122 msg(MSG::INFO) << "The folder: InnerDetector->TRT->TRTBarrel->TRTBarrelElectronics not found in DetDesc tag. Using hardcoded tag: TRTBarElecToStrawRel-02" << endmsg;
123 }
124
125
126 // initialization
127
128 const int numberOfm1layers=19;
129 const int numberOfm2layers=24;
130 const int numberOfm3layers=30;
131
132 int layer_m1_array[numberOfm1layers]= {15,16,16,16,16,17,17,17,17,17,18,18,18,18,18,19,19,19,18};
133 int layer_m2_array[numberOfm2layers]= {19,20,20,20,20,20,21,21,21,21,21,22,22,22,22,22,23,23,23,23,23,24,24,23};
134 int layer_m3_array[numberOfm3layers]= {23,24,24,24,24,25,25,25,25,25,26,26,26,26,26,27,27,27,27,27,28,28,28,28,28,29,29,29,29,28};
135
136 int i =0;
137 unsigned int acc=0;
138
139 for (i=0; i<numberOfm1layers ;i++){
140 m_layer_m1.push_back(layer_m1_array[i]);
141 acc +=layer_m1_array[i];
142 m_layer_m1_acc.push_back(acc);
143 }
144
145 acc=0;
146 for (i=0; i<numberOfm2layers;i++){
147 m_layer_m2.push_back(layer_m2_array[i]);
148 acc +=layer_m2_array[i];
149 m_layer_m2_acc.push_back(acc);
150 }
151
152 acc=0;
153 for (i=0; i<numberOfm3layers;i++){
154 m_layer_m3.push_back(layer_m3_array[i]);
155 acc +=layer_m3_array[i];
156 m_layer_m3_acc.push_back(acc);
157 }
158
159
160
161
163
164
165 int straw =0;
166 int stnm=0, pad=0, previous_pad=1, layer = 0, pad_rel_mod=0;
167 double chip=0.;
168
169 std::vector<std::vector<int> > dummy1;
170 std::vector<int> dummy12;
171 std::vector<std::vector<int> > dummy2;
172 std::vector<int> dummy22;
173 std::vector<std::vector<int> > dummy3;
174 std::vector<int> dummy32;
175
176 std::vector<std::vector<int> > dumdumdum1;
177 std::vector<std::vector<int> > dumdumdum2;
178 std::vector<std::vector<int> > dumdumdum3;
179 std::vector<int> dumdum ;
180 for (unsigned int d =0; d<=100; d++ ) {
181 dumdumdum1.push_back(dumdum);
182 dumdumdum2.push_back(dumdum);
183 dumdumdum3.push_back(dumdum);
184 }
185
186 m_m1.push_back(0);
187 m_m2.push_back(0);
188 m_m3.push_back(0);
189
190
191 dummy1.clear();
192 dummy12.clear();
193 while(layer == 0) {
194 const IRDBRecord* RDBVars__TRTElec = (*RDB_TRTElec)[straw];
195 layer = RDBVars__TRTElec->getInt("LAYER");
196 if (!(layer==0)) break;
197 stnm = RDBVars__TRTElec->getInt("STRAWNUM");
198 pad = RDBVars__TRTElec->getInt("HVPADRELSTRAW");
199 pad_rel_mod = RDBVars__TRTElec->getInt("HVPADRELMOD");
200 m_m1.push_back(pad_rel_mod);
201 if (pad==previous_pad) dummy12.push_back(stnm);
202 else if (pad != previous_pad) {
203 previous_pad=pad;
204 dummy1.push_back(dummy12);
205 dummy12.clear();
206 dummy12.push_back(stnm);
207 }
208 chip=(RDBVars__TRTElec->getDouble("CHIPRELSTRAW"));
209 m_chip_vector1.push_back(chip);
210 (dumdumdum1[(int)chip]).push_back(straw+1);
211 straw++;
212 }
213 m_pad_to_straw.push_back(std::move(dummy1));
214 m_chip_to_straw.push_back(std::move(dumdumdum1));
215
216
217 dummy2.clear();
218 dummy22.clear();
219 previous_pad=1;
220 while(layer == 1) {
221 const IRDBRecord* RDBVars__TRTElec = (*RDB_TRTElec)[straw];
222 layer = RDBVars__TRTElec->getInt("LAYER");
223 if (!(layer==1)) break;
224 stnm = RDBVars__TRTElec->getInt("STRAWNUM");
225 pad = RDBVars__TRTElec->getInt("HVPADRELSTRAW");
226 pad_rel_mod = RDBVars__TRTElec->getInt("HVPADRELMOD");
227 m_m2.push_back(pad_rel_mod);
228 if (pad==previous_pad) dummy22.push_back(stnm);
229 else if (pad != previous_pad) {
230 previous_pad=pad;
231 dummy2.push_back(dummy22);
232 dummy22.clear();
233 dummy22.push_back(stnm);
234 }
235 chip=(RDBVars__TRTElec->getDouble("CHIPRELSTRAW"));
236 m_chip_vector2.push_back(chip);
237 (dumdumdum2[(int)chip]).push_back(straw+1-329);
238 straw++;
239 }
240 m_pad_to_straw.push_back(std::move(dummy2));
241 m_chip_to_straw.push_back(std::move(dumdumdum2));
242
243
244
245 dummy3.clear();
246 dummy32.clear();
247 previous_pad=1;
248 while(layer == 2) {
249 if (straw>1641) break;// return StatusCode::SUCCESS;
250 const IRDBRecord* RDBVars__TRTElec = (*RDB_TRTElec)[straw];
251 layer = RDBVars__TRTElec->getInt("LAYER");
252 if (!(layer==2)) break;
253 stnm = RDBVars__TRTElec->getInt("STRAWNUM");
254 pad = RDBVars__TRTElec->getInt("HVPADRELSTRAW");
255 pad_rel_mod = RDBVars__TRTElec->getInt("HVPADRELMOD");
256 m_m3.push_back(pad_rel_mod);
257 if (pad==previous_pad) dummy32.push_back(stnm);
258 else if (pad != previous_pad) {
259 previous_pad=pad;
260 dummy3.push_back(dummy32);
261 dummy32.clear();
262 dummy32.push_back(stnm);
263 }
264 chip=(RDBVars__TRTElec->getDouble("CHIPRELSTRAW"));
265 m_chip_vector3.push_back(chip);
266 (dumdumdum3[(int)chip]).push_back(straw+1-329-520);
267 straw++;
268
269 }
270 m_pad_to_straw.push_back(std::move(dummy3));
271 m_chip_to_straw.push_back(std::move(dumdumdum3));
272
273
274
275 ATH_MSG_DEBUG("TRT_StrawNeighbourSvc initialized ");
276 if (!((m_m1.size()==330)&&(m_m2.size()==521)&&(m_m3.size()==794) )) ATH_MSG_WARNING("Initialization of TRT_StrawNeighbourTool incomplete. Depending on usage, this can give rise to runtime problems");
277
278
279 //for strawLayer barrel
280 int numberOfStraws[75] = {0,
281 15,
282 16,16,16,16,
283 17,17,17,17,17,
284 18,18,18,18,18,
285 19,19,19,
286 18,
287 19,
288 20,20,20,20,20,
289 21,21,21,21,21,
290 22,22,22,22,22,
291 23,23,23,23,23,
292 24,24,
293 23,23,
294 24,24,24,24,
295 25,25,25,25,25,
296 26,26,26,26,26,
297 27,27,27,27,27,
298 28,28,28,28,28,
299 29,29,29,29,
300 28,
301 0};
302 for(int j=0; j<75; j++) m_numberOfStraws[j]=numberOfStraws[j];
303
304 int TripletOrientation[2][32] = {
305 {1,1,1,1,1,1,1,1,
306 0,0,0,0,0,0,0,0,
307 1,1,1,1,1,1,1,1,
308 0,0,0,0,0,0,0,0},
309 {1,1,1,1,1,1,1,1,
310 0,0,0,0,0,0,0,0,
311 1,1,1,1,1,1,1,1,
312 0,0,0,0,0,0,0,0}
313 };
314
315
316
317 for(int j=0; j<2; j++)
318 for(int jj=0; jj<32; jj++)
319 m_TripletOrientation[j][jj]=TripletOrientation[j][jj];
320
321
322 return StatusCode::SUCCESS;
323
324
325
326}
327
329
330
331
333{
334
335 msg(MSG::INFO) << "TRT_StrawNeighbourSvc finalize method called" << endmsg;
336 return StatusCode::SUCCESS;
337}
338
339
341
342void TRT_StrawNeighbourSvc::getAtlasIdentifier(int strawnumber, Identifier &outputID, Identifier inputID){
343 int straw=0,layer=0;
344 int moduleType = m_trtid->layer_or_wheel(inputID);
345
346 if (moduleType==0) {
347 for (unsigned int i=0; i< m_layer_m1_acc.size();i++){
348 if (((unsigned int)strawnumber)<=m_layer_m1_acc[i]) {
349 layer=i;
350 straw= m_layer_m1_acc[i]-strawnumber;
351 break;
352 }
353 }
354 }
355 else if (moduleType==1) {
356 for (unsigned int i=0; i< m_layer_m2_acc.size();i++){
357 if (((unsigned int)strawnumber)<=m_layer_m2_acc[i]) {
358 layer=i;
359 straw= m_layer_m2_acc[i]-strawnumber;
360 break;
361 }
362 }
363 }
364 else if (moduleType==2) {
365 for (unsigned int i=0; i< m_layer_m3_acc.size();i++){
366 if (((unsigned int)strawnumber)<=m_layer_m3_acc[i]) {
367 layer=i;
368 straw= m_layer_m3_acc[i]-strawnumber;
369 break;
370 }
371 }
372 }
373
374
375 outputID = m_trtid->straw_id(m_trtid->barrel_ec(inputID),
376 m_trtid->phi_module(inputID),
377 m_trtid->layer_or_wheel(inputID),
378 layer,
379 straw);
380}
381
382
383
385
387
388 if (abs((m_trtid->barrel_ec(offlineID)))!=1 ) {
389 msg(MSG::ERROR) << "Sorry, getRunningNumbering only works for barrel" << endmsg;
390 return 0;
391 }
392
393 int layer = m_trtid->straw_layer(offlineID);
394 int straw = m_trtid->straw(offlineID);
395 int moduleType = m_trtid->layer_or_wheel(offlineID);
396
397
398 int strawnumber=0;
399 if (moduleType==0) {
400 strawnumber += m_layer_m1_acc[layer];
401 strawnumber -= straw;
402 }
403 else if (moduleType==1) {
404 strawnumber += m_layer_m2_acc[layer];
405 strawnumber -= straw;
406 }
407 else if (moduleType==2) {
408 strawnumber += m_layer_m3_acc[layer];
409 strawnumber -= straw;
410 }
411 return strawnumber;
412}
413
414
417
418 if ( !(abs(m_trtid->barrel_ec(offlineID))==1)) {
419 msg(MSG::ERROR) << "Sorry, this only works for barrel"<<endmsg;
420 return;
421 } else {
422
423
424
425 int chip = 0;
426 getChip(offlineID,chip);
427 int layer_or_wheel = m_trtid->layer_or_wheel(offlineID);
428
429 if (layer_or_wheel==0 )socket = m_chipConversionChipToSocket_m1[chip];
430 else if (layer_or_wheel==1 )socket = m_chipConversionChipToSocket_m2[chip];
431 else if (layer_or_wheel==2 )socket = m_chipConversionChipToSocket_m3[chip];
432
433 return;
434 }
435}
436
437
438void TRT_StrawNeighbourSvc::getChip(Identifier offlineID, int& chip ){
439
440 int socket=0;
441 chip=0;
442
443 int layer_or_wheel = m_trtid->layer_or_wheel(offlineID);
444
445 if (abs((m_trtid->barrel_ec(offlineID)))!=2 ) {
446 if (layer_or_wheel == 0) socket = (int)m_chip_vector1[getRunningNumbering(offlineID)-1];
447 else if (layer_or_wheel == 1) socket = (int)m_chip_vector2[getRunningNumbering(offlineID)-1];
448 else if (layer_or_wheel == 2) socket = (int)m_chip_vector3[getRunningNumbering(offlineID)-1];
449 else { msg(MSG::ERROR) << "Something is very wrong: According to identifier, straw belongs to a barrel module which is not of type 1,2 or 3 (corresponding to offline numbering: layer_or_wheel = 0,1 or 2) " << endmsg;}
450
451
452 if (layer_or_wheel == 0) chip = m_chipConversionSocketToChip_m1[socket] ;
453 else if (layer_or_wheel == 1) chip = m_chipConversionSocketToChip_m2[socket] ;
454 else if (layer_or_wheel == 2) chip = m_chipConversionSocketToChip_m3[socket] ;
455 return;
456 }
457 int straw = m_trtid->straw(offlineID);
458 int strawlayer = m_trtid->straw_layer(offlineID);
459 int bec = m_trtid->barrel_ec(offlineID);
460 int phi = m_trtid->phi_module(offlineID);
461
462// FIX ENDCAP CHIP MAPPING - SASA, 27 July 2009
463
464 chip = (straw - straw%4) / 2;
465 if (strawlayer%8 >= 4) chip++;
466
467 int nominal_reversed = 1 - ( (phi - phi%8)/8 ) %2 ;
468 int *map = nullptr;
469 if (bec==2) {
470 map = nominal_reversed ? m_endcapChipMapA8 : m_endcapChipMapA0;
471 chip = map[chip];
472 }
473 else if (bec==-2) {
474 map = nominal_reversed ? m_endcapChipMapC8 : m_endcapChipMapC0;
475 chip = map[chip];
476 }
477 else { msg(MSG::ERROR) << "Something is very wrong: endcap chip mapping " << bec << endmsg; chip = 12; }
478
479 chip += 104;
480
481 int board = layer_or_wheel;
482 if (board<6) { board *= 2; if (strawlayer>7) board++; }
483 else { board += 6; }
484 chip += board * 12;
485
486// end FIX ENDCAP CHIP MAPPING - SASA, 27 July 2009
487
488 //orientation
489
490 // endcap A is normal. endcap C is reverse
491/*
492 int orientation = 1;
493 if (bec < 0) orientation = -1;
494
495 //some phi sectors has reverse chip orientation
496 if (!( ( phi >= 24 ) || ( (phi >= 8) && ( phi <= 15)) )) orientation = orientation * (-1 );
497
498 int strawlayer_temp = strawlayer % 8 ;
499 int straw_temp=straw;
500
501 if (bec<0) straw_temp=23-straw_temp;
502
503 //case normal orientation
504 if (orientation > 0 ) {
505 if (strawlayer_temp < 4 ) {
506 if (straw_temp<4) chip = 1;
507 else if (straw_temp<8) chip = 0;
508 else if (straw_temp<12) chip = 5;
509 else if (straw_temp<16) chip = 4;
510 else if (straw_temp<20) chip = 9;
511 else chip = 8;
512 }else{
513 if (straw_temp<4) chip = 2;
514 else if (straw_temp<8) chip = 3;
515 else if (straw_temp<12) chip = 6;
516 else if (straw_temp<16) chip = 7;
517 else if (straw_temp<20) chip = 10;
518 else chip = 11;
519 }
520 }else{
521 if (strawlayer_temp < 4 ) {
522 if (straw_temp<4) chip = 11;
523 else if (straw_temp<8) chip = 10;
524 else if (straw_temp<12) chip = 7;
525 else if (straw_temp<16) chip = 6;
526 else if (straw_temp<20) chip =3;
527 else chip = 2;
528 }else{
529 if (straw_temp<4) chip = 8;
530 else if (straw_temp<8) chip = 9;
531 else if (straw_temp<12) chip = 4;
532 else if (straw_temp<16) chip = 5;
533 else if (straw_temp<20) chip = 0;
534 else chip = 1;
535 }
536 }
537
538
539 chip+=104;
540 if (layer_or_wheel<=5) chip+=layer_or_wheel*24+ (strawlayer <8?0:12);
541 else chip+=6*24+(layer_or_wheel-6)*12;
542
543
544 return;
545*/
546}
547
548
549
550
551
552
553
554
555
556
557void TRT_StrawNeighbourSvc::getPin(Identifier offlineID, int& pin ){
558
559
560 pin=0;
561
562 int layer_or_wheel = m_trtid->layer_or_wheel(offlineID);
563 if (abs((m_trtid->barrel_ec(offlineID)))==1 ) {
564 if (layer_or_wheel == 0) {
565 pin = (int)(100*std::fmod(m_chip_vector1[getRunningNumbering(offlineID)-1],1.)+0.1);
566 }
567 else if (layer_or_wheel == 1) {
568 pin = (int)(100*std::fmod(m_chip_vector2[getRunningNumbering(offlineID)-1],1.)+0.1);
569 }
570 else if (layer_or_wheel == 2){
571 pin = (int)(100*std::fmod(m_chip_vector3[getRunningNumbering(offlineID)-1],1.)+0.1);
572 }
573 else { msg(MSG::ERROR) << "Something is very wrong: According to identifier, straw belongs to a barrel module which is not of type 1,2 or 3 (corresponding to offline numbering: layer_or_wheel = 0,1 or 2) " << endmsg;}
574
575 return;
576 }
577
578 else {
579 msg(MSG::WARNING) << " Sorry getPin only implemented for barrel so far. Returning pin=0 " << endmsg;
580 pin=0;
581
582 return ;
583 }
584}
585
586
587
588
589void TRT_StrawNeighbourSvc::getPad(Identifier offlineID, int& pad ){
590
591 if (abs((m_trtid->barrel_ec(offlineID)))!=1 ) {
592 // msg(MSG::ERROR) << "Sorry, getPad only works for barrel. barrel_ec(offlineID) = "<<m_trtid->barrel_ec(offlineID) << endmsg;
593 int temp_straw = (m_trtid->straw(offlineID))/8;
594 int temp_straw_layer = (m_trtid->straw_layer(offlineID))/4;
595 pad= temp_straw_layer*3+temp_straw+1;
596 return;
597 }
598
599
600 int strawnumber=getRunningNumbering(offlineID);
601 int moduleType = m_trtid->layer_or_wheel(offlineID);
602
603
604 strawnumber=strawnumber%1642;
605
606
607
608 if (moduleType==0) {
609 pad = m_m1[strawnumber];
610 return;
611 }
612 else if (moduleType==1) {
613 pad = m_m2[strawnumber];
614 return;
615 }
616 else if (moduleType==2) {
617 pad = m_m3[strawnumber];
618 return;
619 }
620 msg(MSG::ERROR) << "Something went wrong: Pad not found, returning 0" << endmsg;
621 pad = 0;
622}
623
624
625
626
627
629
630
631void TRT_StrawNeighbourSvc::getStrawsFromPad(Identifier offlineID, std::vector<Identifier>& neighbourIDs) {
632
633 Identifier outputID;
634
635 if (abs((m_trtid->barrel_ec(offlineID))) != 1 ) {
636 // msg(MSG::ERROR) << "Sorry, getStrawsFromPad only works for barrel" << endmsg;
637 // The Endcap getStrawsFromPad has NOT been properly tested!!!!
638
639 int temp_straw = (m_trtid->straw(offlineID))/8;
640 int temp_straw_layer = (m_trtid->straw_layer(offlineID))/4;
641
642
643 for (int temp_it = temp_straw * 8 ; temp_it < temp_straw * 8 +8 ; temp_it++){
644 for (int temp_it2 = temp_straw_layer * 4 ; temp_it2 < temp_straw_layer * 4 +4 ; temp_it2++){
645 outputID = m_trtid->straw_id(m_trtid->barrel_ec(offlineID),
646 m_trtid->phi_module(offlineID),
647 m_trtid->layer_or_wheel(offlineID),
648 temp_straw_layer,
649 temp_straw);
650
651 neighbourIDs.push_back(outputID);
652 }
653 }
654
655 }else{
656 int moduleType = m_trtid->layer_or_wheel(offlineID);
657 int pad = 0;
658 getPad(offlineID, pad);
659 for ( unsigned int j=0; j<(m_pad_to_straw[moduleType][pad-1]).size();j++){
660 getAtlasIdentifier((m_pad_to_straw[moduleType][pad-1][j]),outputID,offlineID);
661 neighbourIDs.push_back(outputID);
662 if (j>9) {
663 msg(MSG::ERROR) << " Error in getStrawsFromPad. Returning "<<endmsg;
664 continue;
665 }
666 }
667 }
668 }
669
671
672
673
674void TRT_StrawNeighbourSvc::getStrawsFromChip(Identifier inputID, std::vector<Identifier>& neighbourIDs) {
675
676 Identifier outputID;
677
678 if (abs((m_trtid->barrel_ec(inputID))) == 2) {
679
680 unsigned int straw = (m_trtid->straw(inputID));
681 unsigned int straw_layer = (m_trtid->straw_layer(inputID));
682
683 unsigned int local_straw = (m_trtid->straw(inputID))%4;
684 unsigned int local_straw_layer = (m_trtid->straw_layer(inputID))%4;
685
686
687 // int sign_straw_layer = 0; // set but not used
688 // int sign_straw = 0; // set but not used
689
690 for( unsigned int i = 0 ; i < 4 ; i ++ ) {
691 for( unsigned int j = 0 ; j < 4 ; j ++ ) {
692
693
694 // set but not used
695 // sign_straw = (i<local_straw ?
696 // -1 :
697 // +1);
698
699 // set but not used
700 // sign_straw_layer = (j<local_straw ?
701 // -1 :
702 // +1);
703
704 outputID = m_trtid->straw_id(m_trtid->barrel_ec(inputID),
705 m_trtid->phi_module(inputID),
706 m_trtid->layer_or_wheel(inputID),
707 ( straw_layer + j - local_straw_layer),
708 ( straw + i - local_straw));
709 neighbourIDs.push_back(outputID);
710 // sign_straw=0;
711 // sign_straw_layer=0; // set but not used
712 }
713 }
714 }
715 else if (abs((m_trtid->barrel_ec(inputID))) == 1 ) {
716 //m_chip_to_straw
717
718 int moduleType = m_trtid->layer_or_wheel(inputID);
719 int chip = 0, chiptest=-10;
720 getChip(inputID, chip);
721
722 for ( unsigned int j=0; j<(m_chip_to_straw[moduleType][chip]).size(); j++){
723 if ( (m_chip_to_straw[moduleType][chip][j] ) ==0 ) continue;
724 getAtlasIdentifier((m_chip_to_straw[moduleType][chip][j]),outputID,inputID);
725 getChip(outputID,chiptest);
726 neighbourIDs.push_back(outputID);
727 if (j>17) {
728 msg(MSG::ERROR) << " Error in getStrawsFromChip. Returning "<<endmsg;
729 continue;
730 }
731 }
732 }
733 else if ( (abs((m_trtid->barrel_ec(inputID))) != 1 ) && (abs((m_trtid->barrel_ec(inputID))) != 2 )) {
734 msg(MSG::ERROR) << "Attempt to use getStrawsFromChip based on a non-TRT identifier. barrel_ec(inputID) = " << m_trtid->barrel_ec(inputID) <<endmsg; }
735
736
737
738 }
739
741
743 Identifier outputID;
744
745 if (abs(m_trtid->barrel_ec(inputID)) == 2 ) {
746
747 unsigned int straw = (m_trtid->straw(inputID));
748 unsigned int straw_layer = (m_trtid->straw_layer(inputID));
749
750 unsigned int local_straw = (m_trtid->straw(inputID))%4;
751 unsigned int local_straw_layer = (m_trtid->straw_layer(inputID))%4;
752
753 //FIXME extra layer not needed
754
755 //construt identifier of first straw in chip
756 outputID = m_trtid->straw_id(m_trtid->barrel_ec(inputID),
757 m_trtid->phi_module(inputID),
758 m_trtid->layer_or_wheel(inputID),
759 ( straw_layer - local_straw_layer),
760 ( straw - local_straw ) );
761
762 }
763 else if (abs((m_trtid->barrel_ec(inputID))) == 1 ) {
764
765 int moduleType = m_trtid->layer_or_wheel(inputID);
766 int chip = 0;
767 getChip(inputID, chip);
768
769 getAtlasIdentifier(m_chip_to_straw[moduleType][chip][0],outputID,inputID);
770
771 }
772 else { msg(MSG::ERROR) << "Attempt to use getFirstStrawFromChip based on a non-TRT identifier. barrel_ec(inputID) = "<<m_trtid->barrel_ec(inputID) << endmsg; }
773
775 TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtid->barrel_ec(outputID),m_trtid->layer_or_wheel(outputID),
776 m_trtid->phi_module(outputID),m_trtid->straw_layer(outputID),
777 m_trtid->straw(outputID),level );
778 return id;
779}
780
781
783
784 // First translate between internal software numbering and hardware numbering:
785 int hardwarechip = 0;
786
787 if ( (chip<1) || (chip > 50) || (abs(layer)>2) ) msg(MSG::ERROR) << "Attempt to use chipToBoard(int chip, int layer) with input outside bounds: 1<=chip<=50 and 0<=|layer|<=2 . Input was: chip = "<<chip<<" layer = "<<layer <<endmsg;
788
789 if (abs(layer)==0) hardwarechip = chip -1;
790 else if (abs(layer)==1) hardwarechip = chip + 20;
791 else if (abs(layer)==2) hardwarechip = chip + 20 + 33;
792
793 //From Sasa
794
795 // return logical board index:
796 // 0 for Board 1S (has 10 chips_
797 // 1 for 1L (11)
798 // 2 for 2S (15)
799 // 3 for 2L, first 9 chips
800 // 4 for 2L, second 9 chips
801 // 5 for 3S, first 11
802 // 6 for 3S, second 12
803 // 7 for 3L, first 13
804 // 8 for 3L, second 14
805
806 int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
807 int count = 0;
808 for (int i=0; i<9; i++) {
809 count += list[i];
810 if (hardwarechip < count) return i;
811 }
812 assert(count==104);
813 assert(0); // should never come this far
814
815 msg(MSG::ERROR) << "Something went wrong in chipToBoardBarrel - please contact the author "<<endmsg;
816
817 return -1;
818}
819
820
822
823 if ( abs( m_trtid->barrel_ec( id ) ) != 2 ) {
824 ATH_MSG_WARNING( "getRing is not valid for barrel straws!" );
825 return -1;
826 }
827
828 // const TRT_ID* m_trtid;
829 unsigned int wheel = m_trtid->layer_or_wheel( id );
830 unsigned int strawlayer = m_trtid->straw_layer( id );
831
832 if (wheel < 6)
833 return (16*wheel + strawlayer) / 4;
834 else
835 return (16*6+8*(wheel-6) + strawlayer) /4;
836}
837
839 //----------------------------------------------------------------
840{
841 int Board = -1;
842 int remainder = (chip-1) % 12;
843 Board = int(((chip -1) - remainder) / 12);
844 return Board;
845}
846
847
848
850//-----------------------------------------------------------------//
851{
852 int bec = m_trtid->barrel_ec(id);
853 int phi_stack = m_trtid->phi_module(id);
854 int LayerNumber = m_trtid->layer_or_wheel(id);
855 int strawlayerNumber = m_trtid->straw_layer(id);
856 int strawNumber = m_trtid->straw(id);
857
858
859 if (abs(bec)==1) {
860
861 int addToStrawNumber=0;
862 int addToStrawNumberNext=0;
863 int i=0;
864
865
866 do
867 {
868 i++;
869 addToStrawNumber+=m_numberOfStraws[i-1];
870 addToStrawNumberNext = addToStrawNumber+m_numberOfStraws[i];
871 }
872 while(strawLayerNumber(id)!=i-1);
873 /*
874 if(strawLayerNumber(id)%2==-10)
875 {
876 strawNumber += addToStrawNumber;
877 }
878 else
879 {
880 strawNumber = addToStrawNumberNext - strawNumber-1;
881 }
882 */
883 strawNumber = addToStrawNumberNext - strawNumber-1;
884
885 return strawNumber;
886 }
887
888 //strawNumber() for barrel
889
890 else if (abs(bec)==2) {
891 int phi1=-1;
892 int side=bec;
893 if(side==2) phi1=phi_stack, side=1;
894 else if (side==-2) phi1=31-phi_stack, side=0;
895 if (phi1>-1){
896 //if (side==1 && TripletOrientation[side][phi1]){
897 if (m_TripletOrientation[side][phi1]){
898 //Change straw number from 0-23 in straw layer to 0-192
899
900 if (strawlayerNumber < 8)strawNumber = strawNumber + 24*strawlayerNumber;
901 if (strawlayerNumber > 7)strawNumber = strawNumber + 24*(strawlayerNumber -8);
902
903 strawNumber = (192-1)*m_TripletOrientation[side][phi1]+strawNumber*(1-2*m_TripletOrientation[side][phi1]);//actual rotation
904
905 //take strawNumber back to 0-23
906 if (strawlayerNumber<8) strawlayerNumber = int(strawNumber/24);
907 if (strawlayerNumber>7) strawlayerNumber = int(strawNumber/24) + 8;
909 }
910
911 //Finish rotation
912
913 //Flip straw in layer.
914
915 if (side==0) strawNumber = 23 - strawNumber;
916
917 //Finish Flipping
918 }
919
920 // Done with corrections
921
922 //Start mapping from athena identifiers to TRTViewer maps
923
924 int strawNumberNew=0;
925
926 if(LayerNumber<6 && strawlayerNumber>7)
927 {
928 strawNumberNew=strawNumberNew+(384*LayerNumber);
929 strawNumberNew=strawNumberNew+192+(strawlayerNumber%8)+(strawNumber*8);
930 }
931 else if(LayerNumber<6 && strawlayerNumber<8)
932 {
933 strawNumberNew=strawNumberNew+(384*LayerNumber);
934 strawNumberNew=strawNumberNew + (strawlayerNumber%8) + (strawNumber*8);
935 }
936
937 else if(LayerNumber>5 && strawlayerNumber>7)
938 {
939 strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6);
940 strawNumberNew = strawNumberNew + 192 + (strawlayerNumber%8) + (8*strawNumber);
941 }
942 else if(LayerNumber>5 && strawlayerNumber<8)
943 {
944 strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6);
945 strawNumberNew = strawNumberNew + (strawlayerNumber%8) + (8*strawNumber);
946 }
947
948 strawNumber=strawNumberNew;
949
950 return strawNumber;
951 }
952 else {
953 msg(MSG::ERROR) << "corrupted input identifier to TRT_StrawNeighbourSvc::strawNumber(). barrel_ec=" <<bec<< endmsg;
954 }
955 return -1;
956}
958 //----------------------------------------------------------------------//
959{
960
961 int bec = m_trtid->barrel_ec(id);
962 // int phi_stack = m_trtid->phi_module(id);
963 int LayerNumber = m_trtid->layer_or_wheel(id);
964 int strawLayerNumber = m_trtid->straw_layer(id);
965 // int strawNumber = m_trtid->straw(id);
966
967
968 if (abs(bec)==1) {
969
970 if(LayerNumber==0)
971 {
973 }
974 else if(LayerNumber==1)
975 {
977 }
978 else if(LayerNumber==2)
979 {
981 }
982
983 return strawLayerNumber;
984 }//strawLayerNumber()
985 else{
986 msg(MSG::ERROR) << "Sorry, TRT_StrawNeighbourSvc::strawLayerNumber only works for barrel" << endmsg;
987 }
988 return -1;
989}
Scalar phi() const
phi method
#define endmsg
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
std::vector< std::pair< HWIdentifier, LArBadFeb > > dummy3
std::pair< bool, LArBadChannel::LArBadChannelEnum::ProblemType > dummy1
std::pair< HWIdentifier32, LArBadFeb > dummy22
std::pair< HWIdentifier, LArBadFeb > dummy2
This is an Identifier helper class for the TRT subdetector.
Service to information on straws electronic grouping Developed for the study of noise correlations be...
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:27
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
virtual unsigned int size() const =0
std::vector< double > m_chip_vector1
std::vector< unsigned int > m_m3
virtual ~TRT_StrawNeighbourSvc()
destructor
std::vector< unsigned int > m_layer_m3
void getSocket(Identifier offlineID, int &socket)
void getStrawsFromPad(Identifier offlineID, std::vector< Identifier > &neighbourIDs)
std::vector< unsigned int > m_layer_m2_acc
ServiceHandle< StoreGateSvc > m_detStore
TRT_StrawNeighbourSvc(const std::string &name, ISvcLocator *pSvcLocator)
constructor
std::vector< unsigned int > m_layer_m1
std::vector< unsigned int > m_layer_m1_acc
int strawLayerNumber(Identifier id)
int getRing(const Identifier &id)
void getPin(Identifier offlineID, int &pin)
int chipToBoardBarrel(int chip, int layer)
std::vector< unsigned int > m_m2
std::vector< unsigned int > m_layer_m2
void getPad(Identifier offlineID, int &pad)
public methods
int getRunningNumbering(Identifier offlineID)
virtual StatusCode initialize()
tool initialize
void getChip(Identifier offlineID, int &chip)
TRTCond::ExpandedIdentifier getFirstStrawFromChip(Identifier offlineID)
void getStrawsFromChip(Identifier offlineID, std::vector< Identifier > &neighbourIDs)
std::vector< unsigned int > m_m1
std::vector< double > m_chip_vector2
virtual StatusCode finalize()
tool finalize
std::vector< std::vector< std::vector< int > > > m_chip_to_straw
std::vector< std::vector< std::vector< int > > > m_pad_to_straw
std::vector< unsigned int > m_layer_m3_acc
void getAtlasIdentifier(int strawnumber, Identifier &outputID, Identifier inputID)
std::vector< double > m_chip_vector3
static int chipToBoardEndCap(int chip)
STL class.
std::vector< std::string > remainder(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
MsgStream & msg
Definition testRead.cxx:32