ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_FillCablingData_SR1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//
6// Implementation file for TRT_FillCablingData_SR1 class
7// P.T. Keener
8//
9
10/*
11 * Assumptions:
12 * One side of the barrel is readout, namely side A
13 * We need to map between phi sector index used in the offline and
14 * the Source IDs programmed in the hardware.
15 *
16 * The m_identifier* and m_collID vectors are indexed by ROB source ID - 1.
17 * The magic mapping between ROB source IDs and phi sector indices is in
18 * getRobID() and in fillCollID(). Everything else should just fall
19 * through and gets the Right Answer.
20 */
21
22#include <fstream>
23
24
25
26#include "eformat/SourceIdentifier.h" // change to new eformat v3
28
30
31using eformat::helper::SourceIdentifier;
32using namespace std;
33
34static
35bool greater_RG_GCM( const GlobalCableMap_t *a, const GlobalCableMap_t *b ),
37
38static const InterfaceID IID_ITRT_FillCablingData_SR1
39 ("TRT_FillCablingData_SR1", 1, 0);
40
41 // Constructor
42TRT_FillCablingData_SR1::TRT_FillCablingData_SR1( const std::string& type, const std::string&
43name,const IInterface* parent ): AthAlgTool(type,name,parent),
44 m_TRTHelper(nullptr)
45{
46 declareInterface< TRT_FillCablingData_SR1 >( this );
47}
48
49
50 // Destructor
53
54
56{ return IID_ITRT_FillCablingData_SR1; }
57
58
59 // Initialisation
61{
62 ATH_MSG_INFO( "TRT_FillCablingData_SR1::initialize" );
63
64
65 // Get the TRT Helper
66 if (detStore()->retrieve(m_TRTHelper, "TRT_ID").isFailure())
67 {
68 ATH_MSG_FATAL( "Could not get TRT ID helper" );
69 return StatusCode::FAILURE;
70 }
71 m_cntx = m_TRTHelper->straw_layer_context();
72
73
75
76
80
81 ATH_MSG_INFO( "TRT_FillCablingData_SR1::initializiation finished" );
82
83 return StatusCode::SUCCESS;
84}
85
86
88{
89 delete m_cabling;
90
91 StatusCode sc = AlgTool::finalize();
92 return sc;
93}
94
95
100
101
103{
104 m_numberOfRings = 3;
105
109
110 // m_numberOfStrawsInBarrelROD = 1642;
112
113 // Mapping from phi sector index to source id
114 //m_phi_to_source.push_back( 2 ); // Phi 0 is Source ID 0x3102
115 //m_phi_to_source.push_back( 3 ); // Phi 1 is Source ID 0x3103
116 // m_phi_to_source.push_back( 3 ); // Phi 0 is Source ID 0x3103
117 // m_phi_to_source.push_back( 2 ); // Phi 1 is Source ID 0x3102
118 // NB: Source ID 0x3101 is the 3S boards on BOTH Phi 0 and Phi 1
119
120
121 int tmpArray[] = {15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, // Module Type 1
122 18, 18, 18, 18, 19, 19, 19, 18, // Module Type 1
123 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, // Module Type 2
124 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 23, // Module Type 2
125 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, // Module Type 3
126 26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28, // Module Type 3
127 28, 29, 29, 29, 29, 28, -1}; // Module Type 3
128
129 int i=0;
130 int RunningCount=0;
131 while( -1 != tmpArray[i] )
132 {
133 RunningCount += tmpArray[i];
134 m_numberOfStrawsInLayers.push_back( RunningCount );
135
136 i++;
137 }
138 m_numberOfStrawsInLayers.push_back( -1 );
139
140 return;
141}
142
143
144 // Fill Tables with IDs for all straws
146{
147 ATH_MSG_INFO( "In defineTables" );
148
149
150 // Reading mapping
151 int moduleId, strawLayerId, strawInLayerId;
152 Identifier strawID;
153 IdentifierHash hashId;
154
155 uint32_t strawNumber, bufferOffset;
156 string thisLine;
157
158 std::string dataFile;
159 std::string file;
160
161 std::ifstream *inputFile;
162
163 /**************************************************************/
164 /* Back Side Connector Tables */
165 /**************************************************************/
166
167 /*
168 * Module Type 1, Back Side, Small and Large Triangles
169 */
170 ATH_MSG_INFO( "defineTables: 1BS-1BL " );
171
172 dataFile = "TRT_SR1_1BS-1BL_map.dat";
173 file = PathResolver::find_file (dataFile, "DATAPATH");
174 inputFile = new std::ifstream( file.c_str() );
175
176 if (!inputFile->is_open())
177 {
178 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
179 }
180
181 while ( getline( *inputFile, thisLine ) )
182 {
183 istringstream parse( thisLine );
184
185 parse >> strawNumber >> bufferOffset;
186
187 m_1BS_1BL_map[bufferOffset] = strawNumber;
188 }
189
190
191 inputFile->close();
192 delete inputFile;
193
194
195 /*
196 * Module Type 2, Back Side, Small Triangle and Large Quad
197 */
198 ATH_MSG_INFO( "defineTables: 2BS-2BL1 " );
199
200 dataFile = "TRT_SR1_2BS-2BL1_map.dat";
201 file = PathResolver::find_file (dataFile, "DATAPATH");
202 inputFile = new std::ifstream( file.c_str() );
203
204 if (!inputFile->is_open())
205 {
206 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
207 }
208
209 while ( getline( *inputFile, thisLine ) )
210 {
211 istringstream parse( thisLine );
212
213 parse >> strawNumber >> bufferOffset;
214
215 m_2BS_2BL1_map[bufferOffset] = strawNumber;
216 }
217
218
219 inputFile->close();
220 delete inputFile;
221
222
223 /*
224 * Back Side, Module Type 2 Large Triangle and Module Type 3 Large Quad
225 */
226 ATH_MSG_INFO( "defineTables: 2BL2-3BL1 " );
227
228 dataFile = "TRT_SR1_2BL2-3BL1_map.dat";
229 file = PathResolver::find_file (dataFile, "DATAPATH");
230 inputFile = new std::ifstream( file.c_str() );
231
232 if (!inputFile->is_open())
233 {
234 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
235 }
236
237 while ( getline( *inputFile, thisLine ) )
238 {
239 istringstream parse( thisLine );
240
241 parse >> strawNumber >> bufferOffset;
242
243 m_2BL2_3BL1_map[bufferOffset] = strawNumber;
244 }
245
246 inputFile->close();
247
248
249 /*
250 * Back Side, Module Type 3 Large Triangle
251 */
252 ATH_MSG_INFO( "defineTables: 3BL2 " );
253
254 dataFile = "TRT_SR1_3BL2_map.dat";
255 file = PathResolver::find_file (dataFile, "DATAPATH");
256 inputFile = new std::ifstream( file.c_str() );
257
258 if (!inputFile->is_open())
259 {
260 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
261 }
262
263 while ( getline( *inputFile, thisLine ) )
264 {
265 istringstream parse( thisLine );
266
267 parse >> strawNumber >> bufferOffset;
268
269 m_3BL2_map[bufferOffset] = strawNumber;
270 }
271
272 inputFile->close();
273
274
275 /*
276 * Back Side, Module Type 3 Small Triangle
277 */
278 ATH_MSG_INFO( "defineTables: 3BS " );
279
280 dataFile = "TRT_SR1_3BS_map.dat";
281 file = PathResolver::find_file (dataFile, "DATAPATH");
282 inputFile = new std::ifstream( file.c_str() );
283
284 if (!inputFile->is_open())
285 {
286 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
287 }
288
289 while ( getline( *inputFile, thisLine ) )
290 {
291 istringstream parse( thisLine );
292
293 parse >> strawNumber >> bufferOffset;
294
295 m_3BS_map[bufferOffset] = strawNumber;
296 }
297
298 inputFile->close();
299
300
301 /**************************************************************/
302 /* Front Side Connector Tables */
303 /**************************************************************/
304
305 /*
306 * Module Type 1, Front Side, Small and Large Triangles
307 */
308 ATH_MSG_INFO( "defineTables: 1FS-1FL " );
309
310 dataFile = "TRT_SR1_1FS-1FL_map.dat";
311 file = PathResolver::find_file (dataFile, "DATAPATH");
312 inputFile = new std::ifstream( file.c_str() );
313
314 if (!inputFile->is_open())
315 {
316 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
317 }
318
319 while ( getline( *inputFile, thisLine ) )
320 {
321 istringstream parse( thisLine );
322
323 parse >> strawNumber >> bufferOffset;
324
325 m_1FS_1FL_map[bufferOffset] = strawNumber;
326 }
327
328 inputFile->close();
329
330
331 /*
332 * Module Type 2, Front Side, Small Triangle and Large Trapezoid
333 */
334 ATH_MSG_INFO( "defineTables: 2FS-2FL1 " );
335
336 dataFile = "TRT_SR1_2FS-2FL1_map.dat";
337 file = PathResolver::find_file (dataFile, "DATAPATH");
338 inputFile = new std::ifstream( file.c_str() );
339
340 if (!inputFile->is_open())
341 {
342 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
343 }
344
345 while ( getline( *inputFile, thisLine ) )
346 {
347 istringstream parse( thisLine );
348
349 parse >> strawNumber >> bufferOffset;
350
351 m_2FS_2FL1_map[bufferOffset] = strawNumber;
352 }
353
354 inputFile->close();
355
356
357 /*
358 * Front Side, Module Type 2 Large Triangle and Module Type 3 Large Quad
359 */
360 ATH_MSG_INFO( "defineTables: 2FL2-3FL1 " );
361
362 dataFile = "TRT_SR1_2FL2-3FL1_map.dat";
363 file = PathResolver::find_file (dataFile, "DATAPATH");
364 inputFile = new std::ifstream( file.c_str() );
365
366 if (!inputFile->is_open())
367 {
368 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
369 }
370
371 while ( getline( *inputFile, thisLine ) )
372 {
373 istringstream parse( thisLine );
374
375 parse >> strawNumber >> bufferOffset;
376
377 m_2FL2_3FL1_map[bufferOffset] = strawNumber;
378 }
379
380 inputFile->close();
381
382
383 /*
384 * Front Side, Module Type 3 Large Triangle
385 */
386 ATH_MSG_INFO( "defineTables: 3FL2 " );
387
388 dataFile = "TRT_SR1_3FL2_map.dat";
389 file = PathResolver::find_file (dataFile, "DATAPATH");
390 inputFile = new std::ifstream( file.c_str() );
391
392 if (!inputFile->is_open())
393 {
394 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
395 }
396
397 while ( getline( *inputFile, thisLine ) )
398 {
399 istringstream parse( thisLine );
400
401 parse >> strawNumber >> bufferOffset;
402
403 m_3FL2_map[bufferOffset] = strawNumber;
404 }
405
406 inputFile->close();
407
408
409 /*
410 * Front Side, Module Type 3 Small Triangle
411 */
412 ATH_MSG_INFO( "defineTables: 3FS " );
413
414 dataFile = "TRT_SR1_3FS_map.dat";
415 file = PathResolver::find_file (dataFile, "DATAPATH");
416 inputFile = new std::ifstream( file.c_str() );
417
418 if (!inputFile->is_open())
419 {
420 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
421 }
422
423 while ( getline( *inputFile, thisLine ) )
424 {
425 istringstream parse( thisLine );
426
427 parse >> strawNumber >> bufferOffset;
428
429 m_3FS_map[bufferOffset] = strawNumber;
430 }
431
432 inputFile->close();
433
434
435 /**************************************************************/
436 /* Global Cabling Specification */
437 /**************************************************************/
438
439 ATH_MSG_INFO( "defineTables: Global Spec " );
440
441 dataFile = "TRT_SR1_Barrel_Cable_map.dat";
442
443
444 file = PathResolver::find_file (dataFile, "DATAPATH");
445 inputFile = new std::ifstream( file.c_str() );
446
447 if (!inputFile->is_open())
448 {
449 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Could not open file " << dataFile );
450 }
451
452 uint32_t srcId;
453 std::string feId;
454
455 while ( getline( *inputFile, thisLine ) )
456 {
457 if ( thisLine.length() == 0 )
458 continue;
459
460 string::size_type loc = thisLine.find( '#' );
461 if ( loc != string::npos )
462 {
463 thisLine.replace( loc, thisLine.length(), 1, ' ' );
464
465 loc = thisLine.find_first_not_of( " \t" );
466 if ( loc == string::npos )
467 continue;
468 }
469
470
471 istringstream parse( thisLine );
472
474
475 parse >> (hex) >> srcId >> (dec) >> my_map->Phi >> my_map->RODGroup >> my_map->FEid;
476
477
478 // int this_phi; // set but not used
479
480 if ( (srcId & 0xFF0000) == 0x310000 )
481 {
482 my_map->SubDet = 1;
483 // this_phi = my_map->Phi; // set but not used
484 }
485 else if ( (srcId & 0xFF0000) == 0x320000 )
486 {
487 my_map->SubDet = -1;
488 // this_phi = -my_map->Phi; // set but not used
489 }
490 else if ( (srcId & 0xFF0000) == 0x330000 )
491 {
492 my_map->SubDet = 2;
493 // this_phi = my_map->Phi; // set but not used
494 }
495 else if ( (srcId & 0xFF0000) == 0x340000 )
496 {
497 my_map->SubDet = -2;
498 // this_phi = -my_map->Phi; // set but not used
499 }
500 else {
501 ATH_MSG_FATAL( "TRT_FillCablingData_SR1: Invalid source id " << (hex) << srcId << (dec) );
502 my_map->SubDet = 0;
503 }
504
505
506 /*
507 * my_phi is
508 32 - 63 for +barrel
509 64 - 95 for +end cap
510 -32 - -63 for -barrel
511 -64 - -95 for -end cap
512 */
513
514
515 // int my_phi = my_map->Phi * my_map->SubDet;
516 int my_phi = my_map->SubDet * 32 + my_map->Phi;
517
518
519 std::vector<uint32_t>::iterator it = (m_phi_to_source[my_phi]).begin();
520 while ( (it != (m_phi_to_source[my_phi]).end()) && (srcId != *it) )
521 ++it;
522
523 if ( it == m_phi_to_source[my_phi].end() )
524 {
525 (m_phi_to_source[my_phi]).push_back( srcId );
526 }
527
528
529 (m_CableMap[srcId]).push_back( my_map );
530 }
531
532 inputFile->close();
533
534#ifdef NOTDEF
535 int ptk_i;
536 for ( ptk_i=1; ptk_i<=444; ptk_i++ )
537 {
538 std::map<int, int>::iterator map_it = m_1BS_1BL_map.find( ptk_i );
539 // if ( map_it != m_1BS_1BL_map.end() )
540 // cout << "Offset " << map_it->first << " is Straw " << map_it->second << endl;
541 }
542#endif // NOTDEF
543
544 GlobalCableMap::iterator pos;
545 for ( pos=m_CableMap.begin(); pos != m_CableMap.end(); ++pos )
546 {
547 std::vector< GlobalCableMap_t *> GCM;
548
549 GCM = pos->second;
550
551 sort( GCM.begin(), GCM.end(), greater_RG_GCM );
552
553 int ConnectorCount=-1;
554 std::vector< GlobalCableMap_t *>::iterator it;
555 for ( it=GCM.begin(); it != GCM.end(); ++it )
556 {
557 ConnectorCount++;
558
559 GlobalCableMap_t *my_map = *it;
560 std::map<int, int> con_map;
561
562
563 if ( my_map->FEid == "1BS_1BL" )
564 con_map = m_1BS_1BL_map;
565 else if ( my_map->FEid == "2BS_2BL1" )
566 con_map = m_2BS_2BL1_map;
567 else if ( my_map->FEid == "2BL2_3BL1" )
568 con_map = m_2BL2_3BL1_map;
569 else if ( my_map->FEid == "3BL2" )
570 con_map = m_3BL2_map;
571 else if ( my_map->FEid == "3BS" )
572 con_map = m_3BS_map;
573 else if ( my_map->FEid == "1FS_1FL" )
574 con_map = m_1FS_1FL_map;
575 else if ( my_map->FEid == "2FS_2FL1" )
576 con_map = m_2FS_2FL1_map;
577 else if ( my_map->FEid == "2FL2_3FL1" )
578 con_map = m_2FL2_3FL1_map;
579 else if ( my_map->FEid == "3FL2" )
580 con_map = m_3FL2_map;
581 else if ( my_map->FEid == "3FS" )
582 con_map = m_3FS_map;
583 else if ( my_map->FEid == "ec_rod1l" )
584 con_map = m_ec_1l_map;
585 else if ( my_map->FEid == "ec_rod2l" )
586 con_map = m_ec_2l_map;
587 else if ( my_map->FEid == "ec_rod3l" )
588 con_map = m_ec_3l_map;
589 else if ( my_map->FEid == "ec_rod1r" )
590 con_map = m_ec_1r_map;
591 else if ( my_map->FEid == "ec_rod2r" )
592 con_map = m_ec_2r_map;
593 else if ( my_map->FEid == "ec_rod3r" )
594 con_map = m_ec_3r_map;
595
596
597 int i;
598 Identifier NULLstrawID(0);
599
600 if ( abs( my_map->SubDet ) == 1 ) // barrel
601 {
602 for ( i=1; i<=444; i++ ) // loop over buffer offset
603 {
604 std::map<int, int>::iterator map_it = con_map.find( i );
605
606 if ( map_it == con_map.end() )
607 {
608 m_cabling->set_identifierForAllStraws( pos->first,
609 i + ConnectorCount*444,
610 NULLstrawID );
611 continue;
612 }
613
614 int BufferLocation = map_it->first + ConnectorCount*444;
615 int Straw = map_it->second - 1; // Offline starts at 0
616
617 strawLayerId = 0;
618 while ( (m_numberOfStrawsInLayers[strawLayerId] <= Straw) &&
619 (m_numberOfStrawsInLayers[strawLayerId] != -1) )
620 {
621 strawLayerId++;
622 }
623
624 if ( m_numberOfStrawsInLayers[strawLayerId] == -1)
625 {
626 ATH_MSG_WARNING( "Invalid Straw in table: " << Straw );
627 continue;
628 }
629
630
631 strawInLayerId = m_numberOfStrawsInLayers[strawLayerId] - Straw - 1;
632
633 moduleId = -1;
634 if ( strawLayerId < m_numberOfLayersA )
635 moduleId = 0;
636 else if ( strawLayerId < (m_numberOfLayersA + m_numberOfLayersB) )
637 {
638 moduleId = 1;
639 strawLayerId = strawLayerId - m_numberOfLayersA;
640 }
641 else if ( strawLayerId < (m_numberOfLayersA + m_numberOfLayersB + m_numberOfLayersC) )
642 {
643 moduleId = 2;
644 strawLayerId = strawLayerId - (m_numberOfLayersA + m_numberOfLayersB);
645 }
646
647
648
649 strawID = m_TRTHelper->straw_id( my_map->SubDet, my_map->Phi,
650 moduleId, strawLayerId,
651 strawInLayerId );
652
653
654 m_cabling->set_identifierForAllStraws( pos->first, BufferLocation,
655 strawID );
656
657
658 // IdLayer = m_TRTHelper->layer_id( strawID );
659
660 // int result = m_TRTHelper->get_hash( strawID, hashId, &m_cntx );
661
662 Identifier Lid = m_TRTHelper->layer_id( my_map->SubDet,
663 my_map->Phi, moduleId,
664 strawLayerId );
665
666 int result = m_TRTHelper->get_hash( Lid, hashId, &m_cntx );
667 if ( result != 0 )
668 {
669 ATH_MSG_WARNING( ">>>>>>>>>>> Get Hash FAILED! <<<<<<<<<<" );
670 ATH_MSG_WARNING( "Straw = " << Straw \
671 << " array = " << m_numberOfStrawsInLayers[strawLayerId] \
672 << " SubDet = " << my_map->SubDet \
673 << " Phi = " << my_map->Phi \
674 << " Module = " << moduleId \
675 << " Layer = " << strawLayerId \
676 << " StrInLay = " << strawInLayerId );
677 }
678
679
680 m_cabling->set_identifierHashForAllStraws( pos->first,
681 BufferLocation,
682 hashId );
683 }
684 }
685 else // Endcap
686 {
687 for ( i=0; i<1776; i++ ) // loop over buffer offset
688 {
689 std::map<int, int>::iterator map_it = con_map.find( i );
690
691 if ( map_it == con_map.end() )
692 {
693 m_cabling->set_identifierForAllStraws( pos->first, i,
694 NULLstrawID );
695 continue;
696 }
697
698 int BufferLocation = i;
699 int Straw = map_it->second; // Offline starts at 0
700
701 strawLayerId = (Straw >> 8) & 0xff;
702 strawInLayerId = Straw & 0xff;
703
704 moduleId = strawLayerId / 8;
705 if ( moduleId < 12 ) // A wheel?
706 {
707 moduleId = moduleId / 2;
708 strawLayerId = strawLayerId % 16;
709 }
710 else // B wheel
711 {
712 moduleId = moduleId - 6;
713 strawLayerId = strawLayerId % 8;
714 }
715
716
717 strawID = m_TRTHelper->straw_id( my_map->SubDet, my_map->Phi,
718 moduleId, strawLayerId,
719 strawInLayerId );
720
721
722 m_cabling->set_identifierForAllStraws( pos->first, BufferLocation,
723 strawID );
724
725
726 // IdLayer = m_TRTHelper->layer_id( strawID );
727
728 // int result = m_TRTHelper->get_hash( strawID, hashId, &m_cntx );
729
730 Identifier Lid = m_TRTHelper->layer_id( my_map->SubDet,
731 my_map->Phi, moduleId,
732 strawLayerId );
733
734 int result = m_TRTHelper->get_hash( Lid, hashId, &m_cntx );
735 if ( result != 0 )
736 {
737 ATH_MSG_WARNING( ">>>>>>>>>>> Get Hash FAILED! <<<<<<<<<<" );
738
739 ATH_MSG_WARNING( "Straw = " << Straw \
740 << " SubDet = " << my_map->SubDet \
741 << " Phi = " << my_map->Phi \
742 << " Module = " << moduleId \
743 << " Layer = " << strawLayerId \
744 << " StrInLay = " << strawInLayerId );
745 }
746
747
748 m_cabling->set_identifierHashForAllStraws( pos->first,
749 BufferLocation,
750 hashId );
751 } // loop over bufferOffsets
752 } // Endcap
753 } // loop over GCM
754 } // loop over CableMap
755
756
757
758 ATH_MSG_INFO( "Out of defineTables" );
759
760 return;
761}
762
763/*
764 * Define map of collection IDs for all ROBs
765 */
767{
768 ATH_MSG_INFO( "In defineCollID()" );
769
770 GlobalCableMap::iterator pos;
771 for ( pos=m_CableMap.begin(); pos != m_CableMap.end(); ++pos )
772 {
773 std::vector<IdentifierHash> * vectID = new std::vector<IdentifierHash>();
774 fillCollID( pos->first, *vectID);
775
776 ATH_MSG_INFO( "Adding Collid for ROB " << std::hex << pos->first << std::dec );
777
778 m_cabling->add_collID( pos->first, vectID);
779 }
780
781 return;
782}
783
784
785/*
786 * Input: ROB Source ID
787 * Output: List of Hash IDs, one for each of 73 layers
788 */
790std::vector<IdentifierHash> & ids)
791{
792
793 IdentifierHash idHash;
794
795 // eformat::SubDetector det_id; // set but not used
796 // int module; // set but not used
797
798 eformat::helper::SourceIdentifier id (rob_id);
799 // det_id = id.subdetector_id(); // set but not used
800 // module = (int) id.module_id(); // set but not used
801
802
803 std::map<int, std::vector<GlobalCableMap_t *> >::iterator map_it = m_CableMap.find( rob_id );
804 if ( map_it == m_CableMap.end() )
805 {
806 ATH_MSG_FATAL( "fillCollID: Unable to get CableMap for rob_id " << std::hex << rob_id << std::dec );
807 return;
808 }
809
810 std::vector< GlobalCableMap_t *> GCM = map_it->second;
811
812 sort( GCM.begin(), GCM.end(), greater_Phi_GCM );
813
814 std::vector<GlobalCableMap_t *>::iterator it;
815
816
817 it=GCM.begin();
818 while ( it != GCM.end() )
819 {
820 GlobalCableMap_t *my_map = *it;
821 int rings = 0;
822 int phi = my_map->Phi;
823 int barrelId = my_map->SubDet;
824
825 if ( abs( barrelId ) == 1 ) // barrel?
826 {
827
828 bool done = !((my_map->SubDet == barrelId) && (my_map->Phi == phi));
829 while ( !done && (it != GCM.end()) )
830 {
831
832
833 if ( (my_map->FEid == "1BS_1BL") || (my_map->FEid == "1FS_1FL") )
834 rings |= 1;
835 else if ( (my_map->FEid == "2BS_2BL1") || (my_map->FEid == "2FS_2FL1") )
836 rings |= 2;
837 else if ( (my_map->FEid == "2BL2_3BL1") || (my_map->FEid == "2FL2_3FL1") )
838 rings |= 3;
839 else if ( (my_map->FEid == "3BL2") || (my_map->FEid == "3BS") ||
840 (my_map->FEid == "3FL2") || (my_map->FEid == "3FS") )
841 rings |= 4;
842
843 ++it;
844
845 if ( it != GCM.end() )
846 {
847 my_map = *it;
848 done = !((my_map->SubDet == barrelId) && (my_map->Phi == phi));
849 }
850
851 }
852
853
854 int phiModule = phi;
855
856 for (int ring = 0; ring < m_numberOfRings; ++ring)
857 {
858 if ( (ring == 0) && ((1<<ring) & rings) ) // Module Type 1
859 {
860 for (int layer = 0; layer < m_numberOfLayersA; ++layer)
861 {
862 Identifier id = m_TRTHelper->layer_id(barrelId, phiModule,
863 ring, layer);
864
865 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
866 {
867 ids.push_back(idHash);
868 }
869 else
870 ATH_MSG_FATAL( " Unable to get hash for id " << m_TRTHelper->show_to_string(id) );
871 }
872 }
873 else if ( (ring == 1) && ((1<<ring) & rings) ) // Module Type 2
874 {
875 for (int layer = 0; layer < m_numberOfLayersB; ++layer)
876 {
877 Identifier id = m_TRTHelper->layer_id(barrelId, phiModule,
878 ring, layer);
879
880 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
881 {
882 ids.push_back(idHash);
883 }
884 else
885 ATH_MSG_FATAL( " Unable to get hash for id " << m_TRTHelper->show_to_string(id) );
886 }
887 }
888 else if ( (ring == 2) && ((1<<ring) & rings) ) // Module Type 3
889 {
890 for (int layer = 0; layer < m_numberOfLayersC; ++layer)
891 {
892 Identifier id = m_TRTHelper->layer_id(barrelId, phiModule,
893 ring, layer);
894
895 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
896 {
897 ids.push_back(idHash);
898 }
899 else
900 ATH_MSG_FATAL( " Unable to get hash for id " << m_TRTHelper->show_to_string(id) );
901
902 }
903 }
904 }
905 }
906 else // End cap
907 {
908 int StartWheel=0;
909 int EndWheel=0;
910 int StartLayer=0;
911 int EndLayer=0;
912
913 int phiModule = phi;
914
915 bool done = !((my_map->SubDet == barrelId) && (my_map->Phi == phi));
916 while ( !done && (it != GCM.end()) )
917 {
918
919 if ( (my_map->FEid == "ec_rod1l") ||
920 (my_map->FEid == "ec_rod1r") )
921 {
922 StartWheel = 0;
923 EndWheel = 4;
924 StartLayer = 0;
925 EndLayer = 16;
926 }
927 else if ( (my_map->FEid == "ec_rod2l") ||
928 (my_map->FEid == "ec_rod2r") )
929 {
930 StartWheel = 4;
931 EndWheel = 6;
932 StartLayer = 0;
933 EndLayer = 16;
934 }
935 else if ( (my_map->FEid == "ec_rod3l") ||
936 (my_map->FEid == "ec_rod3r") )
937 {
938 StartWheel = 6;
939 EndWheel = 14;
940 StartLayer = 0;
941 EndLayer = 8;
942 }
943 else
944 {
945 ATH_MSG_ERROR( "Invalid my_map->FEid. This should not happen!" );
946 return;
947 }
948
949 ++it;
950
951 if ( it != GCM.end() )
952 {
953 my_map = *it;
954 done = !((my_map->SubDet == barrelId) && (my_map->Phi == phi));
955 }
956
957 }
958
959
960 for (int wheel = StartWheel; wheel < EndWheel; wheel++ )
961 {
962 for (int layer = StartLayer; layer < EndLayer; layer++ )
963 {
964 Identifier id = m_TRTHelper->layer_id( barrelId, phiModule,
965 wheel, layer);
966
967 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
968 {
969 ids.push_back(idHash);
970 }
971 else
972 ATH_MSG_FATAL( " Unable to get hash for id " << m_TRTHelper->show_to_string(id) );
973 } // loop over layer
974 } // loop over wheel
975 } // endcap
976 }
977
978 return;
979}
980
981/*
982 * Get ROBIDs for each Detector Element (Straw Layer)
983 *
984 * Input : Straw ID
985 * Output: list of ROB Source IDs
986 */
987std::vector<uint32_t> TRT_FillCablingData_SR1::getRobID(Identifier id) const
988{
989 std::vector<uint32_t> v;
990
991
992 int id_barrel_ec = m_TRTHelper->barrel_ec(id);
993 int id_phi_module = m_TRTHelper->phi_module(id);
994 // int id_layer = m_TRTHelper->layer_or_wheel(id);
995
996 /*
997 * It seems to be assumed that the ROD/ROB source IDs are aligned to
998 * the phi sector numbering. This is NOT the case for SR1, so we
999 * need to fix it up.
1000 * In addition, for Module type 3 (ie, layer 2), we need to read out
1001 * the ROB with the 3S boards (number 1), as well as the ROB with
1002 * the rest of the sector.
1003 * We assume only one side here.
1004 */
1005
1006 id_phi_module = id_phi_module + 32 * id_barrel_ec;
1007
1008 const auto& it = m_phi_to_source.find (id_phi_module);
1009 if (it != m_phi_to_source.end()) {
1010 for (u_int32_t thisId : it->second) {
1011 eformat::helper::SourceIdentifier sid( thisId );
1012 v.push_back(sid.code());
1013 }
1014 }
1015
1016 return v;
1017}
1018
1019
1020
1021/*
1022 * Sort Global Cable Map by ROD Group
1023 */
1024static
1025bool greater_RG_GCM( const GlobalCableMap_t *a, const GlobalCableMap_t *b )
1026{
1027 return ( a->RODGroup > b->RODGroup );
1028}
1029
1030/*
1031 * Sort Global Cable Map by phi
1032 */
1033static
1035{
1036 return ( a->Phi > b->Phi );
1037}
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static bool greater_Phi_GCM(const GlobalCableMap_t *a, const GlobalCableMap_t *b)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
This is a "hash" representation of an Identifier.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
TRT_FillCablingData_SR1(const std::string &type, const std::string &name, const IInterface *parent)
std::map< int, int > m_2BL2_3BL1_map
std::map< int, int > m_1FS_1FL_map
std::vector< int > m_numberOfStrawsInLayers
std::map< int, int > m_1BS_1BL_map
void fillCollID(uint32_t rob_id, std::vector< IdentifierHash > &ids)
std::map< int, int > m_2FL2_3FL1_map
std::map< int, int > m_2BS_2BL1_map
std::vector< uint32_t > getRobID(Identifier id) const
static const InterfaceID & interfaceID()
std::map< int, int > m_2FS_2FL1_map
std::map< int, std::vector< uint32_t > > m_phi_to_source
std::map< std::string, std::string > parse(const std::string &list)
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TFile * file