47 #include "eformat/SourceIdentifier.h"
52 using eformat::helper::SourceIdentifier;
55 static const InterfaceID IID_ITRT_FillCablingData_DC3
56 (
"TRT_FillCablingData_DC3", 1, 0);
62 m_PartialDetector(false)
64 declareInterface< TRT_FillCablingData_DC3 >(
this );
78 {
return IID_ITRT_FillCablingData_DC3; }
91 return StatusCode::FAILURE;
118 ATH_MSG_INFO(
"TRT_FillCablingData_DC3::initializiation finished" );
121 return StatusCode::SUCCESS;
150 int tmpArray[] = {15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18,
151 18, 18, 18, 18, 19, 19, 19, 18,
152 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21,
153 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 23,
154 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26,
155 26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28,
156 28, 29, 29, 29, 29, 28, -1};
160 while( -1 != tmpArray[
i] )
164 RunningCount += tmpArray[
i];
180 int moduleId, strawLayerId, strawInLayerId;
182 IdentifierHash hashId;
202 dataFile =
"TRT_ROD05_Barrel_A_Map.dat";
211 for (
int ii=0; ii<(120*16); ii++ )
216 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
219 string::size_type loc = thisLine.find(
'#' );
220 if ( loc != string::npos )
222 thisLine.replace( loc, thisLine.length(), 1,
' ' );
224 loc = thisLine.find_first_not_of(
" \t" );
225 if ( loc == string::npos )
229 istringstream
parse( thisLine );
231 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
234 bufferOffset = (120 * DtmChannel) + RodChannel;
251 dataFile =
"TRT_ROD05_Barrel_C_Map.dat";
260 for (
int ii=0; ii<(120*16); ii++ )
265 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
268 string::size_type loc = thisLine.find(
'#' );
269 if ( loc != string::npos )
271 thisLine.replace( loc, thisLine.length(), 1,
' ' );
273 loc = thisLine.find_first_not_of(
" \t" );
274 if ( loc == string::npos )
278 istringstream
parse( thisLine );
280 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
283 bufferOffset = (120 * DtmChannel) + RodChannel;
308 dataFile =
"TRT_ROD05_ECA_LEFT.dat";
317 for (
int ii=0; ii<(16*120); ii++ )
325 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
328 string::size_type loc = thisLine.find(
'#' );
329 if ( loc != string::npos )
331 thisLine.replace( loc, thisLine.length(), 1,
' ' );
333 loc = thisLine.find_first_not_of(
" \t" );
334 if ( loc == string::npos )
338 istringstream
parse( thisLine );
340 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
341 >> rodhalf >> bufferOffset;
349 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
351 if ( (rodhalf < 0) || (rodhalf > 1) )
359 else if ( 1 == rodhalf )
376 dataFile =
"TRT_ROD05_ECA_RIGHT.dat";
385 for (
int ii=0; ii<(16*120); ii++ )
393 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
396 string::size_type loc = thisLine.find(
'#' );
397 if ( loc != string::npos )
399 thisLine.replace( loc, thisLine.length(), 1,
' ' );
401 loc = thisLine.find_first_not_of(
" \t" );
402 if ( loc == string::npos )
406 istringstream
parse( thisLine );
408 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
409 >> rodhalf >> bufferOffset;
417 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
421 else if ( 1 == rodhalf )
440 dataFile =
"TRT_ROD05_ECC_LEFT.dat";
449 for (
int ii=0; ii<(16*120); ii++ )
457 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
460 string::size_type loc = thisLine.find(
'#' );
461 if ( loc != string::npos )
463 thisLine.replace( loc, thisLine.length(), 1,
' ' );
465 loc = thisLine.find_first_not_of(
" \t" );
466 if ( loc == string::npos )
470 istringstream
parse( thisLine );
472 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
473 >> rodhalf >> bufferOffset;
481 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
483 if ( (rodhalf < 0) || (rodhalf > 1) )
491 else if ( 1 == rodhalf )
508 dataFile =
"TRT_ROD05_ECC_RIGHT.dat";
517 for (
int ii=0; ii<(16*120); ii++ )
525 int wheel, dtmaddr, dtmchannel, zlayer, phistraw, rodhalf, strawNumber;
528 string::size_type loc = thisLine.find(
'#' );
529 if ( loc != string::npos )
531 thisLine.replace( loc, thisLine.length(), 1,
' ' );
533 loc = thisLine.find_first_not_of(
" \t" );
534 if ( loc == string::npos )
538 istringstream
parse( thisLine );
540 parse >> wheel >> dtmaddr >> dtmchannel >> zlayer >> phistraw
541 >> rodhalf >> bufferOffset;
549 strawNumber = (zlayer & 0xff) << 8 | (phistraw & 0xff);
553 else if ( 1 == rodhalf )
582 std::ifstream globalInputFile (
file.c_str() );
584 if (!globalInputFile.is_open())
590 while ( !globalInputFile.eof() && !globalInputFile.fail() )
592 std::getline( globalInputFile, thisLine );
594 if ( !thisLine.empty() )
598 string::size_type loc = thisLine.find(
'#' );
599 if ( loc != string::npos )
601 thisLine.replace( loc, thisLine.length(), 1,
' ' );
603 loc = thisLine.find_first_not_of(
" \t" );
604 if ( loc == string::npos )
608 istringstream
parse( thisLine );
610 parse >> std::hex >> SourceId;
612 ATH_MSG_INFO(
"Including Source ID: " << hex << SourceId << dec );
618 globalInputFile.close();
628 IdentifierHash NULLhashId(0);
634 for ( i_barrel=0; i_barrel<2; i_barrel++ )
636 std::map<int, int> con_map;
642 SourceBase = 0x310000;
648 SourceBase = 0x320000;
654 int rodId = SourceBase | ((
Phi+1) << 8);
658 for ( ii=0; ii<(120*16); ii++ )
660 strawNumber = con_map[ii];
662 if ( strawNumber < 0 )
681 ATH_MSG_WARNING(
"Invalid Straw in table (" <<
Phi <<
", " << ii <<
"): " << strawNumber );
696 else if ( strawLayerId <
726 <<
" SubDet = " <<
SubDet \
727 <<
" Phi = " <<
Phi \
728 <<
" Module = " << moduleId \
729 <<
" Layer = " << strawLayerId \
730 <<
" StrInLay = " << strawInLayerId );
745 for ( i_ec=0; i_ec<2; i_ec++ )
752 SourceBase = 0x330000;
758 SourceBase = 0x340000;
764 for ( j=0; j<2; j++ )
767 std::map< int, int > con_map;
780 else if ( my_Phi < 16 )
782 else if ( my_Phi < 24 )
784 else if ( my_Phi < 32 )
791 else if ( my_Phi < 16 )
793 else if ( my_Phi < 24 )
795 else if ( my_Phi < 32 )
807 else if ( my_Phi < 16 )
809 else if ( my_Phi < 24 )
811 else if ( my_Phi < 32 )
818 else if ( my_Phi < 16 )
820 else if ( my_Phi < 24 )
822 else if ( my_Phi < 32 )
836 else if ( my_Phi < 16 )
838 else if ( my_Phi < 24 )
840 else if ( my_Phi < 32 )
847 else if ( my_Phi < 16 )
849 else if ( my_Phi < 24 )
851 else if ( my_Phi < 32 )
856 int rodId = SourceBase | ((my_Phi+1) << 8) | (j+1);
859 for (
i=0;
i<(120*16);
i++ )
862 int BufferLocation =
i;
863 int StrawNumber = con_map[
i];
865 strawLayerId = (StrawNumber >> 8) & 0xff;
866 strawInLayerId = StrawNumber & 0xff;
870 strawInLayerId = 23 - strawInLayerId;
874 if ( (strawInLayerId < 0) || (strawInLayerId > 23 ) )
876 ATH_MSG_WARNING(
i <<
" " << j <<
" " << my_Phi <<
" " << hex << StrawNumber );
885 moduleId = strawLayerId / 8;
888 moduleId = moduleId / 2;
889 strawLayerId = strawLayerId % 16;
894 if ( strawLayerId < 8 )
895 strawLayerId = 7 - strawLayerId;
897 strawLayerId = 15 - (strawLayerId - 8);
900 strawInLayerId = 23 - strawInLayerId;
905 moduleId = moduleId - 6;
906 strawLayerId = strawLayerId % 8;
909 strawLayerId = 7 - strawLayerId;
910 strawInLayerId = 23 - strawInLayerId;
917 moduleId, strawLayerId,
940 <<
" Phi = " << my_Phi \
941 <<
" Module = " << moduleId \
942 <<
" Layer = " << strawLayerId \
943 <<
" StrInLay = " << strawInLayerId );
975 for ( i_barrel=0; i_barrel<2; i_barrel++ )
979 SourceBase = 0x310000;
983 SourceBase = 0x320000;
988 int rodId = SourceBase | ((
Phi+1) << 8);
992 std::vector<IdentifierHash> * vectID =
new std::vector<IdentifierHash>();
995 ATH_MSG_DEBUG(
"Adding Collid for ROB " << std::hex << rodId << std::dec );
1002 for ( i_ec=0; i_ec<2; i_ec++ )
1006 SourceBase = 0x330000;
1010 SourceBase = 0x340000;
1016 for (
z=1;
z<3;
z++ )
1018 int rodId = SourceBase | ((
Phi+1) << 8) |
z;
1022 std::vector<IdentifierHash> * vectID =
new std::vector<IdentifierHash>();
1025 ATH_MSG_DEBUG(
"Adding Collid for ROB " << std::hex << rodId << std::dec );
1043 std::vector<IdentifierHash> &
ids)
1045 IdentifierHash idHash;
1050 phi = ((rob_id >> 8) & 0xff) - 1;
1052 if ( (rob_id & 0xff0000) == 0x310000 )
1056 else if ( (rob_id & 0xff0000) == 0x320000 )
1060 else if ( (rob_id & 0xff0000) == 0x330000 )
1064 else if ( (rob_id & 0xff0000) == 0x340000 )
1071 std::hex << rob_id << std::dec );
1076 if ( abs( barrelId ) == 1 )
1086 ids.push_back(idHash);
1091 " " <<
phi <<
" " << ring <<
" " <<
layer );
1097 int Z = rob_id & 0xf;
1114 LayerInWheel =
Layer % 16;
1119 LayerInWheel =
Layer % 8;
1126 ids.push_back(idHash);
1131 << wheel <<
" " << LayerInWheel );
1147 int moduleId, strawLayerId, strawInLayerId;
1149 IdentifierHash hashId;
1169 dataFile =
"TRT_ROD05_Barrel_A_Map.dat";
1178 while ( getline(
inputFile, thisLine ) )
1180 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
1183 string::size_type loc = thisLine.find(
'#' );
1184 if ( loc != string::npos )
1186 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1188 loc = thisLine.find_first_not_of(
" \t" );
1189 if ( loc == string::npos )
1193 istringstream
parse( thisLine );
1195 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
1198 bufferOffset = (120 * DtmChannel) + RodChannel;
1215 dataFile =
"TRT_ROD05_Barrel_C_Map.dat";
1224 while ( getline(
inputFile, thisLine ) )
1226 int RodChannel, DtmChannel, strawnumber, HWaddr, GolNumber;
1229 string::size_type loc = thisLine.find(
'#' );
1230 if ( loc != string::npos )
1232 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1234 loc = thisLine.find_first_not_of(
" \t" );
1235 if ( loc == string::npos )
1239 istringstream
parse( thisLine );
1241 parse >> RodChannel >> DtmChannel >> strawnumber >> HWaddr >> Board >> GolNumber;
1244 bufferOffset = (120 * DtmChannel) + RodChannel;
1259 #ifdef ENDCAP_TABLES_DEFINED
1266 dataFile =
"TRT_ROD05_EC_LEFT_LOWZ.dat";
1275 while ( getline(
inputFile, thisLine ) )
1277 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1279 string::size_type loc = thisLine.find(
"#" );
1280 if ( loc != string::npos )
1282 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1284 loc = thisLine.find_first_not_of(
" \t" );
1285 if ( loc == string::npos )
1289 istringstream
parse( thisLine );
1291 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1299 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1301 bufferOffset = (120 * DtmChannel) + RodChannel;
1303 m_ec_l1_map[bufferOffset] = strawNumber;
1315 dataFile =
"TRT_ROD05_EC_LEFT_HIGHZ.dat";
1324 while ( getline(
inputFile, thisLine ) )
1326 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1328 string::size_type loc = thisLine.find(
'#' );
1329 if ( loc != string::npos )
1331 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1333 loc = thisLine.find_first_not_of(
" \t" );
1334 if ( loc == string::npos )
1338 istringstream
parse( thisLine );
1340 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1348 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1350 bufferOffset = (120 * DtmChannel) + RodChannel;
1352 m_ec_l2_map[bufferOffset] = strawNumber;
1363 dataFile =
"TRT_ROD05_EC_Right_LOWZ.dat";
1372 while ( getline(
inputFile, thisLine ) )
1374 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1376 string::size_type loc = thisLine.find(
'#' );
1377 if ( loc != string::npos )
1379 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1381 loc = thisLine.find_first_not_of(
" \t" );
1382 if ( loc == string::npos )
1386 istringstream
parse( thisLine );
1388 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1396 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1398 bufferOffset = (120 * DtmChannel) + RodChannel;
1400 m_ec_r1_map[bufferOffset] = strawNumber;
1412 dataFile =
"TRT_ROD05_EC_RIGHT_HIGHZ.dat";
1421 while ( getline(
inputFile, thisLine ) )
1423 int rodgroup, rodline, dtmchannel, strawlayer, strawnumber;
1425 string::size_type loc = thisLine.find(
'#' );
1426 if ( loc != string::npos )
1428 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1430 loc = thisLine.find_first_not_of(
" \t" );
1431 if ( loc == string::npos )
1435 istringstream
parse( thisLine );
1437 parse >> rodgroup >> rodline >> dtmchannel >> strawlayer >> strawnumber;
1445 strawNumber = (strawlayer & 0xff) << 8 | (strawnumber & 0xff);
1447 bufferOffset = (120 * DtmChannel) + RodChannel;
1449 m_ec_r2_map[bufferOffset] = strawNumber;
1473 std::ifstream globalInputFile (
file.c_str() );
1475 if (!globalInputFile.is_open())
1481 while ( !globalInputFile.eof() && !globalInputFile.fail() )
1483 std::getline( globalInputFile, thisLine );
1485 if ( !thisLine.empty() )
1489 string::size_type loc = thisLine.find(
'#' );
1490 if ( loc != string::npos )
1492 thisLine.replace( loc, thisLine.length(), 1,
' ' );
1494 loc = thisLine.find_first_not_of(
" \t" );
1495 if ( loc == string::npos )
1499 istringstream
parse( thisLine );
1501 parse >> std::hex >> SourceId;
1503 ATH_MSG_INFO(
"Including Source ID: " << hex << SourceId << dec );
1509 globalInputFile.close();
1519 IdentifierHash NULLhashId(0);
1525 for ( i_barrel=0; i_barrel<2; i_barrel++ )
1527 std::map<int, int> con_map;
1529 if ( 0 == i_barrel )
1533 SourceBase = 0x310000;
1539 SourceBase = 0x320000;
1545 int rodId = SourceBase | ((
Phi+1) << 8);
1549 for ( ii=0; ii<(120*16); ii++ )
1551 strawNumber = con_map[ii];
1553 if ( strawNumber < 0 )
1587 else if ( strawLayerId <
1617 <<
" SubDet = " <<
SubDet \
1618 <<
" Phi = " <<
Phi \
1619 <<
" Module = " << moduleId \
1620 <<
" Layer = " << strawLayerId \
1621 <<
" StrInLay = " << strawInLayerId );
1636 for ( i_ec=0; i_ec<2; i_ec++ )
1652 SourceBase = 0x330000;
1658 SourceBase = 0x340000;
1664 for ( j=0; j<2; j++ )
1667 int rodId = SourceBase | ((
Phi+1) << 8) | (j+1);
1670 for (
i=0;
i<(120*16);
i++ )
1673 int BufferLocation =
i;
1674 int Straw =
i + (120*16) * j;
1676 strawLayerId =
Straw / 24;
1677 strawInLayerId =
Straw % 24;
1679 moduleId = strawLayerId / 8;
1680 if ( moduleId < 12 )
1682 moduleId = moduleId / 2;
1683 strawLayerId = strawLayerId % 16;
1687 moduleId = moduleId - 6;
1688 strawLayerId = strawLayerId % 8;
1693 moduleId, strawLayerId,
1715 <<
" SubDet = " <<
SubDet \
1716 <<
" Phi = " <<
Phi \
1717 <<
" Module = " << moduleId \
1718 <<
" Layer = " << strawLayerId \
1719 <<
" StrInLay = " << strawInLayerId );
1751 for ( i_barrel=0; i_barrel<2; i_barrel++ )
1753 if ( 0 == i_barrel )
1755 SourceBase = 0x310000;
1759 SourceBase = 0x320000;
1764 int rodId = SourceBase | ((
Phi+1) << 8);
1768 std::vector<IdentifierHash> * vectID =
new std::vector<IdentifierHash>();
1771 ATH_MSG_DEBUG(
"Adding Collid for ROB " << std::hex << rodId << std::dec );
1778 for ( i_ec=0; i_ec<2; i_ec++ )
1782 SourceBase = 0x330000;
1786 SourceBase = 0x340000;
1792 for (
z=1;
z<3;
z++ )
1794 int rodId = SourceBase | ((
Phi+1) << 8) |
z;
1798 std::vector<IdentifierHash> * vectID =
new std::vector<IdentifierHash>();
1801 ATH_MSG_DEBUG(
"Adding Collid for ROB " << std::hex << rodId << std::dec );
1819 std::vector<IdentifierHash> &
ids)
1821 IdentifierHash idHash;
1826 phi = ((rob_id >> 8) & 0xff) - 1;
1828 if ( (rob_id & 0xff0000) == 0x310000 )
1832 else if ( (rob_id & 0xff0000) == 0x320000 )
1836 else if ( (rob_id & 0xff0000) == 0x330000 )
1840 else if ( (rob_id & 0xff0000) == 0x340000 )
1846 ATH_MSG_FATAL(
"fillCollID_broken_FDR: Bad rob_id " << std::hex << rob_id << std::dec );
1851 if ( abs( barrelId ) == 1 )
1861 ids.push_back(idHash);
1866 " " <<
phi <<
" " << ring <<
" " <<
layer );
1882 int Z = rob_id & 0xf;
1910 ATH_MSG_FATAL(
"fillCollID_broken_FDR: Bad rob_id " << std::hex << rob_id << std::dec );
1917 int wheel = StartWheelA;
1918 while ( wheel <= EndWheelA )
1926 ids.push_back(idHash);
1931 << wheel <<
" " <<
layer );
1941 wheel = StartWheelB;
1945 while ( wheel <= EndWheelB )
1953 ids.push_back(idHash);
1958 << wheel <<
" " <<
layer );
1982 std::vector<uint32_t>
v;
1992 if ( (2 == id_barrel_ec) || (-2 == id_barrel_ec) )
2001 if ( 1 == id_barrel_ec )
2003 Source = 0x310000 | ((id_phi_module+1) << 8);
2005 else if ( -1 == id_barrel_ec )
2007 Source = 0x320000 | ((id_phi_module+1) << 8);
2009 else if ( 2 == id_barrel_ec )
2013 else if ( -2 == id_barrel_ec )
2020 if ( 1 == id_barrel_ec )
2022 Source = 0x310000 | ((id_phi_module+1) << 8);
2024 else if ( -1 == id_barrel_ec )
2026 Source = 0x320000 | ((id_phi_module+1) << 8);
2028 else if ( 2 == id_barrel_ec )
2030 Source = 0x330000 | ((id_phi_module+1) << 8) | ((id_layer < 5)?1:2);
2032 else if ( -2 == id_barrel_ec )
2034 Source = 0x340000 | ((id_phi_module+1) << 8) | ((id_layer < 5)?1:2);
2058 eformat::helper::SourceIdentifier sid(
Source );
2059 v.push_back(sid.code());