16 #include "CaloDetDescr/CaloDetDescrElement.h"
30 static const InterfaceID IID_TileCablingSvc(
"TileCablingSvc", 1, 0);
32 return IID_TileCablingSvc;
39 , m_cablingService(nullptr)
43 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");
53 return AthService::queryInterface(riid, ppvInterface);
56 return StatusCode::SUCCESS;
67 m_cablingService = cablingService;
68 if (!m_cablingService) {
70 return StatusCode::FAILURE;
80 const TileID* tileID(
nullptr);
96 if (m_connectedDrawers.size() > 1) {
105 msg(MSG::INFO) <<
"Connected drawer list:" << MSG::hex;
106 for (
unsigned int dr = 1;
dr < m_connectedDrawers.size();
dr += 2) {
107 int frag1 = std::strtol(m_connectedDrawers[
dr - 1].
data(),
nullptr, 0);
108 int frag2 = std::strtol(m_connectedDrawers[
dr].
data(),
nullptr, 0);
109 for (
int frag = frag1; frag <= frag2; ++frag) {
112 if (
ros >= 1 && ros < 5 && drawer >= 0 &&
drawer < 64) {
114 msg(MSG::INFO) <<
" 0x" << frag;
137 msg(MSG::INFO) <<
" " << MSG::hex;
145 SmartIF<IGeoModelSvc> geoModel{service(
"GeoModelSvc")};
150 std::string atlasVersion = geoModel->atlasVersion();
151 int ctb = atlasVersion.compare(0, 9,
"ATLAS-CTB");
152 int geo = atlasVersion.compare(0,9,
"ATLAS-GEO");
153 int run1 = atlasVersion.compare(0,8,
"ATLAS-R1");
154 int ibl = atlasVersion.compare(0,9,
"ATLAS-IBL");
155 int run2 = atlasVersion.compare(0,8,
"ATLAS-R2");
156 int run3 = atlasVersion.compare(0,8,
"ATLAS-R3");
157 int run4 = atlasVersion.compare(0,13,
"ATLAS-P2-RUN4");
158 int upg = atlasVersion.compare(0,7,
"ATLAS-P") ;
159 int comm = atlasVersion.compare(0,10,
"ATLAS-Comm");
161 bool upgradeA = (tileID->
cell_hash_max() == MAX_TILE_CELLS_UPGRADEA);
162 bool upgradeBC = (tileID->
cell_hash_max() == MAX_TILE_CELLS_UPGRADEBC);
163 bool upgradeABC = (tileID->
cell_hash_max() == MAX_TILE_CELLS_UPGRADEABC);
175 ATH_MSG_INFO(
"RUN2 ATLAS geometry flag detected for geometry: " << atlasVersion );
177 ATH_MSG_INFO(
"RUN2 ATLAS UpgradeA geometry flag detected for geometry: " << atlasVersion );
179 }
else if (upgradeBC) {
180 ATH_MSG_INFO(
"RUN2 ATLAS UpgradeBC geometry flag detected for geometry: " << atlasVersion );
182 }
else if (upgradeABC) {
183 ATH_MSG_INFO(
"RUN2 ATLAS UpgradeABC geometry flag detected for geometry: " << atlasVersion );
187 ATH_MSG_INFO(
"Cabling for RUN2 (2014-2017) ATLAS geometry is set via jobOptions " );
189 ATH_MSG_INFO(
"Cabling for RUN2a (2018) ATLAS geometry is set via jobOptions " );
194 ATH_MSG_INFO(
"Using cabling type " << m_cablingType <<
" from jobOptions " );
200 ATH_MSG_INFO(
"RUN3 ATLAS geometry flag detected for geometry: " << atlasVersion );
202 ATH_MSG_INFO(
"Cabling for RUN3 ATLAS geometry is set via jobOptions " );
207 ATH_MSG_INFO(
"Using cabling type " << m_cablingType <<
" from jobOptions " );
212 ATH_MSG_INFO(
"RUN4 ATLAS geometry flag detected for geometry: " << atlasVersion );
214 ATH_MSG_INFO(
"Cabling for RUN3 ATLAS geometry is set via jobOptions " );
219 ATH_MSG_INFO(
"Using cabling type " << m_cablingType <<
" from jobOptions " );
223 ATH_MSG_INFO(
"Cabling for RUN3 ATLAS geometry is set via jobOptions " );
225 ATH_MSG_INFO(
"Cabling for RUN2 (2014-2017) ATLAS geometry is set via jobOptions " );
227 ATH_MSG_INFO(
"Cabling for RUN2a (2018) ATLAS geometry is set via jobOptions " );
228 }
else if (ctb == 0) {
229 ATH_MSG_INFO(
"CTB geometry detected: " << atlasVersion );
231 }
else if (
geo == 0 ||
run1 == 0 || ibl == 0 ||
run2 == 0 || upg == 0) {
232 ATH_MSG_INFO(
"RUN1 ATLAS geometry detected: " << atlasVersion );
234 }
else if (
comm == 0) {
235 ATH_MSG_INFO(
"RUN1 ATLAS Commissioning geometry detected: " << atlasVersion );
238 ATH_MSG_WARNING(
"Old ATLAS geometry detected - most probably it's a mistake: " << atlasVersion );
247 ATH_MSG_INFO(
"Setting Cabling type to " << m_cablingType );
249 ATH_MSG_DEBUG(
"Maximum number of gains: " << m_cablingService->getMaxChannels());
254 if (
m_detStore->retrieve(tileMgr).isFailure()) {
255 ATH_MSG_WARNING(
"Unable to retrieve TileDetDescrManager from DetectorStore" );
256 ATH_MSG_WARNING(
"Will not set Tile online hash ID in CaloDetDescrElements" );
271 bool disconnected =
true;
274 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
277 disconnected &= (
id2 != id1);
279 if (disconnected) m_disconnectedCells.push_back(cell_id);
283 && (pmtHash[0] != oldPmtHash[0] || pmtHash[1] != oldPmtHash[1])) {
286 <<
" id= " << tileID->
to_string(cell_id, -2)
287 <<
" from (" << oldPmtHash[0] <<
"," << oldPmtHash[1]
288 <<
") to (" << pmtHash[0] <<
"," << pmtHash[1] <<
")" );
313 ATH_MSG_VERBOSE(
"Total: " << m_disconnectedCells.size() <<
" disconnected cells");
319 std::cout <<
"===============================" << std::endl;
328 std::cout <<
" hw1=" << tileHWID->
to_string(hwid1, -1);
329 Identifier id1 = m_cablingService->h2s_pmt_id(hwid1);
331 std::cout <<
" id1=" << tileID->
to_string(id1, -1);
332 HWIdentifier hwid2 = m_cablingService->s2h_channel_id(id1);
334 if (hwid2 != hwid1) std::cout <<
" hw1!=hw2=" << tileHWID->
to_string(hwid2, -1);
338 std::cout <<
" id1!=id2=" << tileID->
to_string(
id2, -1);
340 std::cout << ((tileTBID->
eta(id1)>1) ?
" E4'" :
" MBTS");
344 if (drIdx1 != drIdx2) {
345 std::cout <<
" ERROR in drawer index " << drIdx1 <<
" != " << drIdx2
347 << std::hex <<
" 0x" << hwid1 <<
" 0x"
350 std::cout <<
" drawer index " << drIdx2;
353 std::cout <<
" id2=invalid";
356 std::cout <<
" hw2=invalid";
359 std::cout <<
" id1=invalid";
362 std::cout <<
" hw1=invalid";
364 std::cout << std::endl;
370 std::cout <<
"=== D4 cells in special EB ====" << std::endl;
372 int d4module[4] = { 14, 15, 18, 19 };
374 for (
int imod = 0; imod < 4; ++imod) {
375 int module = d4module[imod] - 1;
380 std::cout <<
" id1=" << tileID->
to_string(id1, -1);
381 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
383 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
386 if (
id2 != id1) std::cout <<
" id1!=id2=" << tileID->
to_string(
id2, -1);
389 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
391 std::cout <<
" hw2=invalid";
394 std::cout <<
" id2=invalid";
397 std::cout <<
" hw1=invalid";
400 std::cout <<
" id1=invalid";
402 std::cout << std::endl;
408 std::cout <<
"=== C10 cells in special EB ===" << std::endl;
410 int c10module[8] = { 39, 40, 41, 42, 55, 56, 57, 58 };
412 for (
int imod = 0; imod < 8; ++imod) {
413 int module = c10module[imod] - 1;
418 std::cout <<
" id1=" << tileID->
to_string(id1, -1);
419 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
421 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
424 if (
id2 != id1) std::cout <<
" id1!=id2=" << tileID->
to_string(
id2, -1);
427 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
429 std::cout <<
" hw2=invalid";
432 std::cout <<
" id2=invalid";
435 std::cout <<
" hw1=invalid";
438 std::cout <<
" id1=invalid";
440 std::cout << std::endl;
446 std::cout <<
"========= E1 cells =========" << std::endl;
450 for (
int tower = 10; tower < 11; tower += 1) {
454 std::cout <<
" id1=" << tileID->
to_string(id1, -1);
455 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
457 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
460 if (
id2 != id1) std::cout <<
" id1!=id2=" << tileID->
to_string(
id2, -1);
463 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
465 std::cout <<
" hw2=invalid";
468 std::cout <<
" id2=invalid";
471 std::cout <<
" hw1=invalid";
474 std::cout <<
" id1=invalid";
476 std::cout << std::endl;
482 std::cout <<
"========= E2 cells =========" << std::endl;
486 for (
int tower = 11; tower < 12; tower += 1) {
490 std::cout <<
" id1=" << tileID->
to_string(id1, -1);
491 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
493 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
496 if (
id2 != id1) std::cout <<
" id1!=id2=" << tileID->
to_string(
id2, -1);
499 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
501 std::cout <<
" hw2=invalid";
504 std::cout <<
" id2=invalid";
507 std::cout <<
" hw1=invalid";
510 std::cout <<
" id1=invalid";
512 std::cout << std::endl;
518 std::cout <<
"========= E3,E4 cells =========" << std::endl;
522 for (
int tower = 13; tower < 16; tower += 2) {
526 std::cout <<
" id1=" << tileID->
to_string(id1, -1);
527 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
529 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
532 if (
id2 != id1) std::cout <<
" id1!=id2=" << tileID->
to_string(
id2, -1);
535 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
537 std::cout <<
" hw2=invalid";
540 std::cout <<
" id2=invalid";
543 std::cout <<
" hw1=invalid";
546 std::cout <<
" id1=invalid";
548 std::cout << std::endl;
554 std::cout <<
"========= MBTS cells ==========" << std::endl;
558 for (
int tower = 0; tower < 2; ++tower) {
562 std::cout <<
" id1=" << tileTBID->
to_string(id1);
563 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
565 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
571 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
573 std::cout <<
" hw2=invalid";
576 std::cout <<
" id2=invalid";
579 std::cout <<
" hw1=invalid";
582 std::cout <<
" id1=invalid";
584 std::cout << std::endl;
592 std::cout <<
"========= E4' cells ==========" << std::endl;
596 for (
int tower = 2; tower < 3; ++tower) {
600 std::cout <<
" id1=" << tileTBID->
to_string(id1);
601 HWIdentifier hw1 = m_cablingService->s2h_channel_id(id1);
603 std::cout <<
" hw1=" << tileHWID->
to_string(hw1, -1);
609 if (hw2 != hw1) std::cout <<
" hwid1!=hwid2=" << tileHWID->
to_string(hw2, -1);
611 std::cout <<
" hw2=invalid";
614 std::cout <<
" id2=invalid";
617 std::cout <<
" hw1=invalid";
620 std::cout <<
" id1=invalid";
622 std::cout << std::endl;
628 std::cout <<
"===============================" << std::endl;
633 return StatusCode::SUCCESS;
640 return StatusCode::SUCCESS;