ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_FillCablingData_DC3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * Implementation file for TRT_FillCablingData_DC3 class.
7 *
8 * NB: This is the case of full ATLAS, without the C wheels, for the ROD05.
9 *
10 * P.T. Keener
11 */
12
13/*
14 * Assumptions:
15 * - The ROD Source IDs give the mapping to the dector:
16 * o Barrel is 3100XX and 3200XX, where XX is the phi sector [1-32]
17 * o EC is 33XX0Y, which XX is the phi sector [1-32] and Y is 1
18 * for the low |Z| wheels and 2 for the high |Z| wheels
19 * + NB: the offline phi sectors are numbered from 0
20 * - We are in the "expanded" mode of ROD05
21 *
22 *
23 * Notes:
24 * - barrel or ec ids
25 * o 310000 is 1 is Barrel A
26 * o 320000 is -1 is Barrel C
27 * o 330000 is 2 is EC A
28 * o 340000 is -2 is EC C
29 *
30 * The m_identifier* and m_collID vectors are indexed by ROB source ID - 1.
31 * The magic mapping between ROB source IDs and phi sector indices is in
32 * getRobID() and in fillCollID(). Everything else should just fall
33 * through and gets the Right Answer.
34 */
35
36#undef ENDCAP_DEFINED
37
38#include <cstdio>
39
40#include <iostream>
42#include <fstream>
43
44#include <functional>
45#include <algorithm>
46
47#include "eformat/SourceIdentifier.h" // change to new eformat v3
49
51
52using eformat::helper::SourceIdentifier;
53using namespace std;
54
55static const InterfaceID IID_ITRT_FillCablingData_DC3
56 ("TRT_FillCablingData_DC3", 1, 0);
57
58 // Constructor
59TRT_FillCablingData_DC3::TRT_FillCablingData_DC3( const std::string& type, const std::string&
60name,const IInterface* parent ): AthAlgTool(type,name,parent),
61 m_TRTHelper(nullptr),
63{
64 declareInterface< TRT_FillCablingData_DC3 >( this );
65
66 declareProperty( "Filename", m_inputFilename="" );
67 declareProperty( "RealData", m_RealData=false );
68
69}
70
71
72 // Destructor
75
76
78{ return IID_ITRT_FillCablingData_DC3; }
79
80
81 // Initialisation
83{
84 ATH_MSG_INFO( "TRT_FillCablingData_DC3::initialize" );
85
86
87 // Get the TRT Helper
88 if (detStore()->retrieve(m_TRTHelper, "TRT_ID").isFailure())
89 {
90 ATH_MSG_FATAL( "Could not get TRT ID helper" );
91 return StatusCode::FAILURE;
92 }
93 m_cntx = m_TRTHelper->straw_layer_context();
94
95
97
98 /*
99 * If we aren't reading real data, use the broken EC A mapping
100 * used for FDR1
101 */
103
104
106
108 {
111 }
112 else
113 {
114 defineTables();
115 defineCollID();
116 }
117
118 ATH_MSG_INFO( "TRT_FillCablingData_DC3::initializiation finished" );
119
120 // return sc;
121 return StatusCode::SUCCESS;
122}
123
124
126{
127
128 delete m_cabling;
129
130 StatusCode sc = AlgTool::finalize();
131 return sc;
132}
133
134
139
140
142{
143 m_numberOfRings = 3;
144
145 m_numberOfLayers[0] = 19;
146 m_numberOfLayers[1] = 24;
147 m_numberOfLayers[2] = 30;
148
149
150 int tmpArray[] = {15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, // Module Type 1
151 18, 18, 18, 18, 19, 19, 19, 18, // Module Type 1
152 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, // Module Type 2
153 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 23, // Module Type 2
154 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, // Module Type 3
155 26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28, // Module Type 3
156 28, 29, 29, 29, 29, 28, -1}; // Module Type 3
157
158 int i=0;
159 int RunningCount=0;
160 while( -1 != tmpArray[i] )
161 {
162 m_StrawsPerLayer.push_back( tmpArray[i] );
163
164 RunningCount += tmpArray[i];
165 m_numberOfStrawsInLayers.push_back( RunningCount );
166
167 i++;
168 }
169 m_numberOfStrawsInLayers.push_back( -1 );
170
171 return;
172}
173
174
175 // Fill Tables with IDs for all straws
177{
178 ATH_MSG_INFO( "In defineTables" );
179
180 int moduleId, strawLayerId, strawInLayerId;
181 Identifier strawID;
182 IdentifierHash hashId;
183
184 uint32_t bufferOffset;
185 string thisLine;
186
187 std::string dataFile;
188 std::string file;
189
190
191
192 /**************************************************************/
193 /* Barrel Tables */
194 /**************************************************************/
195
196 /*
197 * Barrel A side sectors
198 */
199 {
200 ATH_MSG_INFO( "defineTables: Barrel A " );
201
202 dataFile = "TRT_ROD05_Barrel_A_Map.dat";
203 file = PathResolver::find_file (dataFile, "DATAPATH");
204 std::ifstream inputFile ( file.c_str() );
205
206 if (!inputFile.is_open())
207 {
208 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
209 }
210
211 for ( int ii=0; ii<(120*16); ii++ )
212 m_barrel_a_map[ii] = -1;
213
214 while ( getline( inputFile, thisLine ) )
215 {
216 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
217 string Board;
218
219 string::size_type loc = thisLine.find( '#' );
220 if ( loc != string::npos )
221 {
222 thisLine.replace( loc, thisLine.length(), 1, ' ' );
223
224 loc = thisLine.find_first_not_of( " \t" );
225 if ( loc == string::npos )
226 continue;
227 }
228
229 istringstream parse( thisLine );
230
231 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
232
233
234 bufferOffset = (120 * DtmChannel) + RodChannel;
235
236 m_barrel_a_map[bufferOffset] = strawnumber;
237
238 // cout << "Fill, Read BA, " << bufferOffset << " " << strawnumber << endl;
239 }
240
241 inputFile.close();
242 }
243
244
245 /*
246 * Barrel C side sectors
247 */
248 {
249 ATH_MSG_INFO( "defineTables: Barrel C " );
250
251 dataFile = "TRT_ROD05_Barrel_C_Map.dat";
252 file = PathResolver::find_file (dataFile, "DATAPATH");
253 std::ifstream inputFile ( file.c_str() );
254
255 if (!inputFile.is_open())
256 {
257 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
258 }
259
260 for ( int ii=0; ii<(120*16); ii++ )
261 m_barrel_c_map[ii] = -1;
262
263 while ( getline( inputFile, thisLine ) )
264 {
265 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
266 string Board;
267
268 string::size_type loc = thisLine.find( '#' );
269 if ( loc != string::npos )
270 {
271 thisLine.replace( loc, thisLine.length(), 1, ' ' );
272
273 loc = thisLine.find_first_not_of( " \t" );
274 if ( loc == string::npos )
275 continue;
276 }
277
278 istringstream parse( thisLine );
279
280 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
281
282
283 bufferOffset = (120 * DtmChannel) + RodChannel;
284
285 m_barrel_c_map[bufferOffset] = strawnumber;
286 }
287
288 inputFile.close();
289 }
290
291
292
293
294 /**************************************************************/
295 /* Endcap Tables */
296 /**************************************************************/
297
298 /* *********** */
299 /* * ECA * */
300 /* *********** */
301
302 {
303 /*
304 * Left sectors
305 */
306 ATH_MSG_INFO( "defineTables: ECA Left " );
307
308 dataFile = "TRT_ROD05_ECA_LEFT.dat";
309 file = PathResolver::find_file (dataFile, "DATAPATH");
310 std::ifstream inputFile( file.c_str() );
311
312 if (!inputFile.is_open())
313 {
314 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
315 }
316
317 for ( int ii=0; ii<(16*120); ii++ )
318 {
319 m_eca_l0_map[ii] = -1;
320 m_eca_l1_map[ii] = -1;
321 }
322
323 while ( getline( inputFile, thisLine ) )
324 {
325 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
326
327
328 string::size_type loc = thisLine.find( '#' );
329 if ( loc != string::npos )
330 {
331 thisLine.replace( loc, thisLine.length(), 1, ' ' );
332
333 loc = thisLine.find_first_not_of( " \t" );
334 if ( loc == string::npos )
335 continue;
336 }
337
338 istringstream parse( thisLine );
339
340 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
341 >> rodhalf >> bufferOffset;
342
343 /*
344 * HACK! We do not have a good straw numbering scheme for the endcap
345 * and we do not yet have enough info to produce a real offline
346 * identifier. So we make something up!
347 */
348
349 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
350
351 if ( (rodhalf < 0) || (rodhalf > 1) )
352 {
353 ATH_MSG_WARNING( "Invalid rod half: " << rodhalf );
354 std::abort();
355 }
356
357 if ( 0 == rodhalf )
358 m_eca_l0_map[bufferOffset] = strawNumber;
359 else if ( 1 == rodhalf )
360 m_eca_l1_map[bufferOffset] = strawNumber;
361
362 // ATH_MSG_INFO( "Fill LEFT " << rodhalf << " " << bufferOffset << " " << strawNumber );
363 }
364
365 inputFile.close();
366 }
367
368
369
370 {
371 /*
372 * Right sectors
373 */
374 ATH_MSG_INFO( "defineTables: ECA Right " );
375
376 dataFile = "TRT_ROD05_ECA_RIGHT.dat";
377 file = PathResolver::find_file (dataFile, "DATAPATH");
378 std::ifstream inputFile( file.c_str() );
379
380 if (!inputFile.is_open())
381 {
382 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
383 }
384
385 for ( int ii=0; ii<(16*120); ii++ )
386 {
387 m_eca_r0_map[ii] = -1;
388 m_eca_r1_map[ii] = -1;
389 }
390
391 while ( getline( inputFile, thisLine ) )
392 {
393 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
394
395
396 string::size_type loc = thisLine.find( '#' );
397 if ( loc != string::npos )
398 {
399 thisLine.replace( loc, thisLine.length(), 1, ' ' );
400
401 loc = thisLine.find_first_not_of( " \t" );
402 if ( loc == string::npos )
403 continue;
404 }
405
406 istringstream parse( thisLine );
407
408 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
409 >> rodhalf >> bufferOffset;
410
411 /*
412 * HACK! We do not have a good straw numbering scheme for the endcap
413 * and we do not yet have enough info to produce a real offline
414 * identifier. So we make something up!
415 */
416
417 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
418
419 if ( 0 == rodhalf )
420 m_eca_r0_map[bufferOffset] = strawNumber;
421 else if ( 1 == rodhalf )
422 m_eca_r1_map[bufferOffset] = strawNumber;
423
424 // ATH_MSG_INFO( "Fill RIGHT " << rodhalf << " " << bufferOffset << " " << strawNumber );
425 }
426
427 inputFile.close();
428 }
429
430 /* *********** */
431 /* * ECC * */
432 /* *********** */
433
434 {
435 /*
436 * Left sectors
437 */
438 ATH_MSG_INFO( "defineTables: ECC Left " );
439
440 dataFile = "TRT_ROD05_ECC_LEFT.dat";
441 file = PathResolver::find_file (dataFile, "DATAPATH");
442 std::ifstream inputFile( file.c_str() );
443
444 if (!inputFile.is_open())
445 {
446 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
447 }
448
449 for ( int ii=0; ii<(16*120); ii++ )
450 {
451 m_ecc_l0_map[ii] = -1;
452 m_ecc_l1_map[ii] = -1;
453 }
454
455 while ( getline( inputFile, thisLine ) )
456 {
457 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
458
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 istringstream parse( thisLine );
471
472 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
473 >> rodhalf >> bufferOffset;
474
475 /*
476 * HACK! We do not have a good straw numbering scheme for the endcap
477 * and we do not yet have enough info to produce a real offline
478 * identifier. So we make something up!
479 */
480
481 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
482
483 if ( (rodhalf < 0) || (rodhalf > 1) )
484 {
485 ATH_MSG_WARNING( "Invalid rod half: " << rodhalf );
486 std::abort();
487 }
488
489 if ( 0 == rodhalf )
490 m_ecc_l0_map[bufferOffset] = strawNumber;
491 else if ( 1 == rodhalf )
492 m_ecc_l1_map[bufferOffset] = strawNumber;
493
494 // ATH_MSG_INFO( "Fill LEFT " << rodhalf << " " << bufferOffset << " " << strawNumber );
495 }
496
497 inputFile.close();
498 }
499
500
501
502 {
503 /*
504 * Right sectors
505 */
506 ATH_MSG_INFO( "defineTables: ECC Right " );
507
508 dataFile = "TRT_ROD05_ECC_RIGHT.dat";
509 file = PathResolver::find_file (dataFile, "DATAPATH");
510 std::ifstream inputFile( file.c_str() );
511
512 if (!inputFile.is_open())
513 {
514 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
515 }
516
517 for ( int ii=0; ii<(16*120); ii++ )
518 {
519 m_ecc_r0_map[ii] = -1;
520 m_ecc_r1_map[ii] = -1;
521 }
522
523 while ( getline( inputFile, thisLine ) )
524 {
525 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
526
527
528 string::size_type loc = thisLine.find( '#' );
529 if ( loc != string::npos )
530 {
531 thisLine.replace( loc, thisLine.length(), 1, ' ' );
532
533 loc = thisLine.find_first_not_of( " \t" );
534 if ( loc == string::npos )
535 continue;
536 }
537
538 istringstream parse( thisLine );
539
540 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
541 >> rodhalf >> bufferOffset;
542
543 /*
544 * HACK! We do not have a good straw numbering scheme for the endcap
545 * and we do not yet have enough info to produce a real offline
546 * identifier. So we make something up!
547 */
548
549 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
550
551 if ( 0 == rodhalf )
552 m_ecc_r0_map[bufferOffset] = strawNumber;
553 else if ( 1 == rodhalf )
554 m_ecc_r1_map[bufferOffset] = strawNumber;
555
556 // ATH_MSG_INFO( "Fill RIGHT " << rodhalf << " " << bufferOffset << " " << strawNumber );
557 }
558
559 inputFile.close();
560 }
561
562
563
564
565 /**************************************************************/
566 /* Global Cabling Specification */
567 /**************************************************************/
568
569 ATH_MSG_INFO( "defineTables: Global Spec " );
570
571 if ( string(m_inputFilename.value()) != "" )
572 {
573 ATH_MSG_INFO( "User defined SourceID list: " << m_inputFilename.value() );
574
575 m_PartialDetector = true;
576
577 dataFile = string(m_inputFilename.value());
578 // dataFile = "TRT_Global_Cabling.dat";
579
580 file = PathResolver::find_file (dataFile, "DATAPATH");
581
582 std::ifstream globalInputFile ( file.c_str() );
583
584 if (!globalInputFile.is_open())
585 {
586 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
587 }
588
589
590 while ( !globalInputFile.eof() && !globalInputFile.fail() )
591 {
592 std::getline( globalInputFile, thisLine );
593
594 if ( !thisLine.empty() )
595 {
596 uint32_t SourceId;
597
598 string::size_type loc = thisLine.find( '#' );
599 if ( loc != string::npos )
600 {
601 thisLine.replace( loc, thisLine.length(), 1, ' ' );
602
603 loc = thisLine.find_first_not_of( " \t" );
604 if ( loc == string::npos )
605 continue;
606 }
607
608 istringstream parse( thisLine );
609
610 parse >> std::hex >> SourceId;
611
612 ATH_MSG_INFO( "Including Source ID: " << hex << SourceId << dec );
613
614 m_validSourceIds.insert( SourceId );
615 }
616 }
617
618 globalInputFile.close();
619
620 }
621 // else
622 // {
623 // ATH_MSG_INFO( "Default (complete) SourceID list" );
624 // }
625
626
627 Identifier NULLstrawID(0);
628 IdentifierHash NULLhashId(0);
629
630 int i_barrel;
631 int SubDet;
632 int SourceBase;
633
634 for ( i_barrel=0; i_barrel<2; i_barrel++ ) // Loop over A,C sides of barrel
635 {
636 std::map<int, int> con_map;
637
638 if ( 0 == i_barrel )
639 {
640 con_map = m_barrel_a_map;
641 SubDet = 1;
642 SourceBase = 0x310000;
643 }
644 else
645 {
646 con_map = m_barrel_c_map;
647 SubDet = -1;
648 SourceBase = 0x320000;
649 }
650
651 int Phi;
652 for ( Phi=0; Phi<32; Phi++ )
653 {
654 int rodId = SourceBase | ((Phi+1) << 8);
655 int ii;
656 int strawNumber;
657
658 for ( ii=0; ii<(120*16); ii++ )
659 {
660 strawNumber = con_map[ii];
661
662 if ( strawNumber < 0 )
663 {
664 m_cabling->set_identifierForAllStraws( rodId, ii, NULLstrawID );
665 m_cabling->set_identifierHashForAllStraws( rodId, ii, NULLhashId );
666 continue;
667 }
668
669 /*
670 * Calculate strawLayerId
671 */
672 strawLayerId = 0;
673 while ( (m_numberOfStrawsInLayers[strawLayerId] <= strawNumber) &&
674 (m_numberOfStrawsInLayers[strawLayerId] != -1) )
675 {
676 strawLayerId++;
677 }
678
679 if ( m_numberOfStrawsInLayers[strawLayerId] == -1 )
680 {
681 ATH_MSG_WARNING( "Invalid Straw in table (" << Phi << ", " << ii << "): " << strawNumber );
682 continue;
683 }
684
685 strawInLayerId = m_numberOfStrawsInLayers[strawLayerId] - strawNumber - 1;
686
687
688 moduleId = -1;
689 if ( strawLayerId < m_numberOfLayers[0] )
690 moduleId = 0;
691 else if ( strawLayerId < (m_numberOfLayers[0] + m_numberOfLayers[1]) )
692 {
693 moduleId = 1;
694 strawLayerId = strawLayerId - m_numberOfLayers[0];
695 }
696 else if ( strawLayerId <
698 {
699 moduleId = 2;
700 strawLayerId = strawLayerId - (m_numberOfLayers[0] + m_numberOfLayers[1]);
701 }
702 else
703 ATH_MSG_ERROR( "Bad calculated module!" );
704
705
706 strawID = m_TRTHelper->straw_id( SubDet, Phi, moduleId, strawLayerId, strawInLayerId );
707
708
709// cout << "Fill -> " << hex << rodId << " " << dec << ii << " "
710// << strawNumber << " "
711// << SubDet << " " << Phi << " " << moduleId << " "
712// << strawLayerId << " " << strawInLayerId << " " << std::hex
713// << strawID << std::dec << endl;
714
715 m_cabling->set_identifierForAllStraws( rodId, ii, strawID );
716
717
718 Identifier Lid = m_TRTHelper->layer_id( SubDet, Phi, moduleId, strawLayerId );
719
720 int result = m_TRTHelper->get_hash( Lid, hashId, &m_cntx );
721 if ( result != 0 )
722 {
723 ATH_MSG_WARNING( ">>>>>>>>>>> Get Hash FAILED! <<<<<<<<<<" );
725 " array = " << m_numberOfStrawsInLayers[strawLayerId] \
726 << " SubDet = " << SubDet \
727 << " Phi = " << Phi \
728 << " Module = " << moduleId \
729 << " Layer = " << strawLayerId \
730 << " StrInLay = " << strawInLayerId );
731 }
732
733
734 m_cabling->set_identifierHashForAllStraws( rodId, ii, hashId );
735
736 }
737
738 } // Loop over phi
739 } // Loop over barrel A,C
740
741
742 int i_ec;
743 int Phi;
744
745 for ( i_ec=0; i_ec<2; i_ec++ ) // Loop over A,C sides of EndCap
746 {
747
748 if ( 0 == i_ec ) // A side
749 {
750 //con_map = m_barrel_a_map;
751 SubDet = 2;
752 SourceBase = 0x330000;
753 }
754 else // C side
755 {
756 //con_map = m_barrel_c_map;
757 SubDet = -2;
758 SourceBase = 0x340000;
759 }
760
761 for ( Phi=0; Phi<32; Phi++ )
762 {
763 int j;
764 for ( j=0; j<2; j++ ) // Inner vs outer Z RODs
765 {
766 int my_Phi;
767 std::map< int, int > con_map;
768
769 if ( 2 == SubDet ) // A side
770 {
771 // my_Phi = (32 + 15 - Phi) % 32;
772 my_Phi = Phi;
773
775 {
776 if ( 0 == j )
777 {
778 if ( my_Phi < 8 )
779 con_map = m_ecc_r0_map;
780 else if ( my_Phi < 16 )
781 con_map = m_ecc_l0_map;
782 else if ( my_Phi < 24 )
783 con_map = m_ecc_r0_map;
784 else if ( my_Phi < 32 )
785 con_map = m_ecc_l0_map;
786 }
787 else if ( 1 == j )
788 {
789 if ( my_Phi < 8 )
790 con_map = m_ecc_r1_map;
791 else if ( my_Phi < 16 )
792 con_map = m_ecc_l1_map;
793 else if ( my_Phi < 24 )
794 con_map = m_ecc_r1_map;
795 else if ( my_Phi < 32 )
796 con_map = m_ecc_l1_map;
797
798 }
799 }
800 else // Correct ECA cabling
801 {
802
803 if ( 0 == j )
804 {
805 if ( my_Phi < 8 )
806 con_map = m_eca_r0_map;
807 else if ( my_Phi < 16 )
808 con_map = m_eca_l0_map;
809 else if ( my_Phi < 24 )
810 con_map = m_eca_r0_map;
811 else if ( my_Phi < 32 )
812 con_map = m_eca_l0_map;
813 }
814 else if ( 1 == j )
815 {
816 if ( my_Phi < 8 )
817 con_map = m_eca_r1_map;
818 else if ( my_Phi < 16 )
819 con_map = m_eca_l1_map;
820 else if ( my_Phi < 24 )
821 con_map = m_eca_r1_map;
822 else if ( my_Phi < 32 )
823 con_map = m_eca_l1_map;
824 }
825
826 }
827 }
828 else // C side
829 {
830 my_Phi = Phi;
831
832 if ( 0 == j )
833 {
834 if ( my_Phi < 8 )
835 con_map = m_ecc_l0_map;
836 else if ( my_Phi < 16 )
837 con_map = m_ecc_r0_map;
838 else if ( my_Phi < 24 )
839 con_map = m_ecc_l0_map;
840 else if ( my_Phi < 32 )
841 con_map = m_ecc_r0_map;
842 }
843 else if ( 1 == j )
844 {
845 if ( my_Phi < 8 )
846 con_map = m_ecc_l1_map;
847 else if ( my_Phi < 16 )
848 con_map = m_ecc_r1_map;
849 else if ( my_Phi < 24 )
850 con_map = m_ecc_l1_map;
851 else if ( my_Phi < 32 )
852 con_map = m_ecc_r1_map;
853 }
854 }
855
856 int rodId = SourceBase | ((my_Phi+1) << 8) | (j+1);
857
858 int i;
859 for ( i=0; i<(120*16); i++ ) // loop over buffer offset
860 {
861
862 int BufferLocation = i;
863 int StrawNumber = con_map[i];
864
865 strawLayerId = (StrawNumber >> 8) & 0xff;
866 strawInLayerId = StrawNumber & 0xff;
867
868 if ( m_broken_FDR_Cabling && 2 == SubDet ) // A side
869 {
870 strawInLayerId = 23 - strawInLayerId;
871 }
872
873
874 if ( (strawInLayerId < 0) || (strawInLayerId > 23 ) )
875 {
876 ATH_MSG_WARNING( i << " " << j << " " << my_Phi << " " << hex << StrawNumber );
877
878 std::abort();
879 }
880
881
882 m_StrawLayerToRod[strawLayerId] = j+1;
883
884
885 moduleId = strawLayerId / 8;
886 if ( moduleId < 12 ) // A wheel?
887 {
888 moduleId = moduleId / 2;
889 strawLayerId = strawLayerId % 16;
890
891 if ( (-2 == SubDet) && ! m_broken_FDR_Cabling ) // ECC
892 {
893 /* Flip local Z */
894 if ( strawLayerId < 8 )
895 strawLayerId = 7 - strawLayerId;
896 else
897 strawLayerId = 15 - (strawLayerId - 8);
898
899 /* Flip local Phi */
900 strawInLayerId = 23 - strawInLayerId;
901 }
902 }
903 else // B wheel
904 {
905 moduleId = moduleId - 6;
906 strawLayerId = strawLayerId % 8;
907 if ( (-2 == SubDet) && ! m_broken_FDR_Cabling ) // ECC
908 {
909 strawLayerId = 7 - strawLayerId; // Flip local Z
910 strawInLayerId = 23 - strawInLayerId; // Flip local Phi
911 }
912 }
913
914
915
916 strawID = m_TRTHelper->straw_id( SubDet, my_Phi,
917 moduleId, strawLayerId,
918 strawInLayerId );
919
920
921 m_cabling->set_identifierForAllStraws( rodId, BufferLocation,
922 strawID );
923
924
925 // IdLayer = m_TRTHelper->layer_id( strawID );
926
927 // int result = m_TRTHelper->get_hash( strawID, hashId, &m_cntx );
928
929 Identifier Lid = m_TRTHelper->layer_id( SubDet,
930 my_Phi, moduleId,
931 strawLayerId );
932
933 int result = m_TRTHelper->get_hash( Lid, hashId, &m_cntx );
934 if ( result != 0 )
935 {
936 ATH_MSG_WARNING( ">>>>>>>>>>> Get Hash FAILED! <<<<<<<<<<" );
937
939 " SubDet = " << SubDet \
940 << " Phi = " << my_Phi \
941 << " Module = " << moduleId \
942 << " Layer = " << strawLayerId \
943 << " StrInLay = " << strawInLayerId );
944 }
945
946
947 m_cabling->set_identifierHashForAllStraws( rodId,
948 BufferLocation,
949 hashId );
950 } // loop over bufferOffsets
951 } // loop over inner, outer Z RODs
952 } // Endcap
953 } // loop over GCM
954
955
956 ATH_MSG_INFO( "Out of defineTables" );
957
958 return;
959}
960
961/*
962 * Define map of collection IDs for all ROBs
963 */
965{
966 int Phi;
967 int i_barrel;
968 int i_ec;
969 int SourceBase;
970
971 ATH_MSG_INFO( "In defineCollID()" );
972
973
974
975 for ( i_barrel=0; i_barrel<2; i_barrel++ ) // Loop over A,C sides of barrel
976 {
977 if ( 0 == i_barrel )
978 {
979 SourceBase = 0x310000;
980 }
981 else
982 {
983 SourceBase = 0x320000;
984 }
985
986 for ( Phi=0; Phi<32; Phi++ )
987 {
988 int rodId = SourceBase | ((Phi+1) << 8);
989
990 m_cabling->add_allRobs( rodId );
991
992 std::vector<IdentifierHash> * vectID = new std::vector<IdentifierHash>();
993 fillCollID( rodId, *vectID);
994
995 ATH_MSG_DEBUG( "Adding Collid for ROB " << std::hex << rodId << std::dec );
996
997 m_cabling->add_collID( rodId, vectID);
998 }
999 }
1000
1001
1002 for ( i_ec=0; i_ec<2; i_ec++ ) // Loop over A,C sides of barrel
1003 {
1004 if ( 0 == i_ec )
1005 {
1006 SourceBase = 0x330000;
1007 }
1008 else
1009 {
1010 SourceBase = 0x340000;
1011 }
1012
1013 for ( Phi=0; Phi<32; Phi++ )
1014 {
1015 int z;
1016 for ( z=1; z<3; z++ )
1017 {
1018 int rodId = SourceBase | ((Phi+1) << 8) | z;
1019
1020 m_cabling->add_allRobs( rodId );
1021
1022 std::vector<IdentifierHash> * vectID = new std::vector<IdentifierHash>();
1023 fillCollID( rodId, *vectID);
1024
1025 ATH_MSG_DEBUG( "Adding Collid for ROB " << std::hex << rodId << std::dec );
1026
1027 m_cabling->add_collID( rodId, vectID);
1028 }
1029 }
1030 }
1031
1032
1033
1034 return;
1035}
1036
1037
1038/*
1039 * Input: ROB Source ID
1040 * Output: List of Hash IDs, one for each of 73 layers
1041 */
1043std::vector<IdentifierHash> & ids)
1044{
1045 IdentifierHash idHash;
1046
1047 int phi;
1048 int barrelId;
1049
1050 phi = ((rob_id >> 8) & 0xff) - 1;
1051
1052 if ( (rob_id & 0xff0000) == 0x310000 )
1053 {
1054 barrelId = 1;
1055 }
1056 else if ( (rob_id & 0xff0000) == 0x320000 )
1057 {
1058 barrelId = -1;
1059 }
1060 else if ( (rob_id & 0xff0000) == 0x330000 )
1061 {
1062 barrelId = 2;
1063 }
1064 else if ( (rob_id & 0xff0000) == 0x340000 )
1065 {
1066 barrelId = -2;
1067 }
1068 else
1069 {
1070 ATH_MSG_FATAL( "fillCollID: Bad rob_id " <<
1071 std::hex << rob_id << std::dec );
1072 return;
1073 }
1074
1075
1076 if ( abs( barrelId ) == 1 ) // barrel?
1077 {
1078 for (int ring = 0; ring < m_numberOfRings; ++ring)
1079 {
1080 for (int layer = 0; layer < m_numberOfLayers[ring]; ++layer)
1081 {
1082 Identifier id = m_TRTHelper->layer_id(barrelId, phi, ring, layer);
1083
1084 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
1085 {
1086 ids.push_back(idHash);
1087 }
1088 else
1089 ATH_MSG_FATAL( " Unable to get hash for id "
1090 << m_TRTHelper->print_to_string(id) << " -- " << std::hex << rob_id << std::dec <<
1091 " " << phi << " " << ring << " " << layer );
1092 } // Loop over layers
1093 } // Loop over module types
1094 } // Loop over barrel A,C
1095 else // End cap
1096 {
1097 int Z = rob_id & 0xf;
1098
1099
1100 int Layer;
1101 int wheel;
1102 int LayerInWheel;
1103
1104 for ( Layer=0; Layer<160; Layer++ ) // 160 Layers in the EC
1105 {
1106 if ( m_StrawLayerToRod[Layer] != Z )
1107 continue;
1108
1109
1110 wheel = Layer / 8;
1111 if ( wheel < 12 ) // A wheel?
1112 {
1113 wheel = wheel / 2;
1114 LayerInWheel = Layer % 16;
1115 }
1116 else // B wheel
1117 {
1118 wheel = wheel - 6;
1119 LayerInWheel = Layer % 8;
1120 }
1121
1122 Identifier id = m_TRTHelper->layer_id( barrelId, phi, wheel, LayerInWheel );
1123
1124 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
1125 {
1126 ids.push_back(idHash);
1127 }
1128 else
1129 ATH_MSG_FATAL( " EC: Unable to get hash for id "
1130 << m_TRTHelper->show_to_string(id) << " " << barrelId << " " << phi << " "
1131 << wheel << " " << LayerInWheel );
1132 } // loop over layer
1133
1134
1135 } // endcap
1136
1137 return;
1138}
1139
1140
1141
1142 // Fill Tables with IDs for all straws
1144{
1145 ATH_MSG_INFO( "In defineTables_broken_FDR" );
1146
1147 int moduleId, strawLayerId, strawInLayerId;
1148 Identifier strawID;
1149 IdentifierHash hashId;
1150
1151 uint32_t bufferOffset;
1152 string thisLine;
1153
1154 std::string dataFile;
1155 std::string file;
1156
1157
1158
1159 /**************************************************************/
1160 /* Barrel Tables */
1161 /**************************************************************/
1162
1163 /*
1164 * Barrel A side sectors
1165 */
1166 {
1167 ATH_MSG_INFO( "defineTables: Barrel A " );
1168
1169 dataFile = "TRT_ROD05_Barrel_A_Map.dat";
1170 file = PathResolver::find_file (dataFile, "DATAPATH");
1171 std::ifstream inputFile ( file.c_str() );
1172
1173 if (!inputFile.is_open())
1174 {
1175 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1176 }
1177
1178 while ( getline( inputFile, thisLine ) )
1179 {
1180 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
1181 string Board;
1182
1183 string::size_type loc = thisLine.find( '#' );
1184 if ( loc != string::npos )
1185 {
1186 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1187
1188 loc = thisLine.find_first_not_of( " \t" );
1189 if ( loc == string::npos )
1190 continue;
1191 }
1192
1193 istringstream parse( thisLine );
1194
1195 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
1196
1197
1198 bufferOffset = (120 * DtmChannel) + RodChannel;
1199
1200 m_barrel_a_map[bufferOffset] = strawnumber;
1201
1202 // cout << "Fill, Read BA, " << bufferOffset << " " << strawnumber << endl;
1203 }
1204
1205 inputFile.close();
1206 }
1207
1208
1209 /*
1210 * Barrel C side sectors
1211 */
1212 {
1213 ATH_MSG_INFO( "defineTables: Barrel C " );
1214
1215 dataFile = "TRT_ROD05_Barrel_C_Map.dat";
1216 file = PathResolver::find_file (dataFile, "DATAPATH");
1217 std::ifstream inputFile ( file.c_str() );
1218
1219 if (!inputFile.is_open())
1220 {
1221 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1222 }
1223
1224 while ( getline( inputFile, thisLine ) )
1225 {
1226 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
1227 string Board;
1228
1229 string::size_type loc = thisLine.find( '#' );
1230 if ( loc != string::npos )
1231 {
1232 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1233
1234 loc = thisLine.find_first_not_of( " \t" );
1235 if ( loc == string::npos )
1236 continue;
1237 }
1238
1239 istringstream parse( thisLine );
1240
1241 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
1242
1243
1244 bufferOffset = (120 * DtmChannel) + RodChannel;
1245
1246 m_barrel_c_map[bufferOffset] = strawnumber;
1247 }
1248
1249 inputFile.close();
1250 }
1251
1252
1253
1254
1255 /**************************************************************/
1256 /* Endcap Tables */
1257 /**************************************************************/
1258
1259#ifdef ENDCAP_TABLES_DEFINED
1260
1261 /*
1262 * Left sectors, layers 0-79
1263 */
1264 ATH_MSG_INFO( "defineTables: EC Left low |Z| " );
1265
1266 dataFile = "TRT_ROD05_EC_LEFT_LOWZ.dat";
1267 file = PathResolver::find_file (dataFile, "DATAPATH");
1268 inputFile.open( file.c_str() );
1269
1270 if (!inputFile.is_open())
1271 {
1272 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1273 }
1274
1275 while ( getline( inputFile, thisLine ) )
1276 {
1277 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1278
1279 string::size_type loc = thisLine.find( "#" );
1280 if ( loc != string::npos )
1281 {
1282 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1283
1284 loc = thisLine.find_first_not_of( " \t" );
1285 if ( loc == string::npos )
1286 continue;
1287 }
1288
1289 istringstream parse( thisLine );
1290
1291 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1292
1293 /*
1294 * HACK! We do not have a good straw numbering scheme for the endcap
1295 * and we do not yet have enough info to produce a real offline
1296 * identifier. So we make something up!
1297 */
1298
1299 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1300
1301 bufferOffset = (120 * DtmChannel) + RodChannel;
1302
1303 m_ec_l1_map[bufferOffset] = strawNumber;
1304 }
1305
1306 inputFile.close();
1307
1308
1309
1310 /*
1311 * Left sectors, layers 80-159
1312 */
1313 ATH_MSG_INFO( "defineTables: EC Left high |Z| " );
1314
1315 dataFile = "TRT_ROD05_EC_LEFT_HIGHZ.dat";
1316 file = PathResolver::find_file (dataFile, "DATAPATH");
1317 inputFile.open( file.c_str() );
1318
1319 if (!inputFile.is_open())
1320 {
1321 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1322 }
1323
1324 while ( getline( inputFile, thisLine ) )
1325 {
1326 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1327
1328 string::size_type loc = thisLine.find( '#' );
1329 if ( loc != string::npos )
1330 {
1331 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1332
1333 loc = thisLine.find_first_not_of( " \t" );
1334 if ( loc == string::npos )
1335 continue;
1336 }
1337
1338 istringstream parse( thisLine );
1339
1340 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1341
1342 /*
1343 * HACK! We do not have a good straw numbering scheme for the endcap
1344 * and we do not yet have enough info to produce a real offline
1345 * identifier. So we make something up!
1346 */
1347
1348 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1349
1350 bufferOffset = (120 * DtmChannel) + RodChannel;
1351
1352 m_ec_l2_map[bufferOffset] = strawNumber;
1353 }
1354
1355 inputFile.close();
1356
1357
1358 /*
1359 * Right sectors, layers 0-79
1360 */
1361 ATH_MSG_INFO( "defineTables: EC Right low |Z| " );
1362
1363 dataFile = "TRT_ROD05_EC_Right_LOWZ.dat";
1364 file = PathResolver::find_file (dataFile, "DATAPATH");
1365 inputFile.open( file.c_str() );
1366
1367 if (!inputFile.is_open())
1368 {
1369 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1370 }
1371
1372 while ( getline( inputFile, thisLine ) )
1373 {
1374 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1375
1376 string::size_type loc = thisLine.find( '#' );
1377 if ( loc != string::npos )
1378 {
1379 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1380
1381 loc = thisLine.find_first_not_of( " \t" );
1382 if ( loc == string::npos )
1383 continue;
1384 }
1385
1386 istringstream parse( thisLine );
1387
1388 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1389
1390 /*
1391 * HACK! We do not have a good straw numbering scheme for the endcap
1392 * and we do not yet have enough info to produce a real offline
1393 * identifier. So we make something up!
1394 */
1395
1396 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1397
1398 bufferOffset = (120 * DtmChannel) + RodChannel;
1399
1400 m_ec_r1_map[bufferOffset] = strawNumber;
1401 }
1402
1403 inputFile.close();
1404
1405
1406
1407 /*
1408 * Right sectors, layers 80-159
1409 */
1410 ATH_MSG_INFO( "defineTables: EC Right high |Z| " );
1411
1412 dataFile = "TRT_ROD05_EC_RIGHT_HIGHZ.dat";
1413 file = PathResolver::find_file (dataFile, "DATAPATH");
1414 inputFile.open( file.c_str() );
1415
1416 if (!inputFile.is_open())
1417 {
1418 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1419 }
1420
1421 while ( getline( inputFile, thisLine ) )
1422 {
1423 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1424
1425 string::size_type loc = thisLine.find( '#' );
1426 if ( loc != string::npos )
1427 {
1428 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1429
1430 loc = thisLine.find_first_not_of( " \t" );
1431 if ( loc == string::npos )
1432 continue;
1433 }
1434
1435 istringstream parse( thisLine );
1436
1437 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1438
1439 /*
1440 * HACK! We do not have a good straw numbering scheme for the endcap
1441 * and we do not yet have enough info to produce a real offline
1442 * identifier. So we make something up!
1443 */
1444
1445 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1446
1447 bufferOffset = (120 * DtmChannel) + RodChannel;
1448
1449 m_ec_r2_map[bufferOffset] = strawNumber;
1450 }
1451
1452 inputFile.close();
1453
1454#endif /* ENDCAP_TABLES_DEFINED */
1455
1456
1457 /**************************************************************/
1458 /* Global Cabling Specification */
1459 /**************************************************************/
1460
1461 ATH_MSG_INFO( "defineTables: Global Spec " );
1462
1463 if ( string(m_inputFilename.value()) != "" )
1464 {
1465 ATH_MSG_INFO( "User defined SourceID list: " << m_inputFilename.value() );
1466
1467 m_PartialDetector = true;
1468
1469 dataFile = string(m_inputFilename.value());
1470
1471 file = PathResolver::find_file (dataFile, "DATAPATH");
1472
1473 std::ifstream globalInputFile ( file.c_str() );
1474
1475 if (!globalInputFile.is_open())
1476 {
1477 ATH_MSG_FATAL( "TRT_FillCablingData_DC3: Could not open file " << dataFile );
1478 }
1479
1480
1481 while ( !globalInputFile.eof() && !globalInputFile.fail() )
1482 {
1483 std::getline( globalInputFile, thisLine );
1484
1485 if ( !thisLine.empty() )
1486 {
1487 uint32_t SourceId;
1488
1489 string::size_type loc = thisLine.find( '#' );
1490 if ( loc != string::npos )
1491 {
1492 thisLine.replace( loc, thisLine.length(), 1, ' ' );
1493
1494 loc = thisLine.find_first_not_of( " \t" );
1495 if ( loc == string::npos )
1496 continue;
1497 }
1498
1499 istringstream parse( thisLine );
1500
1501 parse >> std::hex >> SourceId;
1502
1503 ATH_MSG_INFO( "Including Source ID: " << hex << SourceId << dec );
1504
1505 m_validSourceIds.insert( SourceId );
1506 }
1507 }
1508
1509 globalInputFile.close();
1510
1511 }
1512 else
1513 {
1514 ATH_MSG_INFO( "Default (complete) SourceID list" );
1515 }
1516
1517
1518 Identifier NULLstrawID(0);
1519 IdentifierHash NULLhashId(0);
1520
1521 int i_barrel;
1522 int SubDet;
1523 int SourceBase;
1524
1525 for ( i_barrel=0; i_barrel<2; i_barrel++ ) // Loop over A,C sides of barrel
1526 {
1527 std::map<int, int> con_map;
1528
1529 if ( 0 == i_barrel )
1530 {
1531 con_map = m_barrel_a_map;
1532 SubDet = 1;
1533 SourceBase = 0x310000;
1534 }
1535 else
1536 {
1537 con_map = m_barrel_c_map;
1538 SubDet = -1;
1539 SourceBase = 0x320000;
1540 }
1541
1542 int Phi;
1543 for ( Phi=0; Phi<32; Phi++ )
1544 {
1545 int rodId = SourceBase | ((Phi+1) << 8);
1546 int ii;
1547 int strawNumber;
1548
1549 for ( ii=0; ii<(120*16); ii++ )
1550 {
1551 strawNumber = con_map[ii];
1552
1553 if ( strawNumber < 0 )
1554 {
1555 m_cabling->set_identifierForAllStraws( rodId, ii, NULLstrawID );
1556 m_cabling->set_identifierHashForAllStraws( rodId, ii, NULLhashId );
1557 continue;
1558 }
1559
1560 /*
1561 * Calculate strawLayerId
1562 */
1563 strawLayerId = 0;
1564 while ( (m_numberOfStrawsInLayers[strawLayerId] <= strawNumber) &&
1565 (m_numberOfStrawsInLayers[strawLayerId] != -1) )
1566 {
1567 strawLayerId++;
1568 }
1569
1570 if ( m_numberOfStrawsInLayers[strawLayerId] == -1 )
1571 {
1572 ATH_MSG_WARNING( "Invalid Straw in table: " << strawNumber );
1573 continue;
1574 }
1575
1576 strawInLayerId = m_numberOfStrawsInLayers[strawLayerId] - strawNumber - 1;
1577
1578
1579 moduleId = -1;
1580 if ( strawLayerId < m_numberOfLayers[0] )
1581 moduleId = 0;
1582 else if ( strawLayerId < (m_numberOfLayers[0] + m_numberOfLayers[1]) )
1583 {
1584 moduleId = 1;
1585 strawLayerId = strawLayerId - m_numberOfLayers[0];
1586 }
1587 else if ( strawLayerId <
1589 {
1590 moduleId = 2;
1591 strawLayerId = strawLayerId - (m_numberOfLayers[0] + m_numberOfLayers[1]);
1592 }
1593 else
1594 ATH_MSG_ERROR( "Bad calculated module!" );
1595
1596
1597 strawID = m_TRTHelper->straw_id( SubDet, Phi, moduleId, strawLayerId, strawInLayerId );
1598
1599
1600// cout << "Fill -> " << hex << rodId << " " << dec << ii << " "
1601// << strawNumber << " "
1602// << SubDet << " " << Phi << " " << moduleId << " "
1603// << strawLayerId << " " << strawInLayerId << " " << std::hex
1604// << strawID << std::dec << endl;
1605
1606 m_cabling->set_identifierForAllStraws( rodId, ii, strawID );
1607
1608
1609 Identifier Lid = m_TRTHelper->layer_id( SubDet, Phi, moduleId, strawLayerId );
1610
1611 int result = m_TRTHelper->get_hash( Lid, hashId, &m_cntx );
1612 if ( result != 0 )
1613 {
1614 ATH_MSG_WARNING( ">>>>>>>>>>> Get Hash FAILED! <<<<<<<<<<" );
1616 " array = " << m_numberOfStrawsInLayers[strawLayerId] \
1617 << " SubDet = " << SubDet \
1618 << " Phi = " << Phi \
1619 << " Module = " << moduleId \
1620 << " Layer = " << strawLayerId \
1621 << " StrInLay = " << strawInLayerId );
1622 }
1623
1624
1625 m_cabling->set_identifierHashForAllStraws( rodId, ii, hashId );
1626
1627 }
1628
1629 } // Loop over phi
1630 } // Loop over barrel A,C
1631
1632
1633 int i_ec;
1634 int Phi;
1635
1636 for ( i_ec=0; i_ec<2; i_ec++ ) // Loop over A,C sides of EndCap
1637 {
1638
1639
1640 /*
1641 * XXX XXX XXX XXX XXX XXX XXX XXX
1642 *
1643 * This is a complete hack to get *some* mapping for the EndCap. It will be
1644 * replaced by the real mapping once it is figured out.
1645 *
1646 * XXX XXX XXX XXX XXX XXX XXX XXX
1647 */
1648 if ( 0 == i_ec ) // A side
1649 {
1650 //con_map = m_barrel_a_map;
1651 SubDet = 2;
1652 SourceBase = 0x330000;
1653 }
1654 else // C side
1655 {
1656 //con_map = m_barrel_c_map;
1657 SubDet = -2;
1658 SourceBase = 0x340000;
1659 }
1660
1661 for ( Phi=0; Phi<32; Phi++ )
1662 {
1663 int j;
1664 for ( j=0; j<2; j++ ) // Inner vs outer Z RODs
1665 {
1666
1667 int rodId = SourceBase | ((Phi+1) << 8) | (j+1);
1668
1669 int i;
1670 for ( i=0; i<(120*16); i++ ) // loop over buffer offset
1671 {
1672
1673 int BufferLocation = i;
1674 int Straw = i + (120*16) * j; // XXX - Hack. This is FAKE FAKE FAKE!
1675
1676 strawLayerId = Straw / 24; // 24 straws per layer
1677 strawInLayerId = Straw % 24;
1678
1679 moduleId = strawLayerId / 8;
1680 if ( moduleId < 12 ) // A wheel?
1681 {
1682 moduleId = moduleId / 2;
1683 strawLayerId = strawLayerId % 16;
1684 }
1685 else // B wheel
1686 {
1687 moduleId = moduleId - 6;
1688 strawLayerId = strawLayerId % 8;
1689 }
1690
1691
1692 strawID = m_TRTHelper->straw_id( SubDet, Phi,
1693 moduleId, strawLayerId,
1694 strawInLayerId );
1695
1696
1697 m_cabling->set_identifierForAllStraws( rodId, BufferLocation,
1698 strawID );
1699
1700
1701 // IdLayer = m_TRTHelper->layer_id( strawID );
1702
1703 // int result = m_TRTHelper->get_hash( strawID, hashId, &m_cntx );
1704
1705 Identifier Lid = m_TRTHelper->layer_id( SubDet,
1706 Phi, moduleId,
1707 strawLayerId );
1708
1709 int result = m_TRTHelper->get_hash( Lid, hashId, &m_cntx );
1710 if ( result != 0 )
1711 {
1712 ATH_MSG_WARNING( ">>>>>>>>>>> Get Hash FAILED! <<<<<<<<<<" );
1713
1714 ATH_MSG_WARNING( "Straw = " << Straw \
1715 << " SubDet = " << SubDet \
1716 << " Phi = " << Phi \
1717 << " Module = " << moduleId \
1718 << " Layer = " << strawLayerId \
1719 << " StrInLay = " << strawInLayerId );
1720 }
1721
1722
1723 m_cabling->set_identifierHashForAllStraws( rodId,
1724 BufferLocation,
1725 hashId );
1726 } // loop over bufferOffsets
1727 } // loop over inner, outer Z RODs
1728 } // Endcap
1729 } // loop over GCM
1730
1731
1732 ATH_MSG_INFO( "Out of defineTables_broken_FDR" );
1733
1734 return;
1735}
1736
1737/*
1738 * Define map of collection IDs for all ROBs
1739 */
1741{
1742 int Phi;
1743 int i_barrel;
1744 int i_ec;
1745 int SourceBase;
1746
1747 ATH_MSG_INFO( "In defineCollID_broken_FDR()" );
1748
1749
1750
1751 for ( i_barrel=0; i_barrel<2; i_barrel++ ) // Loop over A,C sides of barrel
1752 {
1753 if ( 0 == i_barrel )
1754 {
1755 SourceBase = 0x310000;
1756 }
1757 else
1758 {
1759 SourceBase = 0x320000;
1760 }
1761
1762 for ( Phi=0; Phi<32; Phi++ )
1763 {
1764 int rodId = SourceBase | ((Phi+1) << 8);
1765
1766 m_cabling->add_allRobs( rodId );
1767
1768 std::vector<IdentifierHash> * vectID = new std::vector<IdentifierHash>();
1769 fillCollID_broken_FDR( rodId, *vectID);
1770
1771 ATH_MSG_DEBUG( "Adding Collid for ROB " << std::hex << rodId << std::dec );
1772
1773 m_cabling->add_collID( rodId, vectID);
1774 }
1775 }
1776
1777
1778 for ( i_ec=0; i_ec<2; i_ec++ ) // Loop over A,C sides of barrel
1779 {
1780 if ( 0 == i_ec )
1781 {
1782 SourceBase = 0x330000;
1783 }
1784 else
1785 {
1786 SourceBase = 0x340000;
1787 }
1788
1789 for ( Phi=0; Phi<32; Phi++ )
1790 {
1791 int z;
1792 for ( z=1; z<3; z++ )
1793 {
1794 int rodId = SourceBase | ((Phi+1) << 8) | z;
1795
1796 m_cabling->add_allRobs( rodId );
1797
1798 std::vector<IdentifierHash> * vectID = new std::vector<IdentifierHash>();
1799 fillCollID_broken_FDR( rodId, *vectID);
1800
1801 ATH_MSG_DEBUG( "Adding Collid for ROB " << std::hex << rodId << std::dec );
1802
1803 m_cabling->add_collID( rodId, vectID);
1804 }
1805 }
1806 }
1807
1808
1809
1810 return;
1811}
1812
1813
1814/*
1815 * Input: ROB Source ID
1816 * Output: List of Hash IDs, one for each of 73 layers
1817 */
1819std::vector<IdentifierHash> & ids)
1820{
1821 IdentifierHash idHash;
1822
1823 int phi;
1824 int barrelId;
1825
1826 phi = ((rob_id >> 8) & 0xff) - 1;
1827
1828 if ( (rob_id & 0xff0000) == 0x310000 )
1829 {
1830 barrelId = 1;
1831 }
1832 else if ( (rob_id & 0xff0000) == 0x320000 )
1833 {
1834 barrelId = -1;
1835 }
1836 else if ( (rob_id & 0xff0000) == 0x330000 )
1837 {
1838 barrelId = 2;
1839 }
1840 else if ( (rob_id & 0xff0000) == 0x340000 )
1841 {
1842 barrelId = -2;
1843 }
1844 else
1845 {
1846 ATH_MSG_FATAL( "fillCollID_broken_FDR: Bad rob_id " << std::hex << rob_id << std::dec );
1847 return;
1848 }
1849
1850
1851 if ( abs( barrelId ) == 1 ) // barrel?
1852 {
1853 for (int ring = 0; ring < m_numberOfRings; ++ring)
1854 {
1855 for (int layer = 0; layer < m_numberOfLayers[ring]; ++layer)
1856 {
1857 Identifier id = m_TRTHelper->layer_id(barrelId, phi, ring, layer);
1858
1859 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
1860 {
1861 ids.push_back(idHash);
1862 }
1863 else
1864 ATH_MSG_FATAL( " Unable to get hash for id " \
1865 << m_TRTHelper->print_to_string(id) << " -- " << std::hex << rob_id << std::dec << \
1866 " " << phi << " " << ring << " " << layer );
1867 } // Loop over layers
1868 } // Loop over module types
1869 } // Loop over barrel A,C
1870 else // End cap
1871 {
1872 int StartWheelA;
1873 int EndWheelA;
1874 int StartLayerA;
1875 int EndLayerA;
1876
1877 int StartWheelB;
1878 int EndWheelB;
1879 int StartLayerB;
1880 int EndLayerB;
1881
1882 int Z = rob_id & 0xf;
1883
1884 if ( 1 == Z )
1885 {
1886 StartWheelA = 0;
1887 EndWheelA = 4;
1888 StartLayerA = 0;
1889 EndLayerA = 15;
1890
1891 StartWheelB = 0;
1892 EndWheelB = 0;
1893 StartLayerB = 0;
1894 EndLayerB = 0;
1895 }
1896 else if ( 2 == Z )
1897 {
1898 StartWheelA = 5;
1899 EndWheelA = 5;
1900 StartLayerA = 0;
1901 EndLayerA = 15;
1902
1903 StartWheelB = 6;
1904 EndWheelB = 13;
1905 StartLayerB = 0;
1906 EndLayerB = 7;
1907 }
1908 else
1909 {
1910 ATH_MSG_FATAL( "fillCollID_broken_FDR: Bad rob_id " << std::hex << rob_id << std::dec );
1911 return;
1912 }
1913
1914 /*
1915 * A wheels
1916 */
1917 int wheel = StartWheelA;
1918 while ( wheel <= EndWheelA )
1919 {
1920 for (int layer = StartLayerA; layer <= EndLayerA; layer++ )
1921 {
1922 Identifier id = m_TRTHelper->layer_id( barrelId, phi, wheel, layer);
1923
1924 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
1925 {
1926 ids.push_back(idHash);
1927 }
1928 else
1929 ATH_MSG_FATAL( " A: Unable to get hash for id " \
1930 << m_TRTHelper->show_to_string(id) << " " << barrelId << " " << phi << " " \
1931 << wheel << " " << layer );
1932 } // loop over layer
1933
1934 wheel++;
1935 } // loop over wheelA
1936
1937
1938 /*
1939 * B wheels
1940 */
1941 wheel = StartWheelB;
1942 if ( 0 == wheel )
1943 return;
1944
1945 while ( wheel <= EndWheelB )
1946 {
1947 for (int layer = StartLayerB; layer <= EndLayerB; layer++ )
1948 {
1949 Identifier id = m_TRTHelper->layer_id( barrelId, phi, wheel, layer);
1950
1951 if (!m_TRTHelper->get_hash(id, idHash, &m_cntx))
1952 {
1953 ids.push_back(idHash);
1954 }
1955 else
1956 ATH_MSG_FATAL( " B: Unable to get hash for id " \
1957 << m_TRTHelper->show_to_string(id) << " " << barrelId << " " << phi << " " \
1958 << wheel << " " << layer );
1959 } // loop over layer
1960
1961 wheel++;
1962 } // loop over wheelB
1963
1964 } // endcap
1965
1966 return;
1967}
1968
1969
1970
1971
1972
1973
1974/*
1975 * Get ROBIDs for each Detector Element (Straw Layer)
1976 *
1977 * Input : Straw ID
1978 * Output: list of ROB Source IDs
1979 */
1980std::vector<uint32_t> TRT_FillCablingData_DC3::getRobID(Identifier id) const
1981{
1982 std::vector<uint32_t> v;
1983 uint32_t Source=0;
1984
1985 int id_barrel_ec = m_TRTHelper->barrel_ec(id);
1986 int id_phi_module = m_TRTHelper->phi_module(id);
1987 int id_layer = m_TRTHelper->layer_or_wheel(id);
1988
1989 if ( !m_broken_FDR_Cabling )
1990 {
1991 int strawLayer=0;
1992 if ( (2 == id_barrel_ec) || (-2 == id_barrel_ec) )
1993 {
1994 if ( id_layer < 6 )
1995 strawLayer = id_layer * 2 * 8 + m_TRTHelper->straw_layer(id);
1996 else
1997 strawLayer = 6 * 16 + (id_layer - 6) * 8 + m_TRTHelper->straw_layer(id);
1998 }
1999
2000
2001 if ( 1 == id_barrel_ec )
2002 {
2003 Source = 0x310000 | ((id_phi_module+1) << 8);
2004 }
2005 else if ( -1 == id_barrel_ec )
2006 {
2007 Source = 0x320000 | ((id_phi_module+1) << 8);
2008 }
2009 else if ( 2 == id_barrel_ec )
2010 {
2011 Source = 0x330000 | ((id_phi_module+1) << 8) | m_StrawLayerToRod[strawLayer];
2012 }
2013 else if ( -2 == id_barrel_ec )
2014 {
2015 Source = 0x340000 | ((id_phi_module+1) << 8) | m_StrawLayerToRod[strawLayer];
2016 }
2017 }
2018 else // broken_FDR_Cabling
2019 {
2020 if ( 1 == id_barrel_ec )
2021 {
2022 Source = 0x310000 | ((id_phi_module+1) << 8);
2023 }
2024 else if ( -1 == id_barrel_ec )
2025 {
2026 Source = 0x320000 | ((id_phi_module+1) << 8);
2027 }
2028 else if ( 2 == id_barrel_ec )
2029 {
2030 Source = 0x330000 | ((id_phi_module+1) << 8) | ((id_layer < 5)?1:2);
2031 }
2032 else if ( -2 == id_barrel_ec )
2033 {
2034 Source = 0x340000 | ((id_phi_module+1) << 8) | ((id_layer < 5)?1:2);
2035 }
2036 }
2037
2038 if ( m_PartialDetector )
2039 {
2040 // ATH_MSG_WARNING( "Running in Partial Detector Mode" );
2041
2042 std::set< uint32_t >::iterator pos;
2043 pos = m_validSourceIds.find( Source );
2044 if ( pos == m_validSourceIds.end() )
2045 {
2046 // ATH_MSG_WARNING( "Returning 0 instead of " << hex << Source << dec );
2047
2048 return v;
2049 }
2050 else
2051 {
2052 // ATH_MSG_WARNING( "Returning " << hex << Source << dec );
2053 }
2054
2055 }
2056
2057
2058 eformat::helper::SourceIdentifier sid( Source );
2059 v.push_back(sid.code());
2060
2061 return v;
2062}
2063
2064
2065
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)
#define ATH_MSG_DEBUG(x)
#define z
Define macros for attributes used to control the static checker.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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)
static const InterfaceID & interfaceID()
std::map< int, int > m_eca_l0_map
std::map< int, int > m_ecc_r1_map
void fillCollID_broken_FDR(uint32_t rob_id, std::vector< IdentifierHash > &ids)
std::map< int, int > m_eca_r0_map
std::map< int, int > m_eca_l1_map
TRT_FillCablingData_DC3(const std::string &type, const std::string &name, const IInterface *parent)
std::map< int, int > m_ecc_l0_map
std::map< int, int > m_eca_r1_map
std::map< int, int > m_barrel_c_map
std::vector< uint32_t > getRobID(Identifier id) const
std::map< int, int > m_barrel_a_map
std::set< uint32_t > m_validSourceIds
std::map< int, int > m_ecc_l1_map
std::map< int, int > m_ecc_r0_map
void fillCollID(uint32_t rob_id, std::vector< IdentifierHash > &ids)
std::vector< int > m_numberOfStrawsInLayers
std::map< std::string, std::string > parse(const std::string &list)
STL namespace.
TFile * file