11 #include "GeoModelKernel/throwExcept.h"
24 template <
typename read_out>
void clearCache(std::vector<std::unique_ptr<read_out>>&
array) {
25 for (std::unique_ptr<read_out>& ele :
array) {
26 if (ele) ele->clearCache();
29 template <
typename read_out>
void fillCache(std::vector<std::unique_ptr<read_out>>&
array) {
30 for (std::unique_ptr<read_out>& ele :
array) {
31 if (ele) ele->fillCache();
40 if (m_idHelperSvc.retrieve().isFailure()) {
41 THROW_EXCEPTION(
"MuonDetectorManager() - No IdHelper svc is available");
44 if (m_idHelperSvc->hasMDT()){
45 m_mdtArray.resize(m_idHelperSvc->mdtIdHelper().detectorElement_hash_max());
47 if (m_idHelperSvc->hasCSC()){
48 m_cscArray.resize(m_idHelperSvc->cscIdHelper().detectorElement_hash_max());
50 if (m_idHelperSvc->hasTGC()){
51 m_tgcArray.resize(m_idHelperSvc->tgcIdHelper().detectorElement_hash_max());
53 if (m_idHelperSvc->hasRPC()){
54 m_rpcArray.resize(m_idHelperSvc->rpcIdHelper().detectorElement_hash_max());
56 if (m_idHelperSvc->hasMM()){
57 m_mmcArray.resize(m_idHelperSvc->mmIdHelper().detectorElement_hash_max());
59 if (m_idHelperSvc->hasSTGC()){
60 m_stgArray.resize(m_idHelperSvc->stgcIdHelper().detectorElement_hash_max());
124 std::string
key =
muonStationKey(mst->getStationType(), mst->getEtaIndex(), mst->getPhiIndex());
130 if (statEtaIndex < 0)
144 return (*it).second.get();
154 return (*it).second.get();
161 std::vector<const MuonStation*> stationList;
164 stationList.push_back(
ptr.get());
174 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
189 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
x->identify())<<
" which has been already added.");
199 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
x->identify())<<
" which has been already added.");
210 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
219 return arrayIdx < 0 ? nullptr :
m_mdtArray[arrayIdx].get();
224 return arrayIdx < 0 ? nullptr :
m_mdtArray[arrayIdx].get();
231 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
240 return array_idx < 0 ? nullptr :
m_cscArray[array_idx].get();
245 return array_idx < 0 ? nullptr :
m_cscArray[array_idx].get();
252 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
262 return array_idx < 0 ? nullptr :
m_tgcArray[array_idx].get();
266 return array_idx < 0 ? nullptr :
m_tgcArray[array_idx].get();
270 return array_idx < 0 ? nullptr :
m_mmcArray[array_idx].get();
274 return array_idx < 0 ? nullptr :
m_stgArray[array_idx].get();
339 if (alineData.empty()) {
340 ATH_MSG_DEBUG(
"Got empty A-line container (expected for MC), not applying A-lines...");
341 return StatusCode::SUCCESS;
346 unsigned int nLines{0}, nUpdates{0};
347 for (
const ALinePar& ALine : alineData) {
350 const std::string stType = ALine.AmdbStation();
351 const int jff = ALine.AmdbPhi();
352 const int jzz = ALine.AmdbEta();
353 const int job = ALine.AmdbJob();
357 if (stType[0] ==
'M' || stType[0] ==
'S') {
359 ATH_MSG_WARNING(
"Unable to set A-line; the manager does not contain NSW readout elements" );
362 if (stType[0] ==
'M') {
369 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
370 return StatusCode::FAILURE;
375 }
else if (stType[0] ==
'S') {
382 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
383 return StatusCode::FAILURE;
397 ATH_MSG_WARNING(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " <<
job <<
"*** No MuonStation found\n"
398 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use" );
404 if (stType[0] ==
'T') {
405 ATH_MSG_DEBUG(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " <<
job
406 <<
" has JOB not 0 - this is expected for TGC" );
408 ATH_MSG_WARNING(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " <<
job
409 <<
" has JOB not 0 - this is NOT EXPECTED yet for non TGC chambers - skipping this A-line" );
414 ATH_MSG_DEBUG(
"Setting delta transform for Station " << ALine);
417 ALine.getParameter(Parameter::transZ),
418 ALine.getParameter(Parameter::transT),
419 ALine.getParameter(Parameter::rotS),
420 ALine.getParameter(Parameter::rotZ),
421 ALine.getParameter(Parameter::rotT));
427 ATH_MSG_DEBUG(
"Setting delta transform for component " << ALine);
429 ALine.getParameter(Parameter::transS),
430 ALine.getParameter(Parameter::transZ),
431 ALine.getParameter(Parameter::transT),
432 ALine.getParameter(Parameter::rotS),
433 ALine.getParameter(Parameter::rotZ),
434 ALine.getParameter(Parameter::rotT));
441 ATH_MSG_INFO(
"# of A-lines read from the ALineMapContainer in StoreGate is " << nLines );
442 ATH_MSG_INFO(
"# of deltaTransforms updated according to A-lines is " << nUpdates );
443 return StatusCode::SUCCESS;
448 if (blineData.empty()) {
449 ATH_MSG_DEBUG(
"Got empty B-line container (expected for MC), not applying B-lines..." );
450 return StatusCode::SUCCESS;
452 ATH_MSG_INFO(
"temporary B-line container with size = " << blineData.size() );
455 unsigned int nLines{0}, nUpdates{0};
456 for (
const BLinePar& BLine : blineData) {
458 const std::string stType = BLine.AmdbStation();
459 const int jff = BLine.AmdbPhi();
460 const int jzz = BLine.AmdbEta();
461 const int job = BLine.AmdbJob();
465 if (stType[0] ==
'M' || stType[0] ==
'S') {
467 ATH_MSG_WARNING(
"Unable to set B-line; the manager does not contain NSW readout elements" );
470 if (stType[0] ==
'M') {
476 ATH_MSG_WARNING(
"BlinePar with AmdbId " <<BLine<<
" *** No MM readout element found\n"
477 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
478 return StatusCode::FAILURE;
481 }
else if (stType[0] ==
'S') {
486 ATH_MSG_WARNING(
"BlinePar with AmdbId " << BLine <<
" *** No sTGC readout element found\n"
487 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
488 return StatusCode::FAILURE;
498 if (stType.at(0) ==
'T' || stType.at(0) ==
'C' || (stType.substr(0, 3) ==
"BML" && std::abs(jzz) == 7)) {
499 ATH_MSG_DEBUG(
"BLinePar with AmdbId " << BLine <<
" is not a MDT station - skipping" );
507 " *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
508 "Geometry Layout in use");
511 ATH_MSG_DEBUG(
"Setting deformation parameters for Station " << stType <<
" " << jzz <<
" " << jff <<
" ");
515 ATH_MSG_WARNING(
"BLinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " <<
job <<
" has JOB not 0 ");
516 return StatusCode::FAILURE;
519 ATH_MSG_INFO(
"# of B-lines read from the ALineMapContainer in StoreGate is " << nLines );
520 ATH_MSG_INFO(
"# of deform-Transforms updated according to B-lines is " << nUpdates );
521 return StatusCode::SUCCESS;
526 if (ilineData.empty()) {
527 ATH_MSG_WARNING(
"Empty temporary CSC I-line container - nothing to do here" );
528 return StatusCode::SUCCESS;
530 ATH_MSG_INFO(
"temporary CSC I-line container with size = " << ilineData.size() );
533 unsigned int nLines{0}, nUpdates{0};
534 for (
const ALinePar& ILine : ilineData) {
536 const std::string stType = ILine.AmdbStation();
537 const int jff = ILine.AmdbPhi();
538 const int jzz = ILine.AmdbEta();
539 const int job = ILine.AmdbJob();
540 ATH_MSG_DEBUG(
"CscInternalAlignmentPar with AmdbId " << ILine <<
" is new ID = " <<
m_idHelperSvc->toString(ILine.identify()) );
545 <<
" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
546 "Geometry Layout in use");
552 ATH_MSG_ERROR(
"The CSC I-lines container includes stations which are no CSCs! This is impossible." );
561 ATH_MSG_ERROR(
"job for CSC I-Lines= " <<
job <<
" is not 3 => This is not valid." );
564 ATH_MSG_INFO(
"# of CSC I-lines read from the ILineMapContainer in StoreGate is " << nLines );
565 ATH_MSG_INFO(
"# of deltaTransforms updated according to A-lines is " << nUpdates );
566 return StatusCode::SUCCESS;
570 if (asbuiltData.empty()) {
571 ATH_MSG_WARNING(
"Empty temporary As-Built container - nothing to do here" );
572 return StatusCode::SUCCESS;
574 ATH_MSG_INFO(
"temporary As-Built container with size = " << asbuiltData.size() );
577 unsigned int nLines{0}, nUpdates{0};
578 for (
const auto& AsBuiltPar : asbuiltData) {
580 const std::string stType = AsBuiltPar.AmdbStation();
581 const int jff = AsBuiltPar.AmdbPhi();
582 const int jzz = AsBuiltPar.AmdbEta();
585 <<
" is new ID = " <<
m_idHelperSvc->toString(AsBuiltPar.identify()) );
590 ATH_MSG_DEBUG(
"Setting as-built parameters for Station " << AsBuiltPar );
595 <<
" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
596 "Geometry Layout in use");
600 ATH_MSG_INFO(
"# of MDT As-Built read from the MdtAsBuiltMapContainer in StoreGate is " << nLines );
601 ATH_MSG_INFO(
"# of deltaTransforms updated according to As-Built is " << nUpdates );
602 return StatusCode::SUCCESS;
615 if (
id >=
m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()) {
616 ATH_MSG_WARNING(
" try to getMdtReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
617 <<
m_idHelperSvc->mdtIdHelper().detectorElement_hash_max() - 1 );
626 if (
id >=
m_idHelperSvc->rpcIdHelper().detectorElement_hash_max()) {
627 ATH_MSG_WARNING(
" try to getRpcReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
628 <<
m_idHelperSvc->rpcIdHelper().detectorElement_hash_max() - 1 );
637 if (
id >=
m_idHelperSvc->tgcIdHelper().detectorElement_hash_max()) {
638 ATH_MSG_WARNING(
" try to getTgcReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
639 <<
m_idHelperSvc->tgcIdHelper().detectorElement_hash_max() - 1 );
648 if (
id >=
m_idHelperSvc->cscIdHelper().detectorElement_hash_max()) {
649 ATH_MSG_WARNING(
" try to getCscReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
650 <<
m_idHelperSvc->cscIdHelper().detectorElement_hash_max() - 1 );
664 std::map<int, int>::const_iterator itr =
m_rpcIdxToStat.find(stationIndex);
681 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex(
"BIM"), RpcStatType::BIM));
694 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BIM, rpcHelper.stationNameIndex(
"BIM")));