diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCablingJsonDumpAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCablingJsonDumpAlg.cxx index 5f8c1e1ce32910e1c42846e4214085636697bf50..1a21550f6237cf03053f96418dc569c8d4e8f442 100644 --- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCablingJsonDumpAlg.cxx +++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCablingJsonDumpAlg.cxx @@ -61,10 +61,9 @@ StatusCode MdtCablingJsonDumpAlg::execute() { std::vector<MdtMezzanineCard> cached_cards{}; std::set<MdtCablingData> cached_chnls{}; - for (unsigned int hash = 0; hash < MuonGM::MuonDetectorManager::MdtRElMaxHash; ++hash){ - const IdentifierHash id_hash{hash}; - const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(id_hash); + for (auto det_itr = idHelper.detectorElement_begin(); det_itr != idHelper.detectorElement_end(); ++det_itr){ + const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(*det_itr); if (!readEle) { ATH_MSG_DEBUG("Detector element does not exist. "); continue; diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/MdtCablingTestAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/MdtCablingTestAlg.cxx index 12501bf2b9d627bb29bea16f6bc4a5f7ce3a73b8..45431d881b52355482f82a8b7b4cbecc33cb38c5 100644 --- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/MdtCablingTestAlg.cxx +++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/MdtCablingTestAlg.cxx @@ -97,10 +97,10 @@ StatusCode MdtCablingTestAlg::execute(){ const MdtIdHelper& idHelper = m_idHelperSvc->mdtIdHelper(); unsigned int n_elements{0}, n_success{0}; bool failure{false}; - for (unsigned int hash = 0; hash < MuonGM::MuonDetectorManager::MdtRElMaxHash; ++hash){ - const IdentifierHash id_hash{hash}; + + for (auto det_itr = idHelper.detectorElement_begin(); det_itr != idHelper.detectorElement_end(); ++det_itr){ + const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(*det_itr); - const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(id_hash); if (!readEle) { ATH_MSG_DEBUG("Detector element does not exist. "); continue; diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/RpcCablingTestAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/RpcCablingTestAlg.cxx index 2443c67627cacb084243eaea976e4e3ca1a8553a..9bc9d104236d69d793b28d6cdb020aa4439845b7 100644 --- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/RpcCablingTestAlg.cxx +++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/RpcCablingTestAlg.cxx @@ -38,12 +38,11 @@ StatusCode RpcCablingTestAlg::execute(){ } const RpcIdHelper& idHelper = m_idHelperSvc->rpcIdHelper(); unsigned int n_elements{0}, n_success{0}; - for (unsigned int hash = 0; hash < MuonGM::MuonDetectorManager::RpcRElMaxHash; ++hash){ - const IdentifierHash id_hash{hash}; + for (auto det_itr = idHelper.detectorElement_begin(); det_itr != idHelper.detectorElement_end(); ++det_itr){ - const MuonGM::RpcReadoutElement* readEle = detectorMgr->getRpcReadoutElement(id_hash); + const MuonGM::RpcReadoutElement* readEle = detectorMgr->getRpcReadoutElement(*det_itr); if (!readEle) { - ATH_MSG_VERBOSE("Detector element "<<id_hash<<" does not exist. "); + ATH_MSG_VERBOSE("Detector element does not exist. "); continue; } if (!m_cabStat.empty() && !m_cabStat.count(m_idHelperSvc->stationName(readEle->identify()))){ diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h index 72305abd47887183dfac08574c702565606890ba..bba42ee4c9a95e10ab24ddb900f8b71ba41aad14 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h @@ -131,61 +131,6 @@ namespace MuonGM { inline int IncludeCutoutsFlag() const; void setCutoutsBogFlag(int flag); inline int IncludeCutoutsBogFlag() const; - - enum readoutElementHashMax { - MdtRElMaxHash = 2500, - CscRElMaxHash = 130, - RpcRElMaxHash = 2600, - TgcRElMaxHash = 1600, - }; - enum detElementHashMax { - MdtDetElMaxHash = 1200, - CscDetElMaxHash = 65, - RpcDetElMaxHash = 1300, - TgcDetElMaxHash = 1600, - }; - enum MdtGMRanges { - NMdtStatType = 26, - NMdtStatEta = 17, - NMdtStEtaOffset = 8, - NMdtStatPhi = 8, - NMdtMultilayer = 2, - }; - enum RpcGMRanges { - NRpcStatType = 12, // there are 12 station types where RPCs can be installed: BML/BMS/BOL/BOS/BMF/BOF/BOG/BME/BIR/BIM/BIL/BIS - NRpcStatEta = 17, - NRpcStEtaOffset = 8, - NRpcStatPhi = 8, - NDoubletR = 2, - NDoubletZ = 4 - }; // using some trick to save space: dbz=4 if rib's chambers and doubletphi=2; - enum TgcGMRanges { - NTgcStatType = 8, - NTgcStatTypeOff = -41, - NTgcStatEta = 10, - NTgcStEtaOffset = 5, - NTgcStatPhi = 48, - }; - enum CscGMRanges { - NCscStatType = 2, - NCscStatTypeOff = -50, - NCscStatEta = 2, - NCscStEtaOffset = 1, - NCscStatPhi = 8, - NCscChamberLayer = 2 - }; - enum sTgcGMRanges { - NsTgStatEta = 6, /// 3 x 2 sides (-3,-2,-1 and 1,2,3) - NsTgStEtaOffset = 3, /// needed offest to map (-3,-2,-1,1,2,3) to (0,1,2,3,4,5) - NsTgStatPhi = 16, // large and small sector together - NsTgChamberLayer = 2 - }; - enum mmGMRanges { - NMMcStatEta = 4, /// 2 x 2 sides (-2,-1 and 1,2) - NMMcStEtaOffset = 2, /// needed offest to map (-2,-1,1,2) to (0,1,2,3) - NMMcStatPhi = 16, // large and small sector together - NMMcChamberLayer = 2 - }; // Add a MuonStation to the list void addMuonStation(std::unique_ptr<MuonStation>&& mst); @@ -211,6 +156,12 @@ namespace MuonGM { return m_nswAsBuilt ? m_nswAsBuilt->sTgcData.get() : nullptr; ; } #endif + /** + * Identifier <-> AMDB conversion constants in use + */ + static constexpr int NCscStEtaOffset = 1; + static constexpr int NTgcStatTypeOff = -41; + static constexpr int NTgcStEtaOffset = 5; // map the RPC station indices (0-NRpcStatType) back to the RpcIdHelper stationNames int rpcStationName(const int stationIndex) const; @@ -228,10 +179,6 @@ namespace MuonGM { int mmIdenToArrayIdx(const Identifier& id) const; int mdtIdentToArrayIdx(const Identifier& id) const; - /// The doublet z index is required during the initialization of the - /// detector element - int rpcIdentToArrayIdx(const Identifier& id, int& dbz_index) const; - int m_minimalgeo{0}; int m_includeCutouts{0}; int m_includeCutoutsBog{0}; @@ -245,19 +192,13 @@ namespace MuonGM { std::string m_DBMuonVersion{}; // name of the MuonVersion table-collection in Oracle // 115.6 kBytes. - static constexpr int s_NumMaxRpcElements = NRpcStatType * NRpcStatEta * NRpcStatPhi * NDoubletR * NDoubletZ; - - static constexpr int s_NumMaxSTgcElemets = NsTgStatEta * NsTgStatPhi * NsTgChamberLayer; - static constexpr int s_NumMaxMMElements = NMMcStatEta * NMMcStatPhi * NMMcChamberLayer; - std::array<std::unique_ptr<MdtReadoutElement>, MdtRElMaxHash> m_mdtArray; - std::array<std::unique_ptr<CscReadoutElement>, CscRElMaxHash> m_cscArray; - std::array<std::unique_ptr<TgcReadoutElement>, TgcRElMaxHash> m_tgcArray; + std::vector<std::unique_ptr<MdtReadoutElement>> m_mdtArray; + std::vector<std::unique_ptr<CscReadoutElement>> m_cscArray; + std::vector<std::unique_ptr<TgcReadoutElement>> m_tgcArray; - std::array<std::unique_ptr<RpcReadoutElement>, s_NumMaxRpcElements> m_rpcArray; - std::array<std::unique_ptr<sTgcReadoutElement>, s_NumMaxSTgcElemets> m_stgArray; - std::array<std::unique_ptr<MMReadoutElement>, s_NumMaxMMElements> m_mmcArray; - // - std::array<const RpcReadoutElement*, RpcRElMaxHash> m_rpcArrayByHash{nullptr}; + std::vector<std::unique_ptr<RpcReadoutElement>> m_rpcArray; + std::vector<std::unique_ptr<sTgcReadoutElement>> m_stgArray; + std::vector<std::unique_ptr<MMReadoutElement>> m_mmcArray; std::map<std::string, std::unique_ptr<MuonStation> > m_MuonStationMap; unsigned int m_n_mdtRE{0}; @@ -277,16 +218,8 @@ namespace MuonGM { /// RPC name caches std::map<int, int> m_rpcStatToIdx; std::map<int, int> m_rpcIdxToStat; - /// Cache the MDT station name integers and retrieve them from the - /// dict parser. Needed in stationIndex -> mdtStationName conversion - int m_mdt_EIS_stName{-1}; //49 - int m_mdt_BIM_stName{-1}; //52 - int m_mdt_BME_stName{-1}; //53 - int m_mdt_BMG_stName{-1}; //54 - - template <typename read_out, size_t N> void clearCache(std::array<std::unique_ptr<read_out>, N>& array); - template <typename read_out, size_t N> void fillCache(std::array<std::unique_ptr<read_out>, N>& array); - template <typename read_out, size_t N> void refreshCache(std::array<std::unique_ptr<read_out>, N>& array); + + }; const MdtIdHelper* MuonDetectorManager::mdtIdHelper() const { diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx index d3470c48986901f3e85a568c75562b6cb8072a60..00b5a8f77b7b2aa9c8a3761449afe471769d760f 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #include "MuonReadoutGeometry/MuonDetectorManager.h" @@ -8,6 +8,7 @@ #include <utility> #include "GeoPrimitives/GeoPrimitivesHelpers.h" +#include "GeoModelHelpers/throwExcept.h" #include "MuonAlignmentData/ALinePar.h" #include "MuonAlignmentData/BLinePar.h" #include "MuonReadoutGeometry/CscReadoutElement.h" @@ -19,45 +20,66 @@ #include "MuonReadoutGeometry/TgcReadoutElement.h" #include "MuonReadoutGeometry/sTgcReadoutElement.h" +namespace { + template <typename read_out> void clearCache(std::vector<std::unique_ptr<read_out>>& array) { + for (std::unique_ptr<read_out>& ele : array) { + if (ele) ele->clearCache(); + } + } + template <typename read_out> void fillCache(std::vector<std::unique_ptr<read_out>>& array) { + for (std::unique_ptr<read_out>& ele : array) { + if (ele) ele->fillCache(); + } + } +} + namespace MuonGM { MuonDetectorManager::MuonDetectorManager(): AthMessaging{"MGM::MuonDetectorManager"} { setName("Muon"); if (m_idHelperSvc.retrieve().isFailure()) { - throw std::runtime_error("MuonDetectorManager() - No IdHelper svc is available"); + THROW_EXCEPTION("MuonDetectorManager() - No IdHelper svc is available"); } loadStationIndices(); - } - - MuonDetectorManager::~MuonDetectorManager() = default; - - template <typename read_out, size_t N> void MuonDetectorManager::clearCache(std::array<std::unique_ptr<read_out>, N>& array) { - for (std::unique_ptr<read_out>& ele : array) { - if (ele) ele->clearCache(); + if (m_idHelperSvc->hasMDT()){ + m_mdtArray.resize(m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()); } - } - template <typename read_out, size_t N> void MuonDetectorManager::fillCache(std::array<std::unique_ptr<read_out>, N>& array) { - for (std::unique_ptr<read_out>& ele : array) { - if (ele) ele->fillCache(); + if (m_idHelperSvc->hasCSC()){ + m_cscArray.resize(m_idHelperSvc->cscIdHelper().detectorElement_hash_max()); + } + if (m_idHelperSvc->hasTGC()){ + m_tgcArray.resize(m_idHelperSvc->tgcIdHelper().detectorElement_hash_max()); + } + if (m_idHelperSvc->hasRPC()){ + m_rpcArray.resize(m_idHelperSvc->rpcIdHelper().detectorElement_hash_max()); + } + + if (m_idHelperSvc->hasMM()){ + m_mmcArray.resize(m_idHelperSvc->mmIdHelper().detectorElement_hash_max()); + } + if (m_idHelperSvc->hasSTGC()){ + m_stgArray.resize(m_idHelperSvc->stgcIdHelper().detectorElement_hash_max()); } } + MuonDetectorManager::~MuonDetectorManager() = default; + void MuonDetectorManager::clearCache() { - clearCache(m_mdtArray); - clearCache(m_rpcArray); - clearCache(m_tgcArray); - if (nCscRE()) clearCache(m_cscArray); - if (nMMRE()) clearCache(m_mmcArray); - if (nsTgcRE()) clearCache(m_stgArray); + ::clearCache(m_mdtArray); + ::clearCache(m_rpcArray); + ::clearCache(m_tgcArray); + ::clearCache(m_cscArray); + ::clearCache(m_mmcArray); + ::clearCache(m_stgArray); } void MuonDetectorManager::fillCache() { ATH_MSG_INFO( "Filling cache" ); - fillCache(m_mdtArray); - fillCache(m_rpcArray); - fillCache(m_tgcArray); - if (nCscRE()) fillCache(m_cscArray); - if (nMMRE()) fillCache(m_mmcArray); - if (nsTgcRE()) fillCache(m_stgArray); + ::fillCache(m_mdtArray); + ::fillCache(m_rpcArray); + ::fillCache(m_tgcArray); + ::fillCache(m_cscArray); + ::fillCache(m_mmcArray); + ::fillCache(m_stgArray); } unsigned int MuonDetectorManager::getNumTreeTops() const { return m_envelope.size(); } @@ -105,26 +127,11 @@ namespace MuonGM { } void MuonDetectorManager::addRpcReadoutElement(std::unique_ptr<RpcReadoutElement>&& x) { - const Identifier id = x->identify(); - // add RE to map by RE hash - const IdentifierHash Idhash = x->detectorElementHash(); - if (Idhash >= RpcRElMaxHash) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" with hash Id" - <<Idhash<<" exceeding the allowed boundaries 0-"<<RpcRElMaxHash); - throw std::runtime_error("Invalid hash assignment"); - } else { - if (m_rpcArrayByHash[Idhash]) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been added before by"<< - m_idHelperSvc->toStringDetEl(m_rpcArrayByHash[Idhash]->identify())); - throw std::runtime_error("Double assignment of the Hash"); - } - m_rpcArrayByHash[Idhash] = x.get(); - } - int dbz_index{-1}; - int idx = rpcIdentToArrayIdx(id, dbz_index); + const Identifier id = x->identify(); + int idx = rpcIdentToArrayIdx(id); if (m_rpcArray[idx]) { ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added."); - throw std::runtime_error("Double readout element assignment"); + THROW_EXCEPTION("Double readout element assignment"); } m_rpcArray[idx] = std::move(x); ++m_n_rpcRE; @@ -139,7 +146,7 @@ namespace MuonGM { const int array_idx = mmIdenToArrayIdx(x->identify()); if (m_mmcArray[array_idx]) { ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(x->identify())<<" which has been already added."); - throw std::runtime_error("Double readout element assignment"); + THROW_EXCEPTION("Double readout element assignment"); } m_mmcArray[array_idx] = std::move(x); ++m_n_mmcRE; @@ -149,26 +156,18 @@ namespace MuonGM { const int array_idx = stgcIdentToArrayIdx(x->identify()); if (m_stgArray[array_idx]) { ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(x->identify())<<" which has been already added."); - throw std::runtime_error("Double readout element assignment"); + THROW_EXCEPTION("Double readout element assignment"); } m_stgArray[array_idx] = std::move(x); ++m_n_stgRE; } void MuonDetectorManager::addMdtReadoutElement(std::unique_ptr<MdtReadoutElement>&& x) { - const Identifier id = x->identify(); - // add here the MdtReadoutElement to the array by RE hash - // use already known RE hash - const IdentifierHash Idhash = x->detectorElementHash(); - if (Idhash >= MdtRElMaxHash) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" with hash Id" - <<Idhash<<" exceeding the allowed boundaries 0-"<<MdtRElMaxHash); - throw std::runtime_error("Invalid hash assignment"); - } + const Identifier id = x->identify(); const int arrayIdx = mdtIdentToArrayIdx(id); if (m_mdtArray[arrayIdx]) { ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added."); - throw std::runtime_error("Double readout element assignment"); + THROW_EXCEPTION("Double readout element assignment"); } m_mdtArray[arrayIdx] = std::move(x); ++m_n_mdtRE; @@ -186,17 +185,10 @@ namespace MuonGM { void MuonDetectorManager::addCscReadoutElement(std::unique_ptr<CscReadoutElement>&& x) { const Identifier id = x->identify(); - // add here RE to array by hash - const IdentifierHash Idhash = x->detectorElementHash(); - if (Idhash >= CscRElMaxHash) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" with hash Id" - <<Idhash<<" exceeding the allowed boundaries 0-"<<CscRElMaxHash); - throw std::runtime_error("Invalid hash assignment"); - } const int array_idx = cscIdentToArrayIdx(id); if (m_cscArray[array_idx]) { ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added."); - throw std::runtime_error("Double readout element assignment"); + THROW_EXCEPTION("Double readout element assignment"); } m_cscArray[array_idx] = std::move(x); ++m_n_cscRE; @@ -214,17 +206,10 @@ namespace MuonGM { void MuonDetectorManager::addTgcReadoutElement(std::unique_ptr<TgcReadoutElement>&& x) { const Identifier id = x->identify(); - // add RE to array by RE hash - const IdentifierHash Idhash = x->detectorElementHash(); - if (Idhash >= TgcRElMaxHash) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" with hash Id" - <<Idhash<<" exceeding the allowed boundaries 0-"<<TgcRElMaxHash); - throw std::runtime_error("Invalid hash assignment"); - } const int array_idx = tgcIdentToArrayIdx(id); if (m_tgcArray[array_idx]) { ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added."); - throw std::runtime_error("Double readout element assignment"); + THROW_EXCEPTION("Double readout element assignment"); } m_tgcArray[array_idx] = std::move(x); @@ -246,114 +231,67 @@ namespace MuonGM { const sTgcReadoutElement* MuonDetectorManager::getsTgcReadoutElement(const Identifier& id) const { const int array_idx = stgcIdentToArrayIdx(id); return array_idx < 0 ? nullptr : m_stgArray[array_idx].get(); - } - int MuonDetectorManager::mmIdenToArrayIdx(const Identifier& id) const { - const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()}; - IdentifierHash hash{0}; - if (idHelper.get_detectorElement_hash(id,hash)) { + } + int MuonDetectorManager::mdtIdentToArrayIdx(const Identifier& id) const { + const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id)); +#ifndef NDEBUG + if (hash <0) { ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id)); return -1; } - return static_cast<int>(hash); +#endif + return hash; } - int MuonDetectorManager::stgcIdentToArrayIdx(const Identifier& id) const { - const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()}; - IdentifierHash hash{0}; - if (idHelper.get_detectorElement_hash(id,hash)) { + int MuonDetectorManager::mmIdenToArrayIdx(const Identifier& id) const { + const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id)); +#ifndef NDEBUG + if (hash <0) { ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id)); return -1; } - return static_cast<int>(hash); +#endif + return hash; } - int MuonDetectorManager::rpcIdentToArrayIdx(const Identifier& id) const { - int dbl_z{-1}; - return rpcIdentToArrayIdx(id, dbl_z); - } - int MuonDetectorManager::rpcIdentToArrayIdx(const Identifier& id, int& dbz_index) const { - const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()}; - const int stationName = idHelper.stationName(id); - const int stationEta = idHelper.stationEta(id); - const int doubletPhi = idHelper.doubletPhi(id); - const int doubletZ = idHelper.doubletZ(id); - const int doubletR = idHelper.doubletR(id); - const int stname_index = rpcStationTypeIdx(stationName); - const int steta_index = stationEta + NRpcStEtaOffset; - const int stphi_index = idHelper.stationPhi(id) - 1; - const int dbr_index = doubletR - 1; - dbz_index = doubletZ - 1; - - // BMS 5/ |stEta|= 2 / dbR = 1 and 2 / dbZ = 3 - // BMS 6/ |stEta|= 4 / dbR = 2 / dbZ = 3 - // BMS 6/ |stEta|= 4 / dbR = 1 / dbZ = 2 - // these are the special cases where we want the rpc at doubletPhi = 2 - // to be addressed with a dbz_index=dbZ+1 - if (stname_index == RpcStatType::BMS) { - if (std::abs(stationEta) == 2 && doubletZ == 3 && doubletPhi == 2) - ++dbz_index; - else if (std::abs(stationEta) == 4 && doubletR == 2 && doubletZ == 3 && doubletPhi == 2) - ++dbz_index; - else if (std::abs(stationEta) == 4 && doubletR == 1 && doubletZ == 2 && doubletPhi == 2) - ++dbz_index; - } + int MuonDetectorManager::stgcIdentToArrayIdx(const Identifier& id) const { + const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id)); #ifndef NDEBUG - if (stname_index < 0 || stname_index >= NRpcStatType) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" station name index is out of range "<<stname_index<<" allowed 0-"<<(NRpcStatType-1)); - throw std::runtime_error("Out of range station index index"); - } - if (steta_index < 0 || steta_index >= NRpcStatEta) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" eta index is out of range "<<steta_index<<" allowed 0-"<<(NRpcStatEta-1)); - throw std::runtime_error("Out of range eta index"); - } - if (stphi_index < 0 || stphi_index >= NRpcStatPhi) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" phi index is out of range "<<stphi_index<<" allowed 0-"<<(NRpcStatPhi-1)); - throw std::runtime_error("Out of range phi index"); - } - if (dbr_index < 0 || dbr_index >= NDoubletR) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" doublet R index is out of range "<<dbr_index<<" allowed 0-"<<(NDoubletR-1)); - throw std::runtime_error("Out of doublet R index"); + if (hash <0) { + ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id)); + return -1; } - if (dbz_index < 0 || dbz_index >= NDoubletZ) { - ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" doublet Z index is out of range "<<dbz_index<<" allowed 0-"<<(NDoubletZ-1)); - throw std::runtime_error("Out of doublet Z index"); - } -#endif - /// Unfold the array by - /// [A][B][C][D][E] - /// a * BxCxDxE + b * CxDxE + c*DxE +d*E +e - constexpr int E = NDoubletZ; - constexpr int DxE = NDoubletR * E; - constexpr int CxDxE = NRpcStatPhi * DxE; - constexpr int BxCxDxE = NRpcStatEta * CxDxE; - const int arrayIdx = stname_index * BxCxDxE + steta_index * CxDxE + stphi_index * DxE + dbr_index * E + dbz_index; - return arrayIdx; +#endif + return hash; } - int MuonDetectorManager::mdtIdentToArrayIdx(const Identifier& id) const { - const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()}; - IdentifierHash hash{0}; - if (idHelper.get_detectorElement_hash(id,hash)) { + int MuonDetectorManager::rpcIdentToArrayIdx(const Identifier& id) const { + const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id)); +#ifndef NDEBUG + if (hash <0) { ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id)); return -1; - } - return static_cast<int>(hash); + } +#endif + return hash; } int MuonDetectorManager::tgcIdentToArrayIdx(const Identifier& id) const { - const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()}; - IdentifierHash hash{0}; - if (idHelper.get_detectorElement_hash(id,hash)) { + const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id)); +#ifndef NDEBUG + if (hash <0) { ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id)); return -1; } - return static_cast<int>(hash); +#endif + return hash; } int MuonDetectorManager::cscIdentToArrayIdx(const Identifier& id) const { - const CscIdHelper& idHelper{m_idHelperSvc->cscIdHelper()}; - IdentifierHash hash{0}; - if (idHelper.get_detectorElement_hash(id,hash)) { + const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id)); +#ifndef NDEBUG + if (hash <0) { ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id)); return -1; } - return static_cast<int>(hash); +#endif + return hash; } StatusCode MuonDetectorManager::updateAlignment(const ALineContainer& alineData) { @@ -629,9 +567,9 @@ namespace MuonGM { const MdtReadoutElement* MuonDetectorManager::getMdtReadoutElement(const IdentifierHash& id) const { #ifndef NDEBUG - if (id >= MdtRElMaxHash) { + if (id >= m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()) { ATH_MSG_WARNING(" try to getMdtReadoutElement with hashId " << (unsigned int)id << " outside range 0-" - << MdtRElMaxHash - 1 ); + << m_idHelperSvc->mdtIdHelper().detectorElement_hash_max() - 1 ); return nullptr; } #endif @@ -640,20 +578,20 @@ namespace MuonGM { const RpcReadoutElement* MuonDetectorManager::getRpcReadoutElement(const IdentifierHash& id) const { #ifndef NDEBUG - if (id >= RpcRElMaxHash) { + if (id >= m_idHelperSvc->rpcIdHelper().detectorElement_hash_max()) { ATH_MSG_WARNING(" try to getRpcReadoutElement with hashId " << (unsigned int)id << " outside range 0-" - << RpcRElMaxHash - 1 ); + << m_idHelperSvc->rpcIdHelper().detectorElement_hash_max() - 1 ); return nullptr; } #endif - return m_rpcArrayByHash[id]; + return m_rpcArray[id].get(); } const TgcReadoutElement* MuonDetectorManager::getTgcReadoutElement(const IdentifierHash& id) const { #ifndef NDEBUG - if (id >= TgcRElMaxHash) { + if (id >= m_idHelperSvc->tgcIdHelper().detectorElement_hash_max()) { ATH_MSG_WARNING(" try to getTgcReadoutElement with hashId " << (unsigned int)id << " outside range 0-" - << TgcRElMaxHash - 1 ); + << m_idHelperSvc->tgcIdHelper().detectorElement_hash_max() - 1 ); return nullptr; } #endif @@ -662,9 +600,9 @@ namespace MuonGM { const CscReadoutElement* MuonDetectorManager::getCscReadoutElement(const IdentifierHash& id) const { #ifndef NDEBUG - if (id >= CscRElMaxHash) { + if (id >= m_idHelperSvc->cscIdHelper().detectorElement_hash_max()) { ATH_MSG_WARNING(" try to getCscReadoutElement with hashId " << (unsigned int)id << " outside range 0-" - << CscRElMaxHash - 1 ); + << m_idHelperSvc->cscIdHelper().detectorElement_hash_max() - 1 ); return nullptr; } #endif @@ -684,13 +622,6 @@ namespace MuonGM { } void MuonDetectorManager::loadStationIndices() { - if (m_idHelperSvc->hasMDT()) { - const MdtIdHelper& mdtHelper{m_idHelperSvc->mdtIdHelper()}; - m_mdt_EIS_stName = mdtHelper.stationNameIndex("EIS"); - m_mdt_BIM_stName = mdtHelper.stationNameIndex("BIM"); - m_mdt_BME_stName = mdtHelper.stationNameIndex("BME"); - m_mdt_BMG_stName = mdtHelper.stationNameIndex("BMG"); - } if (!m_idHelperSvc->hasRPC()) return; const RpcIdHelper& rpcHelper{m_idHelperSvc->rpcIdHelper()}; m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BML"), RpcStatType::BML)); diff --git a/MuonSpectrometer/MuonIdHelpers/MuonIdHelpers/RpcIdHelper.h b/MuonSpectrometer/MuonIdHelpers/MuonIdHelpers/RpcIdHelper.h index 8b5c6017e7254b9c2e27aeb1dfa25664a66f366d..3c2e3824e1ba04a0109fca7f82fe8db102179622 100644 --- a/MuonSpectrometer/MuonIdHelpers/MuonIdHelpers/RpcIdHelper.h +++ b/MuonSpectrometer/MuonIdHelpers/MuonIdHelpers/RpcIdHelper.h @@ -178,10 +178,11 @@ private: virtual int init_detectorElement_hashes() override; int init_id_to_hashes(); - int zIndex(const Identifier& id) const; - static int zIndex(const std::string& name, int eta, int dR, int dZ, int dP) ; - std::unordered_map<Identifier, unsigned int> m_module_hashes; - std::unordered_map<Identifier, unsigned int > m_detectorElement_hashes; + + bool isExtraDetElId(const Identifier& id) const; + + std::unordered_map<Identifier, unsigned int> m_module_hashes{}; + std::unordered_map<Identifier, unsigned int > m_detectorElement_hashes{}; // compact id indices size_type m_DOUBLETR_INDEX{0}; diff --git a/MuonSpectrometer/MuonIdHelpers/src/MuonIdHelperSvc.cxx b/MuonSpectrometer/MuonIdHelpers/src/MuonIdHelperSvc.cxx index 7b1fa464c72f7fb94327c43ba3e7622c3abb9633..4484b8b1aa040102a9d5a3899452340165fac459 100644 --- a/MuonSpectrometer/MuonIdHelpers/src/MuonIdHelperSvc.cxx +++ b/MuonSpectrometer/MuonIdHelpers/src/MuonIdHelperSvc.cxx @@ -756,7 +756,7 @@ namespace Muon { IdentifierHash hash{}; if (idHelper.get_module_hash(id, hash) || static_cast<unsigned int>(hash) >= idHelper.module_hash_max()){ - ATH_MSG_WARNING("Failed to deduce module hash "<<toString(id)); + ATH_MSG_VERBOSE("Failed to deduce module hash "<<toString(id)); } return hash; } @@ -764,7 +764,7 @@ namespace Muon { IdentifierHash hash{}; if (idHelper.get_detectorElement_hash(id, hash) || static_cast<unsigned int>(hash)>= idHelper.detectorElement_hash_max()) { - ATH_MSG_WARNING("Failed to deduce detector element hash "<<toString(id)); + ATH_MSG_VERBOSE("Failed to deduce detector element hash "<<toString(id)); } return hash; } diff --git a/MuonSpectrometer/MuonIdHelpers/src/RpcIdHelper.cxx b/MuonSpectrometer/MuonIdHelpers/src/RpcIdHelper.cxx index 21c363b49e57dc6140f4757d7325e6d237645141..480077b0a23f66e715a424ea3fb64edad2af36c0 100644 --- a/MuonSpectrometer/MuonIdHelpers/src/RpcIdHelper.cxx +++ b/MuonSpectrometer/MuonIdHelpers/src/RpcIdHelper.cxx @@ -282,8 +282,6 @@ int RpcIdHelper::init_id_to_hashes() { const Identifier& id = m_detectorElement_vec[i]; m_detectorElement_hashes[id] = i; } - m_st_BMS = stationNameIndex("BMS"); - m_st_BIL = stationNameIndex("BIL"); return 0; } @@ -299,30 +297,13 @@ int RpcIdHelper::get_module_hash(const Identifier& id, IdentifierHash& hash_id) int RpcIdHelper::get_detectorElement_hash(const Identifier& id, IdentifierHash& hash_id) const { Identifier detElId = id; - // Certain chambers require doublet Phi in hashing (See zIndex()) - do not reset m_dpb_impl in these cases - bool reset_dbp = true; - const int station = stationName(id); - - if (m_st_BMS == station) { - int eta = stationEta(id); - int dR = doubletR(id); - int dZ = doubletZ(id); - if (std::abs(eta) == 2 && dZ == 3) { - reset_dbp = false; - } else if (std::abs(eta) == 4 && dR == 2 && dZ == 3) { - reset_dbp = false; - } else if (std::abs(eta) == 4 && dR == 1 && dZ == 2) { - reset_dbp = false; - } - } else if (m_st_BIL == station && std::abs(stationEta(id)) == 2) { - reset_dbp = false; + // Certain chambers require doublet Phi in hashing (See isExtraDetElId()) - do not reset m_dpb_impl in these cases + if (!isExtraDetElId(id)) { + m_dbp_impl.reset(detElId); } - - if (reset_dbp) m_dbp_impl.reset(detElId); m_gap_impl.reset(detElId); m_mea_impl.reset(detElId); - m_str_impl.reset(detElId); - + m_str_impl.reset(detElId); auto itr = m_detectorElement_hashes.find(detElId); if (itr == m_detectorElement_hashes.end()) { ATH_MSG_VERBOSE("Cannot find a valid detector element hash for "<<print_to_string(id)); @@ -782,6 +763,8 @@ int RpcIdHelper::init_detectorElement_hashes(void) { // create a vector(s) to retrieve the hashes for compact ids. For // the moment, we implement a hash for detector channels // + m_st_BMS = stationNameIndex("BMS"); + m_st_BIL = stationNameIndex("BIL"); // detector element hash IdContext context = detectorElement_context(); @@ -795,38 +778,25 @@ int RpcIdHelper::init_detectorElement_hashes(void) { Identifier id; get_id((*first), id); Identifier doubletZ_id = doubletZID(id); - int dZ = doubletZ(id); - int corrected_doubletZ = zIndex(id); - bool isInserted = false; - if (dZ == corrected_doubletZ) { - isInserted = ids.insert(doubletZ_id).second; - if (!isInserted) + if (!isExtraDetElId(id)) { + if (!ids.insert(doubletZ_id).second) ATH_MSG_DEBUG("init_detectorElement_hashes " << "Please check the dictionary for possible duplication for " << id); - } else { - isInserted = ids.insert(id).second; - if (!isInserted) { - ATH_MSG_ERROR("init_detectorElement_hashes " - << " Error: duplicated id for detector element id. nid " << (int)nids << " doubletPhi ID " << id); - return 1; - } + } else if (!ids.insert(id).second) { + ATH_MSG_ERROR("init_detectorElement_hashes " + << " Error: duplicated id for detector element id. nid " << (int)nids + << " doubletPhi ID " << id); + return 1; + } nids++; } } m_detectorElement_hash_max = ids.size(); ATH_MSG_INFO("The detector element hash max is " << (int)m_detectorElement_hash_max); - m_detectorElement_vec.resize(m_detectorElement_hash_max); - - nids = 0; - std::set<Identifier>::const_iterator first = ids.begin(); - std::set<Identifier>::const_iterator last = ids.end(); - for (; first != last && nids < m_detectorElement_vec.size(); ++first) { - m_detectorElement_vec[nids] = (*first); - nids++; - } - return (0); + m_detectorElement_vec.insert(m_detectorElement_vec.end(), ids.begin(), ids.end()); + return 0; } Identifier RpcIdHelper::elementID(int stationName, int stationEta, int stationPhi, int doubletR) const { @@ -873,10 +843,6 @@ Identifier RpcIdHelper::elementID(const Identifier& id, int doubletR, bool& isVa } Identifier RpcIdHelper::elementID(const Identifier& id) const { return parentID(id); } -/* Identifier panelID (const Identifier& padID, int gasGap,) const; */ -/* Identifier panelID (const Identifier& channelID) const; */ -/* Identifier panelID (int stationName, int stationEta, int stationPhi, int doubletR, */ -/* int doubletZ, int doubletPhi,int gasGap,) const; */ Identifier RpcIdHelper::panelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi) const { @@ -1147,17 +1113,9 @@ int RpcIdHelper::rpcTechnology() const { return rpcField; } -int RpcIdHelper::zIndex(const Identifier& id) const { - int station = stationName(id); - int eta = stationEta(id); - int dR = doubletR(id); - int dZ = doubletZ(id); - int dP = doubletPhi(id); - const std::string& name = stationNameString(station); - return zIndex(name, eta, dR, dZ, dP); -} - -int RpcIdHelper::zIndex(const std::string& name, int eta, int dR, int dZ, int dP) { +inline +bool RpcIdHelper::isExtraDetElId(const Identifier& id) const { + const int station = stationName(id); /** - from Stefania BMS5 which has the following structure: for dbr=1 there are 3 dbZ, first and second are made of a single @@ -1183,19 +1141,21 @@ int RpcIdHelper::zIndex(const std::string& name, int eta, int dR, int dZ, int dP BMS 5 are at StEta = +/- 2 and StPhi = 1,2,3,4,5,8 BMS 6 are at StEta = +/- 4 and StPhi = 1,2,3,4,5,8 */ - int dbz_index = dZ; - - if (name == "BMS") { - if (abs(eta) == 2 && dZ == 3) { - if (dP == 2) dbz_index++; - } else if (abs(eta) == 4 && dR == 2 && dZ == 3) { - if (dP == 2) dbz_index++; - } else if (abs(eta) == 4 && dR == 1 && dZ == 2) { - if (dP == 2) dbz_index++; + + + if (station == m_st_BMS) { + const int eta = stationEta(id); + const int dZ = doubletZ(id); + if (std::abs(eta) != 4 && dZ != 3) { + return false; } - } else if (name == "BIL") { - if (abs(eta) == 2 && dP == 2) dbz_index++; + const int dP = doubletPhi(id); + const int dR = doubletR(id); + return (dZ == 3 && dP == 2) || + (std::abs(eta) == 4 && dZ !=1 && dR != 2 && dP == 2); + } else if (m_st_BIL == station) { + return std::abs(stationEta(id)) == 2 && doubletPhi(id) == 2; } - return dbz_index; + return false; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/MuonStationIntersectCond/MuonIntersectGeoData.h b/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/MuonStationIntersectCond/MuonIntersectGeoData.h index 35b460eacd044f1b58cb43ea6acded46c43bf0d7..44038b3fb14fab20bd29f909facb8251e4f0e26b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/MuonStationIntersectCond/MuonIntersectGeoData.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/MuonStationIntersectCond/MuonIntersectGeoData.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONSTATIONINTERSECTCOND_MuonIntersectGeoData_H #define MUONSTATIONINTERSECTCOND_MuonIntersectGeoData_H @@ -38,8 +38,7 @@ namespace Muon { private: std::vector<Identifier> binPlusneighbours(const Identifier& id) const; - static constexpr int s_NumMaxMdtElements = MuonGM::MuonDetectorManager::MdtRElMaxHash; - std::array<std::shared_ptr<MdtIntersectGeometry>, s_NumMaxMdtElements> m_geometry{}; + std::vector<std::shared_ptr<MdtIntersectGeometry>> m_geometry{}; const IMuonIdHelperSvc* m_idHelperSvc{nullptr}; const MuonGM::MuonDetectorManager* m_detMgr{nullptr}; const MdtCondDbData* m_dbData{nullptr}; diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/src/MuonIntersectGeoData.cxx b/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/src/MuonIntersectGeoData.cxx index b11a27ec0fd9c4b32cfc74bd75cb0efe659fd710..22969f47106ec2ad2060e5ad72c67520dc77688e 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/src/MuonIntersectGeoData.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonRecUtils/MuonStationIntersectCond/src/MuonIntersectGeoData.cxx @@ -18,7 +18,7 @@ namespace Muon { MuonIntersectGeoData::MuonIntersectGeoData(MsgStream& log, const MuonGM::MuonDetectorManager* detMgr, const IMuonIdHelperSvc* idHelperSvc, const MdtCondDbData* dbData) : m_idHelperSvc{idHelperSvc}, m_detMgr{detMgr}, m_dbData{dbData} { - + m_geometry.resize(m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()); for (unsigned int n = 0; n < m_geometry.size(); ++n) { IdentifierHash id_hash{n}; const MuonGM::MdtReadoutElement* mdt_ele = detMgr->getMdtReadoutElement(id_hash); diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcTrackAnaAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcTrackAnaAlg.cxx index 284d179900fd645f91a8de8d1f48a22a1a5b1d4d..ccff9c6ade08bada5da385a1e17fbf084424e6fe 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcTrackAnaAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcTrackAnaAlg.cxx @@ -96,11 +96,9 @@ StatusCode RpcTrackAnaAlg::initRpcPanel() { m_StationNames[BO2] = {4, 5, 9, 10}; // doubletR = 2 std::vector<int> BMBO_StationNames = {2, 3, 4, 5, 8, 9, 10, 53}; - for (unsigned idetEl = 0; - idetEl < MuonGM::MuonDetectorManager::RpcRElMaxHash; ++idetEl) { - IdentifierHash hash{idetEl}; - const MuonGM::RpcReadoutElement* readoutEl = - muonMgr->getRpcReadoutElement(hash); + for (auto idetEl = rpcIdHelper.detectorElement_begin(); + idetEl != rpcIdHelper.detectorElement_end(); ++idetEl) { + const MuonGM::RpcReadoutElement* readoutEl = muonMgr->getRpcReadoutElement(*idetEl); if (!readoutEl) continue; diff --git a/graphics/VP1/VP1Systems/VP1GeometrySystems/src/VP1GeometrySystem.cxx b/graphics/VP1/VP1Systems/VP1GeometrySystems/src/VP1GeometrySystem.cxx index 13bfe1026f57f428edac56da9fcbc811f4b5d7a3..9ab023e1a0c75ee9c4ac5818503f91bbfcdfb63f 100644 --- a/graphics/VP1/VP1Systems/VP1GeometrySystems/src/VP1GeometrySystem.cxx +++ b/graphics/VP1/VP1Systems/VP1GeometrySystems/src/VP1GeometrySystem.cxx @@ -2200,15 +2200,30 @@ void VP1GeometrySystem::Imp::ensureInitPV2MuonStationMap() VP1Msg::message("WARNING: Could not get muon detector manager to construct volume -> muon station map!"); return; } - - for (unsigned i = 0; i < mgr->MdtRElMaxHash; ++i) - updatePV2MuonStationMap(mgr->getMdtReadoutElement(i)); - for (unsigned i = 0; i < mgr->CscRElMaxHash; ++i) - updatePV2MuonStationMap(mgr->getCscReadoutElement(i)); - for (unsigned i = 0; i < mgr->RpcRElMaxHash; ++i) - updatePV2MuonStationMap(mgr->getRpcReadoutElement(i)); - for (unsigned i = 0; i < mgr->TgcRElMaxHash; ++i) - updatePV2MuonStationMap(mgr->getTgcReadoutElement(i)); + if (mgr->nMdtRE()) { + for (auto det_el = mgr->mdtIdHelper()->detectorElement_begin(); + det_el != mgr->mdtIdHelper()->detectorElement_end(); ++det_el) { + updatePV2MuonStationMap(mgr->getMdtReadoutElement(*det_el)); + } + } + if (mgr->nRpcRE()) { + for (auto det_el = mgr->rpcIdHelper()->detectorElement_begin(); + det_el != mgr->rpcIdHelper()->detectorElement_end(); ++det_el) { + updatePV2MuonStationMap(mgr->getRpcReadoutElement(*det_el)); + } + } + if (mgr->nCscRE()) { + for (auto det_el = mgr->cscIdHelper()->detectorElement_begin(); + det_el != mgr->cscIdHelper()->detectorElement_end(); ++det_el) { + updatePV2MuonStationMap(mgr->getCscReadoutElement(*det_el)); + } + } + if (mgr->nTgcRE()) { + for (auto det_el = mgr->tgcIdHelper()->detectorElement_begin(); + det_el != mgr->tgcIdHelper()->detectorElement_end(); ++det_el) { + updatePV2MuonStationMap(mgr->getTgcReadoutElement(*det_el)); + } + } VP1Msg::messageDebug("Initialised physical volume link -> MuonStation map. Found "+str(pv2MuonStation.size())+" stations.");