16 #include "CaloDetDescr/CaloDetDescrElement.h" 
   32   , m_cablingService(nullptr)
 
   36   declareProperty(
"CablingType", 
m_cablingType = -9, 
"Cabling type: -1 - testbeam, 0 - old simulation, 1 - without MBTS, 2 - with MBTS instead of crack scin, 3 - MBTS in spare channels, 4 - RUN2 cabling, 5 - RUN2a cabling");
 
   48   m_cablingService = cablingService;
 
   49   if (!m_cablingService) {
 
   51     return StatusCode::FAILURE;
 
   61   const TileID* tileID(
nullptr);
 
   77   if (m_connectedDrawers.size() > 1) {
 
   87     for (
unsigned int dr = 1; 
dr < m_connectedDrawers.size(); 
dr += 2) {
 
   88       int frag1 = std::strtol(m_connectedDrawers[
dr - 1].
data(), 
nullptr, 0);
 
   89       int frag2 = std::strtol(m_connectedDrawers[
dr].
data(), 
nullptr, 0);
 
   90       for (
int frag = frag1; frag <= frag2; ++frag) {
 
   93         if (
ros >= 1 && ros < 5 && drawer >= 0 && 
drawer < 64) {
 
  126   SmartIF<IGeoModelSvc> geoModel{service(
"GeoModelSvc")};
 
  131     std::string atlasVersion = geoModel->atlasVersion();
 
  132     int ctb = atlasVersion.compare(0, 9, 
"ATLAS-CTB");
 
  133     int geo  = atlasVersion.compare(0,9,
"ATLAS-GEO");
 
  134     int run1 = atlasVersion.compare(0,8,
"ATLAS-R1");
 
  135     int ibl  = atlasVersion.compare(0,9,
"ATLAS-IBL");
 
  136     int run2 = atlasVersion.compare(0,8,
"ATLAS-R2");
 
  137     int run3 = atlasVersion.compare(0,8,
"ATLAS-R3");
 
  138     int run4 = atlasVersion.compare(0,13,
"ATLAS-P2-RUN4");
 
  139     int upg  = atlasVersion.compare(0,7,
"ATLAS-P") ;
 
  140     int comm = atlasVersion.compare(0,10,
"ATLAS-Comm");
 
  142     bool upgradeA = (tileID->
cell_hash_max() == MAX_TILE_CELLS_UPGRADEA);
 
  143     bool upgradeBC = (tileID->
cell_hash_max() == MAX_TILE_CELLS_UPGRADEBC);
 
  144     bool upgradeABC = (tileID->
cell_hash_max() == MAX_TILE_CELLS_UPGRADEABC);
 
  156       ATH_MSG_INFO( 
"RUN2 ATLAS geometry flag detected for geometry: " << atlasVersion );
 
  158         ATH_MSG_INFO( 
"RUN2 ATLAS UpgradeA geometry flag detected for geometry: " << atlasVersion );
 
  160       } 
else if (upgradeBC) {
 
  161         ATH_MSG_INFO( 
"RUN2 ATLAS UpgradeBC geometry flag detected for geometry: " << atlasVersion );
 
  163       } 
else if (upgradeABC) {
 
  164         ATH_MSG_INFO( 
"RUN2 ATLAS UpgradeABC geometry flag detected for geometry: " << atlasVersion );
 
  168           ATH_MSG_INFO( 
"Cabling for RUN2 (2014-2017) ATLAS geometry is set via jobOptions " );
 
  170           ATH_MSG_INFO( 
"Cabling for RUN2a (2018) ATLAS geometry is set via jobOptions " );
 
  175           ATH_MSG_INFO( 
"Using cabling type " << m_cablingType << 
" from jobOptions " );
 
  181       ATH_MSG_INFO( 
"RUN3 ATLAS geometry flag detected for geometry: " << atlasVersion );
 
  183         ATH_MSG_INFO( 
"Cabling for RUN3 ATLAS geometry is set via jobOptions " );
 
  188         ATH_MSG_INFO( 
"Using cabling type " << m_cablingType << 
" from jobOptions " );
 
  193       ATH_MSG_INFO( 
"RUN4 ATLAS geometry flag detected for geometry: " << atlasVersion );
 
  195         ATH_MSG_INFO( 
"Cabling for RUN3 ATLAS geometry is set via jobOptions " );
 
  200         ATH_MSG_INFO( 
"Using cabling type " << m_cablingType << 
" from jobOptions " );
 
  204       ATH_MSG_INFO( 
"Cabling for RUN3 ATLAS geometry is set via jobOptions " );
 
  206       ATH_MSG_INFO( 
"Cabling for RUN2 (2014-2017) ATLAS geometry is set via jobOptions " );
 
  208       ATH_MSG_INFO( 
"Cabling for RUN2a (2018) ATLAS geometry is set via jobOptions " );
 
  209     }  
else if (ctb == 0) {
 
  210       ATH_MSG_INFO( 
"CTB geometry detected: " << atlasVersion );
 
  212     } 
else if (
geo == 0 || 
run1 == 0 || ibl == 0 || 
run2 == 0 || upg == 0) {
 
  213       ATH_MSG_INFO( 
"RUN1 ATLAS geometry detected: " << atlasVersion );
 
  215     } 
else if (
comm == 0) {
 
  216       ATH_MSG_INFO( 
"RUN1 ATLAS Commissioning geometry detected: " << atlasVersion );
 
  219       ATH_MSG_WARNING( 
"Old ATLAS geometry detected - most probably it's a mistake: " << atlasVersion );
 
  228   ATH_MSG_INFO( 
"Setting Cabling type to " << m_cablingType );
 
  230   ATH_MSG_DEBUG( 
"Maximum number of gains: " <<  m_cablingService->getMaxChannels());
 
  235   if (
m_detStore->retrieve(tileMgr).isFailure()) {
 
  236     ATH_MSG_WARNING( 
"Unable to retrieve TileDetDescrManager from DetectorStore" );
 
  237     ATH_MSG_WARNING( 
"Will not set Tile online hash ID in CaloDetDescrElements" );
 
  252         bool disconnected = 
true;
 
  255           HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  258           disconnected &= (
id2 != id1);
 
  260         if (disconnected) m_disconnectedCells.push_back(cell_id);
 
  264             && (pmtHash[0] != oldPmtHash[0] || pmtHash[1] != oldPmtHash[1])) {
 
  267                           << 
" id= " << tileID->
to_string(cell_id, -2)
 
  268                           << 
" from (" << oldPmtHash[0] << 
"," << oldPmtHash[1]
 
  269                           << 
") to (" << pmtHash[0] << 
"," << pmtHash[1] << 
")" );
 
  294     ATH_MSG_VERBOSE( 
"Total: " << m_disconnectedCells.size() << 
" disconnected cells");
 
  300     std::cout << 
"===============================" << std::endl;
 
  309             std::cout << 
" hw1=" << tileHWID->
to_string(hwid1, -1);
 
  310             Identifier id1 = m_cablingService->h2s_pmt_id(hwid1);
 
  312               std::cout << 
" id1=" << tileID->
to_string(id1, -1);
 
  313               HWIdentifier hwid2 = m_cablingService->s2h_channel_id(id1);
 
  315                 if (hwid2 != hwid1) std::cout << 
" hw1!=hw2=" << tileHWID->
to_string(hwid2, -1);
 
  319                     std::cout << 
" id1!=id2=" << tileID->
to_string(
id2, -1);
 
  321                       std::cout << ((tileTBID->
eta(id1)>1) ? 
" E4'" : 
" MBTS");
 
  325                   if (drIdx1 != drIdx2) {
 
  326                     std::cout << 
"  ERROR in drawer index " << drIdx1 << 
" != " << drIdx2
 
  328                         << std::hex << 
" 0x" << hwid1 << 
" 0x" 
  331                     std::cout << 
"  drawer index " << drIdx2;
 
  334                   std::cout << 
" id2=invalid";
 
  337                 std::cout << 
" hw2=invalid";
 
  340               std::cout << 
" id1=invalid";
 
  343             std::cout << 
" hw1=invalid";
 
  345           std::cout << std::endl;
 
  351     std::cout << 
"=== D4 cells in special EB ====" << std::endl;
 
  353     int d4module[4] = { 14, 15, 18, 19 };
 
  355       for (
int imod = 0; imod < 4; ++imod) {
 
  356         int module = d4module[imod] - 1;
 
  361             std::cout << 
" id1=" << tileID->
to_string(id1, -1);
 
  362             HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  364               std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  367                 if (
id2 != id1) std::cout << 
" id1!=id2=" << tileID->
to_string(
id2, -1);
 
  370                   if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  372                   std::cout << 
" hw2=invalid";
 
  375                 std::cout << 
" id2=invalid";
 
  378               std::cout << 
" hw1=invalid";
 
  381             std::cout << 
" id1=invalid";
 
  383           std::cout << std::endl;
 
  389     std::cout << 
"=== C10 cells in special EB ===" << std::endl;
 
  391     int c10module[8] = { 39, 40, 41, 42, 55, 56, 57, 58 };
 
  393       for (
int imod = 0; imod < 8; ++imod) {
 
  394         int module = c10module[imod] - 1;
 
  399             std::cout << 
" id1=" << tileID->
to_string(id1, -1);
 
  400             HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  402               std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  405                 if (
id2 != id1) std::cout << 
" id1!=id2=" << tileID->
to_string(
id2, -1);
 
  408                   if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  410                   std::cout << 
" hw2=invalid";
 
  413                 std::cout << 
" id2=invalid";
 
  416               std::cout << 
" hw1=invalid";
 
  419             std::cout << 
" id1=invalid";
 
  421           std::cout << std::endl;
 
  427     std::cout << 
"========= E1 cells =========" << std::endl;
 
  431         for (
int tower = 10; tower < 11; tower += 1) {
 
  435             std::cout << 
" id1=" << tileID->
to_string(id1, -1);
 
  436             HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  438               std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  441                 if (
id2 != id1) std::cout << 
" id1!=id2=" << tileID->
to_string(
id2, -1);
 
  444                   if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  446                   std::cout << 
" hw2=invalid";
 
  449                 std::cout << 
" id2=invalid";
 
  452               std::cout << 
" hw1=invalid";
 
  455             std::cout << 
" id1=invalid";
 
  457           std::cout << std::endl;
 
  463     std::cout << 
"========= E2 cells =========" << std::endl;
 
  467         for (
int tower = 11; tower < 12; tower += 1) {
 
  471             std::cout << 
" id1=" << tileID->
to_string(id1, -1);
 
  472             HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  474               std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  477                 if (
id2 != id1) std::cout << 
" id1!=id2=" << tileID->
to_string(
id2, -1);
 
  480                   if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  482                   std::cout << 
" hw2=invalid";
 
  485                 std::cout << 
" id2=invalid";
 
  488               std::cout << 
" hw1=invalid";
 
  491             std::cout << 
" id1=invalid";
 
  493           std::cout << std::endl;
 
  499     std::cout << 
"========= E3,E4 cells =========" << std::endl;
 
  503         for (
int tower = 13; tower < 16; tower += 2) {
 
  507             std::cout << 
" id1=" << tileID->
to_string(id1, -1);
 
  508             HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  510               std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  513                 if (
id2 != id1) std::cout << 
" id1!=id2=" << tileID->
to_string(
id2, -1);
 
  516                   if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  518                   std::cout << 
" hw2=invalid";
 
  521                 std::cout << 
" id2=invalid";
 
  524               std::cout << 
" hw1=invalid";
 
  527             std::cout << 
" id1=invalid";
 
  529           std::cout << std::endl;
 
  535     std::cout << 
"========= MBTS cells ==========" << std::endl;
 
  539         for (
int tower = 0; tower < 2; ++tower) {
 
  543             std::cout << 
" id1=" << tileTBID->
to_string(id1);
 
  544             HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  546               std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  552                   if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  554                   std::cout << 
" hw2=invalid";
 
  557                 std::cout << 
" id2=invalid";
 
  560               std::cout << 
" hw1=invalid";
 
  563             std::cout << 
" id1=invalid";
 
  565           std::cout << std::endl;
 
  573       std::cout << 
"========= E4' cells ==========" << std::endl;
 
  577           for (
int tower = 2; tower < 3; ++tower) {
 
  581               std::cout << 
" id1=" << tileTBID->
to_string(id1);
 
  582               HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
 
  584                 std::cout << 
" hw1=" << tileHWID->
to_string(hw1, -1);
 
  590                     if (hw2 != hw1) std::cout << 
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
 
  592                     std::cout << 
" hw2=invalid";
 
  595                   std::cout << 
" id2=invalid";
 
  598                 std::cout << 
" hw1=invalid";
 
  601               std::cout << 
" id1=invalid";
 
  603             std::cout << std::endl;
 
  609     std::cout << 
"===============================" << std::endl;
 
  614   return StatusCode::SUCCESS;