diff --git a/MuonSpectrometer/Amdcsimrec/AmdcAth/src/AmdcsimrecAthenaSvc.cxx b/MuonSpectrometer/Amdcsimrec/AmdcAth/src/AmdcsimrecAthenaSvc.cxx index 7ebf9e6057d807c8e74aaadff1fee7c1cd019698..40da67c85a8f55df809ce4e5c56efaaef19f4857 100755 --- a/MuonSpectrometer/Amdcsimrec/AmdcAth/src/AmdcsimrecAthenaSvc.cxx +++ b/MuonSpectrometer/Amdcsimrec/AmdcAth/src/AmdcsimrecAthenaSvc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "StoreGate/StoreGateSvc.h" @@ -1504,14 +1504,9 @@ StatusCode AmdcsimrecAthenaSvc::SetAmdcAlineStoreFromExternal(AmdcAlineStore* pA float rotT ; - ALineMapContainer::const_iterator ialineF = pALineMapContainer->begin(); - ALineMapContainer::const_iterator ialineL = pALineMapContainer->end(); - - for (ALineMapContainer::const_iterator ialine = ialineF; ialine != ialineL; ++ialine){ - - ALinePar* al = ialine->second; - al->getAmdbId(StationType, jff, jzz, job); - al->getParameters(s, z, t, rotS, rotZ, rotT); + for (const auto& [id, al] : *pALineMapContainer) { + al.getAmdbId(StationType, jff, jzz, job); + al.getParameters(s, z, t, rotS, rotZ, rotT); double double_s = static_cast<double>( s ) ; double double_z = static_cast<double>( z ) ; @@ -1596,16 +1591,11 @@ StatusCode AmdcsimrecAthenaSvc::SetAmdcBlineStoreFromExternal(AmdcBlineStore* pA float ep; // local expansion float en; // local expansion - BLineMapContainer::const_iterator iblineF = pBLineMapContainer->begin(); - BLineMapContainer::const_iterator iblineL = pBLineMapContainer->end(); - - for (BLineMapContainer::const_iterator ibline = iblineF; ibline != iblineL; ++ibline){ + for (const auto& [id, bl] : *pBLineMapContainer) { + bl.getAmdbId(StationType, jff, jzz, job); - BLinePar* bl = ibline->second; - bl->getAmdbId(StationType, jff, jzz, job); - - bl->getParameters(bz, bp, bn, sp, sn, tw, - pg, tr, eg, ep, en); + bl.getParameters(bz, bp, bn, sp, sn, tw, + pg, tr, eg, ep, en); // ATH_MSG_DEBUG( "=============================SetAmdcBlineStoreFromExternal " ) ; // ATH_MSG_DEBUG( " StationType " << StationType ) ; @@ -1713,14 +1703,9 @@ StatusCode AmdcsimrecAthenaSvc::SetAmdcIlineStoreFromExternal(AmdcIlineStore* pA float rotZ ; float rotT ; - CscInternalAlignmentMapContainer::const_iterator iCscInternalAlignmentF = pCscInternalAlignmentMapContainer->begin(); - CscInternalAlignmentMapContainer::const_iterator iCscInternalAlignmentL = pCscInternalAlignmentMapContainer->end(); - - for (CscInternalAlignmentMapContainer::const_iterator iCscInternalAlignment = iCscInternalAlignmentF; iCscInternalAlignment != iCscInternalAlignmentL; ++iCscInternalAlignment){ - - CscInternalAlignmentPar* al = iCscInternalAlignment->second; - al->getAmdbId(StationType, jff, jzz, job,jlay); - al->getParameters(s, z, t, rotS, rotZ, rotT); + for (const auto& [id, al] : *pCscInternalAlignmentMapContainer) { + al.getAmdbId(StationType, jff, jzz, job,jlay); + al.getParameters(s, z, t, rotS, rotZ, rotT); double double_s = static_cast<double>( s ) ; double double_z = static_cast<double>( z ) ; @@ -1809,17 +1794,14 @@ void AmdcsimrecAthenaSvc::CheckALineMapContainer(const ALineMapContainer*& pALin float rotS2 ; float rotZ2 ; float rotT2 ; - - ALineMapContainer::const_iterator line1F = pALineMapContainer->begin(); - ALineMapContainer::const_iterator line1L = pALineMapContainer->end(); - ALineMapContainer::const_iterator line2F = pALineMapContainer->begin(); - - for (ALineMapContainer::const_iterator line1 = line1F; line1 != line1L; ++line1){ - ALinePar* a1 = line1->second; - a1->getAmdbId(StationType1, jff1, jzz1, job1); - for (ALineMapContainer::const_iterator line2 = line2F; line2 != line1; ++line2){ - ALinePar* a2 = line2->second; - a2->getAmdbId(StationType2, jff2, jzz2, job2); + + for (const auto& [id1, a1] : *pALineMapContainer) { + a1.getAmdbId(StationType1, jff1, jzz1, job1); + for (const auto& [id2, a2] : *pALineMapContainer) { + if (&a1 == &a2) { + break; + } + a2.getAmdbId(StationType2, jff2, jzz2, job2); if ( StationType1 == StationType2 && jff1 == jff2 && jzz1 == jzz2 @@ -1831,15 +1813,15 @@ void AmdcsimrecAthenaSvc::CheckALineMapContainer(const ALineMapContainer*& pALin << " job " << job1 ) ; /* ATH_MSG_DEBUG( " A LINE DOUBLE ENTRY id1 " - << " " << line1->first + << " " << id1 << " " << p_AtlasDetectorID->print_to_string(line1->first) ) ; ATH_MSG_DEBUG( " A LINE DOUBLE ENTRY id2 " - << " " << line2->first + << " " << id2 << " " << p_AtlasDetectorID->print_to_string(line2->first) ) ; */ - a1->getParameters(s1, z1, t1, rotS1, rotZ1, rotT1); - a2->getParameters(s2, z2, t2, rotS2, rotZ2, rotT2); + a1.getParameters(s1, z1, t1, rotS1, rotZ1, rotT1); + a2.getParameters(s2, z2, t2, rotS2, rotZ2, rotT2); ATH_MSG_DEBUG( " A LINE DOUBLE ENTRY values1 " << " " << s1 << " " << z1 @@ -1898,16 +1880,13 @@ void AmdcsimrecAthenaSvc::CheckBLineMapContainer(const BLineMapContainer*& pBLin float ep2; float en2; - BLineMapContainer::const_iterator line1F = pBLineMapContainer->begin(); - BLineMapContainer::const_iterator line1L = pBLineMapContainer->end(); - BLineMapContainer::const_iterator line2F = pBLineMapContainer->begin(); - - for (BLineMapContainer::const_iterator line1 = line1F; line1 != line1L; ++line1){ - BLinePar* b1 = line1->second; - b1->getAmdbId(StationType1, jff1, jzz1, job1); - for (BLineMapContainer::const_iterator line2 = line2F; line2 != line1; ++line2){ - BLinePar* b2 = line2->second; - b2->getAmdbId(StationType2, jff2, jzz2, job2); + for (const auto& [id1, b1] : *pBLineMapContainer) { + b1.getAmdbId(StationType1, jff1, jzz1, job1); + for (const auto& [id2, b2] : *pBLineMapContainer) { + if (&b1 == &b2) { + break; + } + b2.getAmdbId(StationType2, jff2, jzz2, job2); if ( StationType1 == StationType2 && jff1 == jff2 && jzz1 == jzz2 @@ -1919,17 +1898,17 @@ void AmdcsimrecAthenaSvc::CheckBLineMapContainer(const BLineMapContainer*& pBLin << " job " << job1 ) ; /* ATH_MSG_DEBUG( " B LINE DOUBLE ENTRY id1 " - << " " << line1->first + << " " << id1 << " " << p_AtlasDetectorID->print_to_string(line1->first) ) ; ATH_MSG_DEBUG( " B LINE DOUBLE ENTRY id2 " - << " " << line2->first + << " " << id2 << " " << p_AtlasDetectorID->print_to_string(line2->first) ) ; */ - b1->getParameters(bz1, bp1, bn1, sp1, sn1, tw1, - pg1, tr1, eg1, ep1, en1); - b2->getParameters(bz2, bp2, bn2, sp2, sn2, tw2, - pg2, tr2, eg2, ep2, en2); + b1.getParameters(bz1, bp1, bn1, sp1, sn1, tw1, + pg1, tr1, eg1, ep1, en1); + b2.getParameters(bz2, bp2, bn2, sp2, sn2, tw2, + pg2, tr2, eg2, ep2, en2); ATH_MSG_DEBUG( " B LINE DOUBLE ENTRY values1 " << " " << bz1 << " " << bp1 diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/ALinePar.h b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/ALinePar.h index c6bcbd349a9ff22492c2afe2ca8b0adff1a7d462..4540ebde5c2c224f2715b84da7d15b0d1b935965 100755 --- a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/ALinePar.h +++ b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/ALinePar.h @@ -28,7 +28,7 @@ class ALinePar : public MuonAlignmentPar { private: - // traslation parameters + // translation parameters float m_S; float m_Z; float m_T; diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/BLinePar.h b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/BLinePar.h index 2ba95e07782a27df31e1d175470320f2864078c1..a79cc1085db911ca598303ee493ce4c94f5f2496 100755 --- a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/BLinePar.h +++ b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/BLinePar.h @@ -38,7 +38,7 @@ class BLinePar : public MuonAlignmentPar { float& tr, float& eg, float& ep, - float& en); + float& en) const; float bz() const {return m_bz;} float bp() const {return m_bp;} float bn() const {return m_bn;} diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CorrContainer.h b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CorrContainer.h index f59e1e594167babf701e80b5e3ed46974a3d68cf..4bf99332575de69dcf5eb148712192dca2a337c1 100755 --- a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CorrContainer.h +++ b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CorrContainer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONALIGNMENTDATA_CORRCONTAINER_H @@ -13,26 +13,26 @@ #include "MuonAlignmentData/CscInternalAlignmentPar.h" #include "MuonAlignmentData/MdtAsBuiltPar.h" -typedef std::map<Identifier,ALinePar*> ALineMapContainer; +typedef std::map<Identifier,ALinePar> ALineMapContainer; CLASS_DEF(ALineMapContainer,1324994866,1) CLASS_DEF( CondCont<ALineMapContainer>, 1201194425, 0) -typedef std::map<Identifier,BLinePar*> BLineMapContainer; +typedef std::map<Identifier,BLinePar> BLineMapContainer; CLASS_DEF(BLineMapContainer,1124991377,1) CLASS_DEF( CondCont<BLineMapContainer>, 1332301344, 0) -typedef std::map<Identifier,CscInternalAlignmentPar*> CscInternalAlignmentMapContainer; +typedef std::map<Identifier,CscInternalAlignmentPar> CscInternalAlignmentMapContainer; CLASS_DEF(CscInternalAlignmentMapContainer,1285567354,1) CLASS_DEF( CondCont<CscInternalAlignmentMapContainer>, 1227105862, 0) -typedef std::map<Identifier,MdtAsBuiltPar*> MdtAsBuiltMapContainer; +typedef std::map<Identifier,MdtAsBuiltPar> MdtAsBuiltMapContainer; CLASS_DEF( MdtAsBuiltMapContainer , 1198729422 , 1 ) CLASS_DEF( CondCont<MdtAsBuiltMapContainer>, 1076645826, 0) -typedef std::map<Identifier,ALinePar*>::iterator iALineMap; -typedef std::map<Identifier,BLinePar*>::iterator iBLineMap; -typedef std::map<Identifier,CscInternalAlignmentPar*>::iterator iCscInternalAlignmentMap; -typedef std::map<Identifier,MdtAsBuiltPar*>::iterator iMdtAsBuiltMap; +typedef ALineMapContainer::iterator iALineMap; +typedef BLineMapContainer::iterator iBLineMap; +typedef CscInternalAlignmentMapContainer::iterator iCscInternalAlignmentMap; +typedef MdtAsBuiltMapContainer::iterator iMdtAsBuiltMap; #endif // MUONALIGNMENTDATA_ALINEPARCONTAINER_H diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CscInternalAlignmentPar.h b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CscInternalAlignmentPar.h index c77f91a50d3ef3eebb0332c7699aa3d96a781f45..c057959e908e7556cc445f8896c1b34507023c0e 100755 --- a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CscInternalAlignmentPar.h +++ b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/MuonAlignmentData/CscInternalAlignmentPar.h @@ -18,19 +18,19 @@ class CscInternalAlignmentPar : public MuonAlignmentPar { virtual ~CscInternalAlignmentPar() override = default; void setAmdbId(std::string type, int jff, int jzz, int job, int wireLayer); - void getAmdbId(std::string& type, int& jff, int& jzz, int& job, int& wireLayer); + void getAmdbId(std::string& type, int& jff, int& jzz, int& job, int& wireLayer) const; void setParameters(float s, float z, float t, float rotS, float rotZ, float rotT); void getParameters(float& s, float& z, float& t, - float& rotS, float& rotZ, float& rotT); + float& rotS, float& rotZ, float& rotT) const; private: // wire layer identifier int m_wireLayer; - // traslation parameters + // translation parameters float m_S; float m_Z; float m_T; diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/BLinePar.cxx b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/BLinePar.cxx index 879e5987d2958c42034fd2a26df6afc4e20da71a..a7befbe2406fc84a49f8f091156ad7e403b3dc62 100755 --- a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/BLinePar.cxx +++ b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/BLinePar.cxx @@ -54,7 +54,7 @@ void BLinePar::getParameters( float& bz, float& tr, float& eg, float& ep, - float& en ) + float& en ) const { bz = m_bz; bp = m_bp; diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/CscInternalAlignmentPar.cxx b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/CscInternalAlignmentPar.cxx index 2ed28c29ce9540f5a2c775c21bddfef0bc568fb8..a6c5173b1b4a7144455e5d63005b5a3e83b7af99 100755 --- a/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/CscInternalAlignmentPar.cxx +++ b/MuonSpectrometer/MuonAlignment/MuonAlignmentData/src/CscInternalAlignmentPar.cxx @@ -27,7 +27,7 @@ void CscInternalAlignmentPar::setParameters(float s, float z, float t, } void CscInternalAlignmentPar::getParameters(float& s, float& z, float& t, - float& rotS, float& rotZ, float& rotT) + float& rotS, float& rotZ, float& rotT) const { s = m_S; z = m_Z; @@ -48,7 +48,7 @@ void CscInternalAlignmentPar::setAmdbId(std::string type, int jff, int jzz, int return; } -void CscInternalAlignmentPar::getAmdbId(std::string& type, int& jff, int& jzz, int& job, int& wireLayer) +void CscInternalAlignmentPar::getAmdbId(std::string& type, int& jff, int& jzz, int& job, int& wireLayer) const { type = m_Type; jff = m_Jff; diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondAlg/src/MuonAlignmentCondAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondAlg/src/MuonAlignmentCondAlg.cxx index 5d0f593f6a38c2e76d08bc29c1d214bf85800c16..94658e568ccc7b3e06eca9aaa8463dcec4cf5450 100644 --- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondAlg/src/MuonAlignmentCondAlg.cxx +++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondAlg/src/MuonAlignmentCondAlg.cxx @@ -235,23 +235,8 @@ StatusCode MuonAlignmentCondAlg::loadAlignABLines() { // FIRST Update the MuonDetectorManager and THEN record the ALine. // ======================= - ALineMapContainer* alineDataTemp = new ALineMapContainer; - for (auto elem: *writeALineCdo.get() ) { - // new Aline - ALinePar* newALine = new ALinePar(); - std::string stationType; int jff; int jzz; int job; - elem.second->getAmdbId(stationType, jff, jzz, job); - newALine->setAmdbId(stationType, jff, jzz, job); - float s; float z; float t; float ths; float thz; float tht; - elem.second->getParameters(s, z, t, ths, thz, tht); - newALine->setParameters(s, z, t, ths, thz, tht); - - newALine->isNew(elem.second->isNew()); - alineDataTemp->insert(std::make_pair(elem.first,(ALinePar*)newALine)); - } - // FIXME: const_cast - if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateAlignment(alineDataTemp).isFailure()) ATH_MSG_ERROR("Unable to updateAlignment" ); + if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateAlignment(*writeALineCdo).isFailure()) ATH_MSG_ERROR("Unable to updateAlignment" ); else ATH_MSG_DEBUG("updateAlignment DONE" ); // if (m_muonDetMgrDS->updateAlignment(writeALineCdo.get()).isFailure()) ATH_MSG_ERROR("Unable to updateAlignment" ); // else ATH_MSG_DEBUG("updateAlignment DONE" ); @@ -269,23 +254,9 @@ StatusCode MuonAlignmentCondAlg::loadAlignABLines() { // ======================= // FIRST Update the MuonDetectorManager and THEN record the BLine. // ======================= - BLineMapContainer* blineDataTemp = new BLineMapContainer; - for (auto elem: *writeBLineCdo.get() ) { - // new Bline - BLinePar* newBLine = new BLinePar(); - std::string stationType; int jff; int jzz; int job; - elem.second->getAmdbId(stationType, jff, jzz, job); - newBLine->setAmdbId(stationType, jff, jzz, job); - newBLine->setParameters(elem.second->bz(), elem.second->bp(), elem.second->bn(), - elem.second->sp(), elem.second->sn(), elem.second->tw(), - elem.second->pg(), elem.second->tr(), elem.second->eg(), - elem.second->ep(), elem.second->en()); - newBLine->isNew(elem.second->isNew()); - blineDataTemp->insert(std::make_pair(elem.first,(BLinePar*)newBLine)); - } // FIXME: const_cast - if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateDeformations(blineDataTemp).isFailure()) ATH_MSG_ERROR("Unable to updateDeformations" ); + if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateDeformations(*writeBLineCdo).isFailure()) ATH_MSG_ERROR("Unable to updateDeformations" ); else ATH_MSG_DEBUG("updateDeformations DONE" ); // if (m_muonDetMgrDS->updateDeformations(writeBLineCdo.get()).isFailure()) ATH_MSG_ERROR("Unable to updateDeformations" ); // else ATH_MSG_DEBUG("updateDeformations DONE" ); @@ -660,42 +631,32 @@ StatusCode MuonAlignmentCondAlg::loadAlignABLines(std::string folderName, // new Aline ++nDecodedLines; ++nNewDecodedALines; - ALinePar* newALine = new ALinePar(); - newALine->setAmdbId(stationType, jff, jzz, job); - newALine->setParameters(s,z,t,ths,thz,tht); - newALine->isNew(true); - iALineMap ialine; - if((ialine = writeALineCdo->find(id)) != writeALineCdo->end()) { + ALinePar newALine; + newALine.setAmdbId(stationType, jff, jzz, job); + newALine.setParameters(s,z,t,ths,thz,tht); + newALine.isNew(true); + if (!writeALineCdo->insert_or_assign (id, std::move(newALine)).second) { ATH_MSG_WARNING("More than one (A-line) entry in folder " << folderName << " for " << stationType << " at Jzz/Jff " << jzz << "/" << jff << " --- keep the latest one"); - ALinePar* oldALinePar = (*ialine).second; - writeALineCdo->erase(id); - delete oldALinePar; oldALinePar=nullptr; --nNewDecodedALines; } - writeALineCdo->insert(std::make_pair(id,(ALinePar*)newALine)); if (hasBLine && thisRowHasBLine) { // new Bline ++nNewDecodedBLines; - BLinePar* newBLine = new BLinePar(); - newBLine->setAmdbId(stationType, jff, jzz, job); - newBLine->setParameters(bz, bp, bn, sp, sn, tw, pg, tr, eg, ep, en); - newBLine->isNew(true); - iBLineMap ibline; - if((ibline = writeBLineCdo->find(id)) != writeBLineCdo->end()) { + BLinePar newBLine; + newBLine.setAmdbId(stationType, jff, jzz, job); + newBLine.setParameters(bz, bp, bn, sp, sn, tw, pg, tr, eg, ep, en); + newBLine.isNew(true); + if (!writeBLineCdo->insert_or_assign (id, std::move(newBLine)).second) { ATH_MSG_WARNING("More than one (B-line) entry in folder " << folderName << " for " << stationType << " at Jzz/Jff " << jzz << "/" << jff << " --- keep the latest one"); - BLinePar* oldBLinePar = (*ibline).second; - writeBLineCdo->erase(id); - delete oldBLinePar; oldBLinePar=nullptr; --nNewDecodedBLines; } - writeBLineCdo->insert(std::make_pair(id,(BLinePar*)newBLine)); } } } @@ -904,23 +865,17 @@ StatusCode MuonAlignmentCondAlg::loadAlignILines(std::string folderName) // new Iline ++nDecodedLines; ++nNewDecodedILines; - CscInternalAlignmentPar* newILine = new CscInternalAlignmentPar(); - newILine->setAmdbId(stationType, jff, jzz, job, jlay); - newILine->setParameters(tras,traz,trat,rots,rotz,rott); - newILine->isNew(true); - iCscInternalAlignmentMap iiline; - if((iiline = writeCdo->find(id)) != writeCdo->end()) { + CscInternalAlignmentPar newILine; + newILine.setAmdbId(stationType, jff, jzz, job, jlay); + newILine.setParameters(tras,traz,trat,rots,rotz,rott); + newILine.isNew(true); + if (!writeCdo->insert_or_assign (id, newILine).second) { ATH_MSG_WARNING("More than one (I-line) entry in folder " << folderName << " for " << stationType << " at Jzz/Jff/Jlay " << jzz << "/" << jff << "/" << jlay << " --- keep the latest one"); - CscInternalAlignmentPar* oldCscInternalAlignmentPar = (*iiline).second; - writeCdo->erase(id); - delete oldCscInternalAlignmentPar; oldCscInternalAlignmentPar=nullptr; --nNewDecodedILines; } - // m_ilineData->insert(std::make_pair(id,(CscInternalAlignmentPar*)newILine)); - writeCdo->insert(std::make_pair(id,(CscInternalAlignmentPar*)newILine)); } } } @@ -935,23 +890,8 @@ StatusCode MuonAlignmentCondAlg::loadAlignILines(std::string folderName) // FIRST update MuonDetectorManager and THEN record the output cond object. // ======================= - CscInternalAlignmentMapContainer* ilineDataTemp = new CscInternalAlignmentMapContainer; - for (auto elem: *writeCdo.get() ) { - // new Iline - CscInternalAlignmentPar* newILine = new CscInternalAlignmentPar(); - std::string stationType; int jff; int jzz; int job; int jlay; - elem.second->getAmdbId(stationType, jff, jzz, job, jlay); - newILine->setAmdbId(stationType, jff, jzz, job, jlay); - float tras; float traz; float trat; float rots; float rotz; float rott; - elem.second->getParameters(tras,traz,trat,rots,rotz,rott); - newILine->setParameters(tras,traz,trat,rots,rotz,rott); - - newILine->isNew(elem.second->isNew()); - ilineDataTemp->insert(std::make_pair(elem.first,(CscInternalAlignmentPar*)newILine)); - } - // FIXME: const_cast - if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateCSCInternalAlignmentMap(ilineDataTemp).isFailure()) ATH_MSG_ERROR("Unable to updateCSCInternalAlignmentMap" ); + if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateCSCInternalAlignmentMap(*writeCdo).isFailure()) ATH_MSG_ERROR("Unable to updateCSCInternalAlignmentMap" ); else ATH_MSG_DEBUG("updateCSCInternalAlignmentMap DONE" ); // if (m_muonDetMgrDS->updateCSCInternalAlignmentMap(writeCdo.get()).isFailure()) ATH_MSG_ERROR("Unable to updateCSCInternalAlignmentMap" ); // else ATH_MSG_DEBUG("updateCSCInternalAlignmentMap DONE" ); @@ -1066,16 +1006,11 @@ StatusCode MuonAlignmentCondAlg::loadAlignAsBuilt(std::string folderName) ATH_MSG_VERBOSE("Station type jff jzz " << stationType << jff << " " << jzz ); ++nDecodedLines; ++nNewDecodedAsBuilt; - ciMdtAsBuiltMap iasbuild; - if((iasbuild = writeCdo->find(id)) != writeCdo->end()) { + if (!writeCdo->insert_or_assign (id, xPar).second) { ATH_MSG_WARNING( "More than one (As-built) entry in folder "<<folderName<<" for " << stationType<<" at Jzz/Jff "<<jzz<<"/"<< jff<<" --- keep the latest one" ); - MdtAsBuiltPar* oldMdtAsBuiltPar = (*iasbuild).second; - writeCdo->erase(id); - delete oldMdtAsBuiltPar; oldMdtAsBuiltPar=nullptr; --nNewDecodedAsBuilt; } - writeCdo->insert(std::make_pair(id,new MdtAsBuiltPar(xPar))); } } } @@ -1090,14 +1025,8 @@ StatusCode MuonAlignmentCondAlg::loadAlignAsBuilt(std::string folderName) // FIRST update MuonDetectorManager and THEN record the output cond object. // ======================= - MdtAsBuiltMapContainer* AsBuiltDataTemp = new MdtAsBuiltMapContainer; - for (auto elem: *writeCdo.get() ) { - // AsBuiltDataTemp->insert(std::make_pair(elem.first,(CscInternalAlignmentPar*)newILine)); - AsBuiltDataTemp->insert(std::make_pair(elem.first,new MdtAsBuiltPar(*(elem.second)))); - } - // FIXME: const_cast - if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateAsBuiltParams(AsBuiltDataTemp).isFailure()) ATH_MSG_ERROR("Unable to updateAsBuiltParams" ); + if (const_cast<MuonGM::MuonDetectorManager*>(m_muonDetMgrDS)->updateAsBuiltParams(*writeCdo).isFailure()) ATH_MSG_ERROR("Unable to updateAsBuiltParams" ); else ATH_MSG_DEBUG("updateAsBuiltParams DONE" ); // if (m_muonDetMgrDS->updateAsBuiltParams(writeCdo.get()).isFailure()) ATH_MSG_ERROR("Unable to updateAsBuiltParams" ); // else ATH_MSG_DEBUG("updateAsBuiltParams DONE" ); @@ -1122,15 +1051,13 @@ void MuonAlignmentCondAlg::dumpALines(const std::string& folderName, ATH_MSG_INFO("dumping A-lines for folder " << folderName); ATH_MSG_INFO("A type jff jzz job s(cm) z(cm) t(cm) ths(rad) thz(rad) tht(rad) ID"); - - for (auto aline : *writeALineCdo) { - Identifier ALineId = aline.first; - ALinePar* ALine = aline.second; + + for (const auto& [ALineId, ALine] : *writeALineCdo) { std::string stationType; int jff,jzz,job; - ALine->getAmdbId(stationType,jff,jzz,job); + ALine.getAmdbId(stationType,jff,jzz,job); float s,z,t,ths,thz,tht; - ALine->getParameters(s,z,t,ths,thz,tht); + ALine.getParameters(s,z,t,ths,thz,tht); ATH_MSG_INFO("A " << std::setiosflags(std::ios::fixed|std::ios::right) << std::setw(4) << stationType <<" " @@ -1156,14 +1083,12 @@ void MuonAlignmentCondAlg::dumpBLines(const std::string& folderName, ATH_MSG_INFO( "dumping B-lines for folder " << folderName); ATH_MSG_INFO( "B type jff jzz job bs bp bn sp sn tw pg tr eg ep en ID"); - for (auto bline : *writeBLineCdo) { - Identifier BLineId = bline.first; - BLinePar* BLine = bline.second; + for (const auto& [BLineId, BLine] : *writeBLineCdo) { std::string stationType; int jff,jzz,job; - BLine->getAmdbId(stationType,jff,jzz,job); + BLine.getAmdbId(stationType,jff,jzz,job); float bs,bp,bn,sp,sn,tw,pg,tr,eg,ep,en; - BLine->getParameters(bs,bp,bn,sp,sn,tw,pg,tr,eg,ep,en); + BLine.getParameters(bs,bp,bn,sp,sn,tw,pg,tr,eg,ep,en); ATH_MSG_INFO( "B " << std::setiosflags(std::ios::fixed|std::ios::right) << std::setw(4) << stationType <<" " @@ -1192,14 +1117,12 @@ void MuonAlignmentCondAlg::dumpILines(const std::string& folderName, ATH_MSG_INFO( "dumping I-lines for folder " << folderName); ATH_MSG_INFO( "I \ttype\tjff\tjzz\tjob\tjlay\ttras\ttraz\ttrat\trots\trotz\trott"); - for (auto iline : *writeCdo) { - Identifier ILineId = iline.first; - CscInternalAlignmentPar* ILine = iline.second; + for (const auto& [ILineId, ILine] : *writeCdo) { std::string stationType; int jff,jzz,job,jlay; - ILine->getAmdbId(stationType,jff,jzz,job,jlay); + ILine.getAmdbId(stationType,jff,jzz,job,jlay); float tras,traz,trat,rots,rotz,rott; - ILine->getParameters(tras,traz,trat,rots,rotz,rott); + ILine.getParameters(tras,traz,trat,rots,rotz,rott); ATH_MSG_INFO( "I\t" << std::setiosflags(std::ios::fixed|std::ios::right) << std::setw(4) << stationType <<"\t" @@ -1250,21 +1173,18 @@ void MuonAlignmentCondAlg::setALinesFromAscii(ALineMapContainer* writeALineCdo) // loop through A-line container and find the correct one std::string testStationType; - int testJff,testJzz,testJob; - ALinePar* ALine(0); - for (auto aline : *writeALineCdo) { - aline.second->getAmdbId(testStationType,testJff,testJzz,testJob); + for (auto& [id, ALine] : *writeALineCdo) { + int testJff,testJzz,testJob; + ALine.getAmdbId(testStationType,testJff,testJzz,testJob); if (testStationType==name && testJff == jff && - testJzz == jzz) { - ALine = aline.second; - break; - } + testJzz == jzz) + { + // set parameter if you found it + ALine.setParameters(tras,traz,trat,rots,rotz,rott); + break; + } } - - // set parameter if you found it - if (ALine) - ALine->setParameters(tras,traz,trat,rots,rotz,rott); } } return; @@ -1294,21 +1214,17 @@ void MuonAlignmentCondAlg::setAsBuiltFromAscii(MdtAsBuiltMapContainer* writeCdo) ATH_MSG_ERROR( "Invalid MDT identifiers: sta=" << stName << " eta=" << jzz << " phi=" << jff ); continue; } - std::map<Identifier,MdtAsBuiltPar*>::iterator ci = writeCdo->begin(); - if((ci = writeCdo->find(id)) != writeCdo->end()) + if (writeCdo->insert_or_assign (id, xPar).second) { - ATH_MSG_DEBUG( "Updating extisting entry in AsBuilt container for Station " <<stName<<" at Jzz/Jff "<<jzz<<"/"<< jff ); - ATH_MSG_DEBUG( "That is strange since it's read from ASCII so this station is listed twice!" ); - MdtAsBuiltPar* oldAsBuilt = (*ci).second; - writeCdo->erase(id); - delete oldAsBuilt; oldAsBuilt=nullptr; - } else { ATH_MSG_DEBUG( "New entry in AsBuilt container for Station " <<stName<<" at Jzz/Jff "<<jzz<<"/"<< jff<<" --- in the container with key "<< m_idHelperSvc->mdtIdHelper().show_to_string(id) ); } - writeCdo->insert(std::make_pair(id,new MdtAsBuiltPar(xPar))); - ++count; - } + else { + ATH_MSG_DEBUG( "Updating existing entry in AsBuilt container for Station " <<stName<<" at Jzz/Jff "<<jzz<<"/"<< jff ); + ATH_MSG_DEBUG( "That is strange since it's read from ASCII so this station is listed twice!" ); + } + ++count; + } } } ATH_MSG_INFO( "Parsed AsBuilt parameters: " << count ); diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/AlignCondAthTest.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/AlignCondAthTest.cxx index fc7c9331795d7616b24e1e334ce8cf43f0f7368d..5d06886fd29ba66f41c489c44ee53ca67a3a0de3 100755 --- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/AlignCondAthTest.cxx +++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondTest/src/AlignCondAthTest.cxx @@ -149,16 +149,12 @@ StatusCode AlignCondAthTest::finalize() { StatusCode AlignCondAthTest::checkALines(const MuonGM::MuonDetectorManager* manager, std::ofstream* fout) { - - const ALineMapContainer* alineDataTemp = manager->ALineContainer(); - for (auto aline : *alineDataTemp) { - Identifier ALineId = aline.first; - const ALinePar* ALine = aline.second; + for (const auto& [ALineId, ALine] : *manager->ALineContainer()) { std::string stationType; int jff,jzz,job; - ALine->getAmdbId(stationType,jff,jzz,job); + ALine.getAmdbId(stationType,jff,jzz,job); float s,z,t,ths,thz,tht; - ALine->getParameters(s,z,t,ths,thz,tht); + ALine.getParameters(s,z,t,ths,thz,tht); (*fout) << "A " << std::setiosflags(std::ios::fixed|std::ios::right) << std::setw(4) << stationType <<" " @@ -171,7 +167,7 @@ StatusCode AlignCondAthTest::checkALines(const MuonGM::MuonDetectorManager* mana << std::setw(6) << std::setprecision(6) << ths <<" " << std::setw(6) << std::setprecision(6) << thz <<" " << std::setw(6) << std::setprecision(6) << tht <<" " - << ALineId << std::endl; + << &ALineId << std::endl; } @@ -180,16 +176,12 @@ StatusCode AlignCondAthTest::checkALines(const MuonGM::MuonDetectorManager* mana StatusCode AlignCondAthTest::checkBLines(const MuonGM::MuonDetectorManager* manager, std::ofstream* fout) { - - const BLineMapContainer* blineDataTemp = manager->BLineContainer(); - for (auto bline : *blineDataTemp) { - Identifier BLineId = bline.first; - BLinePar* BLine = bline.second; + for (const auto& [BLineId, BLine] : *manager->BLineContainer()) { std::string stationType; int jff,jzz,job; - BLine->getAmdbId(stationType,jff,jzz,job); + BLine.getAmdbId(stationType,jff,jzz,job); float bs,bp,bn,sp,sn,tw,pg,tr,eg,ep,en; - BLine->getParameters(bs,bp,bn,sp,sn,tw,pg,tr,eg,ep,en); + BLine.getParameters(bs,bp,bn,sp,sn,tw,pg,tr,eg,ep,en); (*fout) << "B " << std::setiosflags(std::ios::fixed|std::ios::right) << std::setw(4) << stationType <<" " diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/CscReadoutElement.h b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/CscReadoutElement.h index 242c466753e90e8f7f2b8eb732c283596ded62c3..09e475194a7f543e8011cde0909bdb9a30d390fa 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/CscReadoutElement.h +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/CscReadoutElement.h @@ -230,7 +230,7 @@ namespace MuonGM { void set_wirepitch (double ); void set_first_strip_localcoo(double ); void set_first_wire_localcoo (double ); - void setCscInternalAlignmentPar(CscInternalAlignmentPar* ); + void setCscInternalAlignmentPar(const CscInternalAlignmentPar& ); void setCscInternalAlignmentParams(); // // internal alignment // double m_cscIntTransl[4][3]; // first index is wireLayer, second = 0,1,2 for s,z,t diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h index d79e1cb7d71fe3525473ceabe5bf565fdc991448..44a4f7f52a717fb13911f1a5b61cbbade2812866 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h @@ -152,7 +152,7 @@ public: const Amg::Vector3D tubeFrame_localROPos(Identifier id) const; // defining B-line parameters - /*inline*/ void setBLinePar(BLinePar* bLine); + /*inline*/ void setBLinePar(const BLinePar* bLine); inline void clearBLinePar(); inline const BLinePar* getBLinePar() const {return m_BLinePar;} @@ -255,7 +255,7 @@ private: std::vector<CxxUtils::CachedUniquePtr<Amg::Transform3D> > m_deformTransf; // one per tube std::vector<CxxUtils::CachedUniquePtr<Amg::Transform3D> > m_backupDeformTransf; // one per tube - BLinePar* m_BLinePar; + const BLinePar* m_BLinePar; CxxUtils::CachedValue<Amg::Vector3D> m_elemNormal; // one std::vector<CxxUtils::CachedUniquePtr<Trk::SaggedLineSurface> > m_tubeSurfaces; // one per tube std::vector<CxxUtils::CachedUniquePtr<Trk::CylinderBounds> > m_tubeBounds; // one per step in tube-length diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h index 7f2944850ca3c7a0751ca383bd84e985ddda0bf9..23a305fb60bff1daf254a075631793aef154bcac 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h @@ -29,10 +29,10 @@ #define optimRE true -typedef std::map<Identifier,ALinePar*>::const_iterator ciALineMap; -typedef std::map<Identifier,BLinePar*>::const_iterator ciBLineMap; -typedef std::map<Identifier,CscInternalAlignmentPar*>::const_iterator ciCscInternalAlignmentMap; -typedef std::map<Identifier,MdtAsBuiltPar*>::const_iterator ciMdtAsBuiltMap; +typedef ALineMapContainer::const_iterator ciALineMap; +typedef BLineMapContainer::const_iterator ciBLineMap; +typedef CscInternalAlignmentMapContainer::const_iterator ciCscInternalAlignmentMap; +typedef MdtAsBuiltMapContainer::const_iterator ciMdtAsBuiltMap; namespace MuonGM { @@ -89,13 +89,13 @@ namespace MuonGM { void addsTgcReadoutElement_withIdFields (sTgcReadoutElement*, int iStname, int iStEta, int iStPhi, int imL);//!< store the sTgcReadoutElement using as "key" the identifier void addMMReadoutElement_withIdFields (MMReadoutElement*, int iStname, int iStEta, int iStPhi, int imL);//!< store the MMReadoutElement using as "key" the identifier - // storeTgcReadoutParams - void storeTgcReadoutParams(TgcReadoutParams* x); + // storeTgcReadoutParams takes ownership. + void storeTgcReadoutParams(const TgcReadoutParams* x); // storeCscInternalAlignmentParams - void storeCscInternalAlignmentParams(CscInternalAlignmentPar* x); + void storeCscInternalAlignmentParams(const CscInternalAlignmentPar& x); - void storeMdtAsBuiltParams(MdtAsBuiltPar* x); + void storeMdtAsBuiltParams(const MdtAsBuiltPar& x); // access to Readout Elements const MdtReadoutElement* getMdtReadoutElement(Identifier) const;//!< access via extended identifier (requires unpacking) @@ -362,11 +362,11 @@ namespace MuonGM { inline ciCscInternalAlignmentMap CscALineMapEnd() const; inline ciMdtAsBuiltMap MdtAsBuiltMapBegin() const; inline ciMdtAsBuiltMap MdtAsBuiltMapEnd() const; - StatusCode updateAlignment(const ALineMapContainer* a); - StatusCode updateDeformations(const BLineMapContainer* a); - StatusCode updateAsBuiltParams(const MdtAsBuiltMapContainer* a); + StatusCode updateAlignment(const ALineMapContainer& a); + StatusCode updateDeformations(const BLineMapContainer& a); + StatusCode updateAsBuiltParams(const MdtAsBuiltMapContainer& a); StatusCode initCSCInternalAlignmentMap(); - StatusCode updateCSCInternalAlignmentMap(const CscInternalAlignmentMapContainer* cscIntAline); + StatusCode updateCSCInternalAlignmentMap(const CscInternalAlignmentMapContainer& cscIntAline); void initABlineContainers(); // get Mdt AsBuilt parameters for chamber specified by Identifier @@ -441,21 +441,16 @@ namespace MuonGM { unsigned int m_n_tgcDE; // TODO: New Small Wheel - // pointers to the XxxDetectorElements (with granularity a la EDM) - std::vector<TgcReadoutParams*> m_TgcReadoutParamsVec; - // vector of CSC Internal Alignment parameters (just for init purposes) filled from file or Oracle table (RDBReaderAccess) and then deleted by the factory; - MdtDetectorElement* m_mdtDEArray[MdtDetElMaxHash]; RpcDetectorElement* m_rpcDEArray[RpcDetElMaxHash]; TgcDetectorElement* m_tgcDEArray[TgcDetElMaxHash]; CscDetectorElement* m_cscDEArray[CscDetElMaxHash]; // TODO: New Small Wheel - ALineMapContainer * m_aLineContainer; - BLineMapContainer * m_bLineContainer; - // CscInternalAlignmentMapContainer (pointers) will be created by RDBReaderAccess at the first attempt to store a CscInternalAlignmentPar -rot and transl parameters are held by the CSCredoutElements and the corresponding A-line is provided with this map (key Identifier) by the manager - the manager is responsible to delete the CscInternalAlignmentPar - CscInternalAlignmentMapContainer * m_cscALineContainer; - MdtAsBuiltMapContainer* m_AsBuiltParamsMap; + ALineMapContainer m_aLineContainer; + BLineMapContainer m_bLineContainer; + CscInternalAlignmentMapContainer m_cscALineContainer; + MdtAsBuiltMapContainer m_AsBuiltParamsMap; }; @@ -550,28 +545,28 @@ namespace MuonGM { const ALineMapContainer* MuonDetectorManager::ALineContainer() const - {return m_aLineContainer;} + {return &m_aLineContainer;} const BLineMapContainer* MuonDetectorManager::BLineContainer() const - {return m_bLineContainer;} + {return &m_bLineContainer;} const CscInternalAlignmentMapContainer* MuonDetectorManager::CscInternalAlignmentContainer() const - {return m_cscALineContainer;} + {return &m_cscALineContainer;} const MdtAsBuiltMapContainer* MuonDetectorManager::MdtAsBuiltContainer() const - {return m_AsBuiltParamsMap;} - - ciALineMap MuonDetectorManager::ALineMapBegin() const {return m_aLineContainer->begin();} - ciBLineMap MuonDetectorManager::BLineMapBegin() const {return m_bLineContainer->begin();} - ciALineMap MuonDetectorManager::ALineMapEnd() const {return m_aLineContainer->end();} - ciBLineMap MuonDetectorManager::BLineMapEnd() const {return m_bLineContainer->end();} - ciCscInternalAlignmentMap MuonDetectorManager::CscALineMapBegin() const {return m_cscALineContainer->begin();} - ciCscInternalAlignmentMap MuonDetectorManager::CscALineMapEnd() const {return m_cscALineContainer->end();} - ciMdtAsBuiltMap MuonDetectorManager::MdtAsBuiltMapBegin() const {return m_AsBuiltParamsMap->begin();} - ciMdtAsBuiltMap MuonDetectorManager::MdtAsBuiltMapEnd() const {return m_AsBuiltParamsMap->end();} + {return &m_AsBuiltParamsMap;} + + ciALineMap MuonDetectorManager::ALineMapBegin() const {return m_aLineContainer.begin();} + ciBLineMap MuonDetectorManager::BLineMapBegin() const {return m_bLineContainer.begin();} + ciALineMap MuonDetectorManager::ALineMapEnd() const {return m_aLineContainer.end();} + ciBLineMap MuonDetectorManager::BLineMapEnd() const {return m_bLineContainer.end();} + ciCscInternalAlignmentMap MuonDetectorManager::CscALineMapBegin() const {return m_cscALineContainer.begin();} + ciCscInternalAlignmentMap MuonDetectorManager::CscALineMapEnd() const {return m_cscALineContainer.end();} + ciMdtAsBuiltMap MuonDetectorManager::MdtAsBuiltMapBegin() const {return m_AsBuiltParamsMap.begin();} + ciMdtAsBuiltMap MuonDetectorManager::MdtAsBuiltMapEnd() const {return m_AsBuiltParamsMap.end();} void MuonDetectorManager::setCacheFillingFlag(int value){m_cacheFillingFlag = value;} diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonStation.h b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonStation.h index 1dbd8d361f1fe73b72d1b756fabfa1c5816e72d3..20876dc7f8804bee94030bb1d8c6bb2021517a07 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonStation.h +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonStation.h @@ -105,7 +105,7 @@ public: void fillCache(); void clearBLineCache(); void fillBLineCache(); - void setBline(BLinePar * bline); + void setBline(const BLinePar * bline); inline GeoAlignableTransform* getGeoTransform() const; inline HepGeom::Transform3D getTransform() const; inline const HepGeom::Transform3D* getNativeToAmdbLRS() const; diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/CscReadoutElement.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/CscReadoutElement.cxx index 74bdb9d92e137d22046b37e9baefc8441010d95e..df1436262cd9404d69c1807cc9d2ab552769f83b 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/CscReadoutElement.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/CscReadoutElement.cxx @@ -700,7 +700,7 @@ void CscReadoutElement::setCscInternalAlignmentParams() } // } -void CscReadoutElement::setCscInternalAlignmentPar(CscInternalAlignmentPar* x) +void CscReadoutElement::setCscInternalAlignmentPar(const CscInternalAlignmentPar& x) { // get id helper @@ -711,19 +711,19 @@ void CscReadoutElement::setCscInternalAlignmentPar(CscInternalAlignmentPar* x) int jzz = 0; int job = 0; int wlayer = 0; - x->getAmdbId(stName, jff, jzz, job, wlayer); + x.getAmdbId(stName, jff, jzz, job, wlayer); float s_trans =0.; float z_trans =0.; float t_trans =0.; float s_rot =0.; float z_rot =0.; float t_rot =0.; - x->getParameters(s_trans, - z_trans, - t_trans, - s_rot , - z_rot , - t_rot ); + x.getParameters(s_trans, + z_trans, + t_trans, + s_rot , + z_rot , + t_rot ); bool notAllowedWLayer = (wlayer>4 || wlayer<1); if (stName != getStationName().substr(0,3) || jff != getStationPhi() || jzz != getStationEta() || notAllowedWLayer ) diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx index 75959d9928cd5f2d6f3df027d8b3c09b488031f6..f8dd1f66bc3ba4c4485b641107024b5609af232a 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx @@ -1674,7 +1674,7 @@ void MdtReadoutElement::clearCache() clearBLineCache(); } -void MdtReadoutElement::setBLinePar(BLinePar* bLine) +void MdtReadoutElement::setBLinePar(const BLinePar* bLine) { #ifndef NDEBUG MsgStream log(Athena::getMessageSvc(),"MdtReadoutElement"); diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx index bb555630f97bb514d81222e7e0cd1ad6da491eb5..cfd0b574833ec65b06ff4c181df989f40ea37aab 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx @@ -100,10 +100,6 @@ MuonDetectorManager::MuonDetectorManager() { m_n_mdtDE = m_n_cscDE = m_n_tgcDE = m_n_rpcDE = 0; m_n_mdtRE = m_n_cscRE = m_n_tgcRE = m_n_rpcRE = m_n_mmcRE = m_n_stgRE = 0; - m_aLineContainer = nullptr; - m_bLineContainer = nullptr; - m_cscALineContainer = nullptr; - m_AsBuiltParamsMap = nullptr; setName("Muon"); m_cachingFlag = 1; @@ -189,38 +185,6 @@ MuonDetectorManager::~MuonDetectorManager() { { delete i->second; i->second = nullptr; } - - for (std::vector<TgcReadoutParams*>::iterator i=m_TgcReadoutParamsVec.begin(); - i!=m_TgcReadoutParamsVec.end();++i) - { - delete (*i); *i = nullptr; - } - - if (nullptr != m_cscALineContainer) { - for (auto elem: *m_cscALineContainer ) { - if (nullptr != elem.second) {delete elem.second; elem.second = nullptr;} - } - delete m_cscALineContainer; m_cscALineContainer = nullptr; - } - - if (nullptr != m_AsBuiltParamsMap) { - for (auto elem: *m_AsBuiltParamsMap ) { - if (nullptr != elem.second) {delete elem.second; elem.second = nullptr;} - } - delete m_AsBuiltParamsMap; m_AsBuiltParamsMap = nullptr; - } - - if (nullptr != m_aLineContainer) { - for (auto elem: *m_aLineContainer ) { - if (nullptr != elem.second) {delete elem.second; elem.second = nullptr;} - } - } - if (nullptr != m_bLineContainer) { - for (auto elem: *m_bLineContainer ) { - if (nullptr != elem.second) {delete elem.second; elem.second = nullptr;} - } - } - } @@ -1223,10 +1187,10 @@ void MuonDetectorManager::initABlineContainers() { MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); - m_aLineContainer = new ALineMapContainer; - m_bLineContainer = new BLineMapContainer; + m_aLineContainer.clear(); + m_bLineContainer.clear(); - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG << "Init A/B Line Containers - pointers are <" <<(uintptr_t)m_aLineContainer << "> and <" << (uintptr_t)m_bLineContainer << ">" << endmsg; + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG << "Init A/B Line Containers - pointers are <" <<(uintptr_t)&m_aLineContainer << "> and <" << (uintptr_t)&m_bLineContainer << ">" << endmsg; // loop over stations to fill the A-line map at start-up for (std::map< std::string, MuonStation * >::const_iterator ist=m_MuonStationMap.begin(); @@ -1237,19 +1201,19 @@ MuonDetectorManager::initABlineContainers() int jzz = ms->getEtaIndex(); std::string stType = ms->getStationType(); - ALinePar* newALine = new ALinePar(); - newALine->setAmdbId(stType, jff, jzz, 0); + ALinePar newALine; + newALine.setAmdbId(stType, jff, jzz, 0); if (ms->hasALines()) { - newALine->setParameters(ms->getALine_tras(),ms->getALine_traz(),ms->getALine_trat(), - ms->getALine_rots(),ms->getALine_rotz(),ms->getALine_rott()); + newALine.setParameters(ms->getALine_tras(),ms->getALine_traz(),ms->getALine_trat(), + ms->getALine_rots(),ms->getALine_rotz(),ms->getALine_rott()); } else { if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"No starting A-lines for Station "<<stType<<" Jzz/Jff "<<jzz<<"/"<<jff<<endmsg; - newALine->setParameters(0.,0.,0.,0.,0.,0.); + newALine.setParameters(0.,0.,0.,0.,0.,0.); } - newALine->isNew(true); + newALine.isNew(true); Identifier id; //= m_mdtIdHelper->elementID(stType, jzz, jff); @@ -1279,15 +1243,15 @@ MuonDetectorManager::initABlineContainers() id = m_mdtIdHelper->elementID(stType, jzz, jff); if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Filling A-line container with entry for key = "<<m_mdtIdHelper->show_to_string(id)<<endmsg; } - m_aLineContainer->insert(std::make_pair(id,(ALinePar*)newALine)); + m_aLineContainer.emplace(id, std::move(newALine)); if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"<Filling A-line container with entry for key >"<<m_mdtIdHelper->show_to_string(id)<<endmsg; } - log << MSG::INFO << "Init A/B Line Containers - done - size is respectively " << m_aLineContainer->size() << "/" << m_bLineContainer->size() << endmsg; + log << MSG::INFO << "Init A/B Line Containers - done - size is respectively " << m_aLineContainer.size() << "/" << m_bLineContainer.size() << endmsg; } StatusCode -MuonDetectorManager::updateAlignment(const ALineMapContainer * alineData) +MuonDetectorManager::updateAlignment(const ALineMapContainer& alineData) { #ifdef TESTBLINES { @@ -1308,32 +1272,25 @@ MuonDetectorManager::updateAlignment(const ALineMapContainer * alineData) } #endif MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); - if (alineData == nullptr) { - log<<MSG::WARNING<<"Undefined pointer to temporary A-line container - nothing to do here"<<endmsg; - return StatusCode::SUCCESS; - } - if (alineData->size()==0) { + if (alineData.empty()) { log<<MSG::WARNING<<"Empty temporary A-line container - nothing to do here"<<endmsg; return StatusCode::SUCCESS; } - else log<<MSG::INFO<<"temporary A-line container with size = "<<alineData->size()<<endmsg; + else log<<MSG::INFO<<"temporary A-line container with size = "<<alineData.size()<<endmsg; // loop over the container of the updates passed by the MuonAlignmentDbTool - ciALineMap cialine = alineData->begin();//ALineMapBegin(); unsigned int nLines = 0; unsigned int nUpdates = 0; - for (; cialine != alineData->end(); cialine++) + for (const auto& [ALineId, ALine] : alineData) { nLines++; - Identifier ALineId = (*cialine).first; - ALinePar* ALine = (*cialine).second; std::string stType = ""; int jff = 0; int jzz = 0; int job = 0; - ALine->getAmdbId(stType, jff, jzz, job); - if (!ALine->isNew()) + ALine.getAmdbId(stType, jff, jzz, job); + if (!ALine.isNew()) { log<<MSG::WARNING <<"ALinePar with AmdbId " @@ -1344,124 +1301,97 @@ MuonDetectorManager::updateAlignment(const ALineMapContainer * alineData) if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG <<"ALinePar with AmdbId " <<stType<<" "<<jzz<<" "<<jff<<" "<<job<<" is new ID = "<<m_mdtIdHelper->show_to_string(ALineId)<<endmsg; + + + MuonStation* thisStation = getMuonStation(stType, jzz, jff); + if (!thisStation) { + log<<MSG::WARNING + <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job + <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; + continue; + } + + if (job != 0) { + // job different than 0 (standard for TGC conditions for Sept 2010 repro.) + if (stType.substr(0,1)=="T") + { + if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG + <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job + <<" has JOB not 0 - this is expected for TGC"<<endmsg; + } + else + { + log<<MSG::WARNING + <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job + <<" has JOB not 0 - this is NOT EXPECTED yet for non TGC chambers - skipping this A-line"<<endmsg; + continue; + } + } + + // record this A-line in the historical A-line container + auto [it, flag] = m_aLineContainer.insert_or_assign (ALineId, ALine); + ALinePar& newALine = it->second; + if (flag) + { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in A-line container for Station " + <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff <<" --- in the container with key "<< m_mdtIdHelper->show_to_string(ALineId)<< endmsg; + } + else { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in A-line container for Station " + <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; + } + if (job == 0) { - MuonStation* thisStation = getMuonStation(stType, jzz, jff); - if (thisStation) - { - float s,z,t,ths,thz,tht; - ALine->getParameters(s,z,t,ths,thz,tht); - if ( m_controlAlines%10 == 0) tht = 0.; - if (int(m_controlAlines/10)%10 == 0) thz = 0.; - if (int(m_controlAlines/100)%10 == 0) ths = 0.; - if (int(m_controlAlines/1000)%10 == 0) t = 0.; - if (int(m_controlAlines/10000)%10 == 0) z = 0.; - if (int(m_controlAlines/100000)%10== 0) s = 0.; - if (m_controlAlines!=111111) ALine->setParameters(s,z,t,ths,thz,tht); - if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting delta transform for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<" params are = "<<s<<" "<<z<<" "<<t<<" "<<ths<<" "<<thz<<" "<<tht<<endmsg; - thisStation->setDelta_fromAline( s,z,t,ths,thz,tht ); + float s,z,t,ths,thz,tht; + newALine.getParameters(s,z,t,ths,thz,tht); + if ( m_controlAlines%10 == 0) tht = 0.; + if (int(m_controlAlines/10)%10 == 0) thz = 0.; + if (int(m_controlAlines/100)%10 == 0) ths = 0.; + if (int(m_controlAlines/1000)%10 == 0) t = 0.; + if (int(m_controlAlines/10000)%10 == 0) z = 0.; + if (int(m_controlAlines/100000)%10== 0) s = 0.; + if (m_controlAlines!=111111) newALine.setParameters(s,z,t,ths,thz,tht); + if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting delta transform for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<" params are = "<<s<<" "<<z<<" "<<t<<" "<<ths<<" "<<thz<<" "<<tht<<endmsg; + thisStation->setDelta_fromAline( s,z,t,ths,thz,tht ); #ifdef TESTBLINES - ALine->setParameters( 0., 0., 0., 0., 0., 0.); - thisStation->setDelta_fromAline( 0., 0., 0., 0., 0., 0.); + newALine.setParameters( 0., 0., 0., 0., 0., 0.); + thisStation->setDelta_fromAline( 0., 0., 0., 0., 0., 0.); #endif - if (cacheFillingFlag()) - { - thisStation->clearCache(); - thisStation->fillCache(); - } - else - { - thisStation->refreshCache(); - } - nUpdates++; - } - else - { - log<<MSG::WARNING - <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job - <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; - continue; - } - // record this A-line in the historical A-line container - ciALineMap ci = ALineMapBegin(); - if((ci = ALineContainer()->find(ALineId)) != ALineMapEnd()) - { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in A-line container for Station " - <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; - ALinePar * oldALine = (*ci).second; - m_aLineContainer->erase(ALineId); - delete oldALine; - } - else - { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in A-line container for Station " - <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff <<" --- in the container with key "<< m_mdtIdHelper->show_to_string(ALineId)<< endmsg; - } - m_aLineContainer->insert(std::make_pair(ALineId,ALine)); + if (cacheFillingFlag()) + { + thisStation->clearCache(); + thisStation->fillCache(); + } + else + { + thisStation->refreshCache(); + } } else - {// job different than 0 (standard for TGC conditions for Sept 2010 repro.) - if (stType.substr(0,1)=="T") - { - if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG - <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job - <<" has JOB not 0 - this is expected for TGC"<<endmsg; - } - else - { - log<<MSG::WARNING - <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job - <<" has JOB not 0 - this is NOT EXPECTED yet for non TGC chambers - skipping this A-line"<<endmsg; - continue; - } - MuonStation* thisStation = getMuonStation(stType, jzz, jff); - if (thisStation) - { - float s,z,t,ths,thz,tht; - ALine->getParameters(s,z,t,ths,thz,tht); - if ( m_controlAlines%10 == 0) tht = 0.; - if (int(m_controlAlines/10)%10 == 0) thz = 0.; - if (int(m_controlAlines/100)%10 == 0) ths = 0.; - if (int(m_controlAlines/1000)%10 == 0) t = 0.; - if (int(m_controlAlines/10000)%10 == 0) z = 0.; - if (int(m_controlAlines/100000)%10== 0) s = 0.; - if (m_controlAlines!=111111) ALine->setParameters(s,z,t,ths,thz,tht); - if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting delta transform for component "<<job<<" of Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<" params are = "<<s<<" "<<z<<" "<<t<<" "<<ths<<" "<<thz<<" "<<tht<<endmsg; - thisStation->setDelta_fromAline_forComp( job, s,z,t,ths,thz,tht ); - if (cacheFillingFlag()) { - thisStation->getMuonReadoutElement(job)->clearCache(); - thisStation->getMuonReadoutElement(job)->fillCache(); - } - else - { - thisStation->getMuonReadoutElement(job)->refreshCache(); - } - nUpdates++; - } - else - { - log<<MSG::WARNING - <<"ALinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job - <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; - continue; - } - // record this A-line in the historical A-line container - ciALineMap ci = ALineMapBegin(); - if((ci = ALineContainer()->find(ALineId)) != ALineMapEnd()) - { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating existing entry in A-line container for Station " - <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; - ALinePar * oldALine = (*ci).second; - m_aLineContainer->erase(ALineId); - delete oldALine; oldALine=0; - } - else - { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in A-line container for Station Component " - <<stType<<" at Jzz/Jff/Job "<<jzz<<"/"<< jff <<"/"<<job<<" --- in the container with key "<< m_mdtIdHelper->show_to_string(ALineId)<< endmsg; - } - m_aLineContainer->insert(std::make_pair(ALineId,ALine)); + { + // job different than 0 (standard for TGC conditions for Sept 2010 repro.) + float s,z,t,ths,thz,tht; + newALine.getParameters(s,z,t,ths,thz,tht); + if ( m_controlAlines%10 == 0) tht = 0.; + if (int(m_controlAlines/10)%10 == 0) thz = 0.; + if (int(m_controlAlines/100)%10 == 0) ths = 0.; + if (int(m_controlAlines/1000)%10 == 0) t = 0.; + if (int(m_controlAlines/10000)%10 == 0) z = 0.; + if (int(m_controlAlines/100000)%10== 0) s = 0.; + if (m_controlAlines!=111111) newALine.setParameters(s,z,t,ths,thz,tht); + if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting delta transform for component "<<job<<" of Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<" params are = "<<s<<" "<<z<<" "<<t<<" "<<ths<<" "<<thz<<" "<<tht<<endmsg; + thisStation->setDelta_fromAline_forComp( job, s,z,t,ths,thz,tht ); + if (cacheFillingFlag()) { + thisStation->getMuonReadoutElement(job)->clearCache(); + thisStation->getMuonReadoutElement(job)->fillCache(); + } + else + { + thisStation->getMuonReadoutElement(job)->refreshCache(); + } } + nUpdates++; } log<<MSG::INFO<<"# of A-lines read from the ALineMapContainer in StoreGate is "<<nLines<<endmsg; log<<MSG::INFO<<"# of deltaTransforms updated according to A-lines is "<<nUpdates<<endmsg; @@ -1471,7 +1401,7 @@ MuonDetectorManager::updateAlignment(const ALineMapContainer * alineData) } StatusCode -MuonDetectorManager::updateDeformations(const BLineMapContainer * blineData) +MuonDetectorManager::updateDeformations(const BLineMapContainer& blineData) { #ifdef TESTBLINES { @@ -1494,61 +1424,53 @@ MuonDetectorManager::updateDeformations(const BLineMapContainer * blineData) return StatusCode::SUCCESS; } - if (blineData == nullptr) - { - log<<MSG::WARNING<<"Undefined pointer to temporary B-line container - nothing to do here"<<endmsg; - return StatusCode::SUCCESS; - } - if (blineData->size()==0) + if (blineData.empty()) { log<<MSG::WARNING<<"Empty temporary B-line container - nothing to do here"<<endmsg; return StatusCode::SUCCESS; } - else log<<MSG::INFO<<"temporary B-line container with size = "<<blineData->size()<<endmsg; + else log<<MSG::INFO<<"temporary B-line container with size = "<<blineData.size()<<endmsg; // loop over the container of the updates passed by the MuonAlignmentDbTool - ciBLineMap cibline = blineData->begin(); unsigned int nLines = 0; unsigned int nUpdates = 0; - for (; cibline != blineData->end(); cibline++) + for (auto [BLineId, BLine] : blineData) { nLines++; - Identifier BLineId = (*cibline).first; - BLinePar* BLine = (*cibline).second; std::string stType = ""; int jff = 0; int jzz = 0; int job = 0; #ifdef TESTBLINES - BLine->setParameters(0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.); + BLine.setParameters(0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.); #endif if (mdtDeformationFlag()>999999) { // first reset everything - BLine->setParameters(0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.); + BLine.setParameters(0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.); // now apply user choice int choice = mdtDeformationFlag(); - if (int(choice% 10)>0 ) BLine->setParameters(0.,0.,0.,BLine->sp(),BLine->sn(),BLine->tw(),0.,0.,BLine->eg(),BLine->ep(),100.); - if (int(choice% 100)>9 ) BLine->setParameters(0.,0.,0.,BLine->sp(),BLine->sn(),BLine->tw(),0.,0.,BLine->eg(),100.,BLine->en()); - if (int(choice% 1000)>99 ) BLine->setParameters(0.,0.,0.,BLine->sp(),BLine->sn(),BLine->tw(),0.,0.,100.,BLine->ep(),BLine->en()); - if (int(choice% 10000)>999 ) BLine->setParameters(0.,0.,0.,BLine->sp(),BLine->sn(),100.,0.,0.,BLine->eg(),BLine->ep(),BLine->en()); - if (int(choice% 100000)>9999 ) BLine->setParameters(0.,0.,0.,BLine->sp(),100.,BLine->tw(),0.,0.,BLine->eg(),BLine->ep(),BLine->en()); - if (int(choice%1000000)>99999) BLine->setParameters(0.,0.,0.,100.,BLine->sn(),BLine->tw(),0.,0.,BLine->eg(),BLine->ep(),BLine->en()); + if (int(choice% 10)>0 ) BLine.setParameters(0.,0.,0.,BLine.sp(),BLine.sn(),BLine.tw(),0.,0.,BLine.eg(),BLine.ep(),100.); + if (int(choice% 100)>9 ) BLine.setParameters(0.,0.,0.,BLine.sp(),BLine.sn(),BLine.tw(),0.,0.,BLine.eg(),100.,BLine.en()); + if (int(choice% 1000)>99 ) BLine.setParameters(0.,0.,0.,BLine.sp(),BLine.sn(),BLine.tw(),0.,0.,100.,BLine.ep(),BLine.en()); + if (int(choice% 10000)>999 ) BLine.setParameters(0.,0.,0.,BLine.sp(),BLine.sn(),100.,0.,0.,BLine.eg(),BLine.ep(),BLine.en()); + if (int(choice% 100000)>9999 ) BLine.setParameters(0.,0.,0.,BLine.sp(),100.,BLine.tw(),0.,0.,BLine.eg(),BLine.ep(),BLine.en()); + if (int(choice%1000000)>99999) BLine.setParameters(0.,0.,0.,100.,BLine.sn(),BLine.tw(),0.,0.,BLine.eg(),BLine.ep(),BLine.en()); if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Testing B-lines: control flag "<<choice<<" hard coding Bline = ( bz=" - <<BLine->bz()<<" bp=" - <<BLine->bp()<<" bn=" - <<BLine->bn()<<" sp=" - <<BLine->sp()<<" sn=" - <<BLine->sn()<<" tw=" - <<BLine->tw()<<" pg=" - <<BLine->pg()<<" tr=" - <<BLine->tr()<<" eg=" - <<BLine->eg()<<" ep=" - <<BLine->ep()<<" en=" - <<BLine->en()<<")"<<endmsg; + <<BLine.bz()<<" bp=" + <<BLine.bp()<<" bn=" + <<BLine.bn()<<" sp=" + <<BLine.sp()<<" sn=" + <<BLine.sn()<<" tw=" + <<BLine.tw()<<" pg=" + <<BLine.pg()<<" tr=" + <<BLine.tr()<<" eg=" + <<BLine.eg()<<" ep=" + <<BLine.ep()<<" en=" + <<BLine.en()<<")"<<endmsg; } - BLine->getAmdbId(stType, jff, jzz, job); + BLine.getAmdbId(stType, jff, jzz, job); if (stType.substr(0,1)=="T" || stType.substr(0,1)=="C" || (stType.substr(0,3)=="BML" && abs(jzz)==7) ) { if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG <<"BLinePar with AmdbId " @@ -1572,7 +1494,7 @@ MuonDetectorManager::updateDeformations(const BLineMapContainer * blineData) if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<" mdtDeformationFlag()==0 skipping this b-line"<<endmsg; continue; // should never happen... } - if (!BLine->isNew()) + if (!BLine.isNew()) { log<<MSG::WARNING <<"BLinePar with AmdbId " @@ -1586,37 +1508,30 @@ MuonDetectorManager::updateDeformations(const BLineMapContainer * blineData) if (job == 0) { MuonStation* thisStation = getMuonStation(stType, jzz, jff); - if (thisStation) - { - if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting deformation parameters for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<endmsg; - thisStation->clearBLineCache(); - thisStation->setBline(BLine); - if (cacheFillingFlag()) thisStation->fillBLineCache(); - nUpdates++; - } - else - { - log<<MSG::WARNING - <<"BLinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job - <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; - continue; + if (!thisStation) { + log<<MSG::WARNING + <<"BLinePar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job + <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; + continue; } + // record this B-line in the historical B-line container - ciBLineMap ci = BLineMapBegin(); - if((ci = BLineContainer()->find(BLineId)) != BLineMapEnd()) + auto [it, flag] = m_bLineContainer.insert_or_assign (BLineId, BLine); + if (flag) { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating existing entry in B-line container for Station " - <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; - BLinePar * oldBLine = (*ci).second; - m_bLineContainer->erase(BLineId); - delete oldBLine; oldBLine=0; - } - else - { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in B-line container for Station " + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in B-line container for Station " <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff <<" --- in the container with key "<< m_mdtIdHelper->show_to_string(BLineId)<< endmsg; } - m_bLineContainer->insert(std::make_pair(BLineId,BLine)); + else { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating existing entry in B-line container for Station " + <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; + } + + if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting deformation parameters for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<endmsg; + thisStation->clearBLineCache(); + thisStation->setBline(&it->second); + if (cacheFillingFlag()) thisStation->fillBLineCache(); + nUpdates++; } else { @@ -1632,9 +1547,9 @@ MuonDetectorManager::updateDeformations(const BLineMapContainer * blineData) return StatusCode::SUCCESS; } -void MuonDetectorManager::storeTgcReadoutParams(TgcReadoutParams* x) +void MuonDetectorManager::storeTgcReadoutParams(const TgcReadoutParams* /*x*/) { - m_TgcReadoutParamsVec.push_back(x); + // Unused (memory leak, to be fixed later) } StatusCode MuonDetectorManager::initCSCInternalAlignmentMap() @@ -1644,7 +1559,7 @@ StatusCode MuonDetectorManager::initCSCInternalAlignmentMap() if (!m_useCscIlinesFromGM) { log<<MSG::INFO<<"Init of CSC I-Lines will be done via Conditions DB"<<endmsg; - m_cscALineContainer = new CscInternalAlignmentMapContainer; + m_cscALineContainer.clear(); for (std::map< std::string, MuonStation * >::const_iterator ist=m_MuonStationMap.begin(); ist!=m_MuonStationMap.end(); ++ist) @@ -1659,63 +1574,52 @@ StatusCode MuonDetectorManager::initCSCInternalAlignmentMap() for (unsigned int wlay =1; wlay<5; ++wlay) { - CscInternalAlignmentPar* newILine = new CscInternalAlignmentPar(); - newILine->setAmdbId(stType, jff, jzz, job, wlay); + CscInternalAlignmentPar newILine; + newILine.setAmdbId(stType, jff, jzz, job, wlay); if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"No starting I-Lines or reseting them for Station "<<stType<<" Jzz/Jff/Wlay "<<jzz<<"/"<<jff<<"/"<<wlay<<endmsg; // there is no way to check if the RE already has parameters set - always overwriting them. - newILine->setParameters(0.,0.,0.,0.,0.,0.); - newILine->isNew(true); + newILine.setParameters(0.,0.,0.,0.,0.,0.); + newILine.isNew(true); Identifier idp = m_cscIdHelper->parentID(ms->getMuonReadoutElement(job)->identify()); Identifier id = m_cscIdHelper->channelID(idp, 2, wlay, 0, 1); if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"<Filling I-Line container with entry for key >"<<m_cscIdHelper->show_to_string(id)<<endmsg; - m_cscALineContainer->insert(std::make_pair(id,(CscInternalAlignmentPar*)newILine)); + m_cscALineContainer.emplace(id, newILine); } } - log<<MSG::INFO<<"Init I-Line Container - done - size is respectively " << m_cscALineContainer->size()<<endmsg; + log<<MSG::INFO<<"Init I-Line Container - done - size is respectively " << m_cscALineContainer.size()<<endmsg; } if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Init CSC I-Line Containers - pointer is <" - <<(uintptr_t)m_cscALineContainer<<">"<<endmsg; + <<(uintptr_t)&m_cscALineContainer<<">"<<endmsg; - if (m_cscALineContainer == nullptr) { - log<<MSG::INFO<<"No Aline for CSC wire layers loaded "<<endmsg; - } else { - log<<MSG::INFO<<"I-Line for CSC wire layers loaded (Csc Internal Alignment)"<<endmsg; - if (m_useCscIntAlign) log<<MSG::INFO<<"According to configuration they WILL be used "<<endmsg; - else log<<MSG::INFO<<"According to configuration parameters they WILL BE UPDATED FROM CONDDB "<<endmsg; - } + log<<MSG::INFO<<"I-Line for CSC wire layers loaded (Csc Internal Alignment)"<<endmsg; + if (m_useCscIntAlign) log<<MSG::INFO<<"According to configuration they WILL be used "<<endmsg; + else log<<MSG::INFO<<"According to configuration parameters they WILL BE UPDATED FROM CONDDB "<<endmsg; return StatusCode::SUCCESS; } StatusCode -MuonDetectorManager::updateCSCInternalAlignmentMap(const CscInternalAlignmentMapContainer* ilineData) +MuonDetectorManager::updateCSCInternalAlignmentMap(const CscInternalAlignmentMapContainer& ilineData) { MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); - if (ilineData == nullptr) { - log<<MSG::WARNING<<"Undefined pointer to temporary CSC I-line container - nothing to do here"<<endmsg; - return StatusCode::SUCCESS; - } - if (ilineData->size()==0) { + if (ilineData.empty()) { log<<MSG::WARNING<<"Empty temporary CSC I-line container - nothing to do here"<<endmsg; return StatusCode::SUCCESS; } - else log<<MSG::INFO<<"temporary CSC I-line container with size = "<<ilineData->size()<<endmsg; + else log<<MSG::INFO<<"temporary CSC I-line container with size = "<<ilineData.size()<<endmsg; // loop over the container of the updates passed by the MuonAlignmentDbTool - ciCscInternalAlignmentMap ciiline = ilineData->begin(); unsigned int nLines = 0; unsigned int nUpdates = 0; - for (; ciiline != ilineData->end(); ciiline++) + for (const auto& [ILineId, ILine] : ilineData) { nLines++; - Identifier ILineId = (*ciiline).first; - CscInternalAlignmentPar* ILine = (*ciiline).second; std::string stType = ""; int jff = 0; int jzz = 0; int job = 0; int jlay = 0; - ILine->getAmdbId(stType, jff, jzz, job, jlay); - if (!ILine->isNew()) + ILine.getAmdbId(stType, jff, jzz, job, jlay); + if (!ILine.isNew()) { log<<MSG::WARNING <<"CscInternalAlignmentPar with AmdbId " @@ -1729,57 +1633,52 @@ MuonDetectorManager::updateCSCInternalAlignmentMap(const CscInternalAlignmentMap if (job == 3) { MuonStation* thisStation = getMuonStation(stType, jzz, jff); - if (thisStation) + if (!thisStation) { - float tras, traz, trat, rots, rotz, rott; - ILine->getParameters(tras,traz,trat,rots,rotz,rott); - int choice = CscIlinesFlag(); - if ( choice%10 == 0) tras = 0.; - if (int(choice/10)%10 == 0) rotz = 0.; - if (int(choice/100)%10 == 0) rots = 0.; - if (int(choice/1000)%10 == 0) trat = 0.; - if (int(choice/10000)%10 == 0) traz = 0.; - if (int(choice/100000)%10== 0) traz = 0.; - if (m_controlCscIlines!=111111) ILine->setParameters(tras,traz,trat,rots,rotz,rott); - if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting CSC I-Lines for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<job<<" "<<jlay<<" "<<" params are = "<<tras<<" "<<traz<<" "<<trat<<" "<<rots<<" "<<rotz<<" "<<rott<<endmsg; - CscReadoutElement* CscRE = dynamic_cast<CscReadoutElement*> (thisStation->getMuonReadoutElement(job)); - if(!CscRE) log<<MSG::ERROR<<"The CSC I-lines container includes stations which are no CSCs! This is impossible." <<endmsg; - else { - CscRE->setCscInternalAlignmentPar(ILine); - } - if (cacheFillingFlag()) - { - thisStation->clearCache(); - thisStation->fillCache(); - } - else - { - thisStation->refreshCache(); - } - nUpdates++; + log<<MSG::WARNING + <<"CscInternalAlignmentPar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job<<" "<<jlay + <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; + continue; } - else - { - log<<MSG::WARNING - <<"CscInternalAlignmentPar with AmdbId "<<stType<<" "<<jzz<<" "<<jff<<" "<<job<<" "<<jlay - <<" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use"<<endmsg; - continue; + + auto [it, flag] = m_cscALineContainer.insert_or_assign (ILineId, ILine); + if (flag) { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in CSC I-line container for Station " + <<stType<<" at Jzz/Jff/Jlay "<<jzz<<"/"<< jff<<"/"<< jlay <<" --- in the container with key "<< m_cscIdHelper->show_to_string(ILineId)<< endmsg; } - ciCscInternalAlignmentMap ci = CscALineMapBegin(); - if((ci = CscInternalAlignmentContainer()->find(ILineId)) != CscALineMapEnd()) + else { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in CSC I-line container for Station " + <<stType<<" at Jzz/Jff/Jlay "<<jzz<<"/"<< jff <<"/"<< jlay<< endmsg; + } + + CscInternalAlignmentPar& newILine = it->second; + float tras, traz, trat, rots, rotz, rott; + newILine.getParameters(tras,traz,trat,rots,rotz,rott); + int choice = CscIlinesFlag(); + if ( choice%10 == 0) tras = 0.; + if (int(choice/10)%10 == 0) rotz = 0.; + if (int(choice/100)%10 == 0) rots = 0.; + if (int(choice/1000)%10 == 0) trat = 0.; + if (int(choice/10000)%10 == 0) traz = 0.; + if (int(choice/100000)%10== 0) traz = 0.; + if (m_controlCscIlines!=111111) newILine.setParameters(tras,traz,trat,rots,rotz,rott); + if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting CSC I-Lines for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<job<<" "<<jlay<<" "<<" params are = "<<tras<<" "<<traz<<" "<<trat<<" "<<rots<<" "<<rotz<<" "<<rott<<endmsg; + CscReadoutElement* CscRE = dynamic_cast<CscReadoutElement*> (thisStation->getMuonReadoutElement(job)); + if(!CscRE) log<<MSG::ERROR<<"The CSC I-lines container includes stations which are no CSCs! This is impossible." <<endmsg; + else { + CscRE->setCscInternalAlignmentPar(newILine); + } + if (cacheFillingFlag()) { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in CSC I-line container for Station " - <<stType<<" at Jzz/Jff/Jlay "<<jzz<<"/"<< jff <<"/"<< jlay<< endmsg; - CscInternalAlignmentPar * oldILine = (*ci).second; - m_cscALineContainer->erase(ILineId); - delete oldILine; oldILine=0; + thisStation->clearCache(); + thisStation->fillCache(); } else { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< " New entry in CSC I-line container for Station " - <<stType<<" at Jzz/Jff/Jlay "<<jzz<<"/"<< jff<<"/"<< jlay <<" --- in the container with key "<< m_cscIdHelper->show_to_string(ILineId)<< endmsg; + thisStation->refreshCache(); } - m_cscALineContainer->insert(std::make_pair(ILineId,ILine)); + nUpdates++; + } else { @@ -1793,60 +1692,44 @@ MuonDetectorManager::updateCSCInternalAlignmentMap(const CscInternalAlignmentMap return StatusCode::SUCCESS; } StatusCode -MuonDetectorManager::updateAsBuiltParams(const MdtAsBuiltMapContainer* asbuiltData) +MuonDetectorManager::updateAsBuiltParams(const MdtAsBuiltMapContainer& asbuiltData) { MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); - if (asbuiltData == nullptr) { - log<<MSG::WARNING<<"Undefined pointer to temporary As-Built container - nothing to do here"<<endmsg; - return StatusCode::SUCCESS; - } - if (asbuiltData->size()==0) { + if (asbuiltData.empty()) { log<<MSG::WARNING<<"Empty temporary As-Built container - nothing to do here"<<endmsg; return StatusCode::SUCCESS; - } else log<<MSG::INFO<<"temporary As-Built container with size = "<<asbuiltData->size()<<endmsg; - - if (!m_AsBuiltParamsMap) { - log << MSG::INFO << "Creating the Mdt AsBuilt paramerter map" << endmsg; - m_AsBuiltParamsMap = new MdtAsBuiltMapContainer(); - } + } else log<<MSG::INFO<<"temporary As-Built container with size = "<<asbuiltData.size()<<endmsg; // loop over the container of the updates passed by the MuonAlignmentDbTool - ciMdtAsBuiltMap ciasbuilt = asbuiltData->begin(); unsigned int nLines = 0; unsigned int nUpdates = 0; - for (; ciasbuilt != asbuiltData->end(); ciasbuilt++) + for (const auto& [AsBuiltId, AsBuiltPar] : asbuiltData) { nLines++; - Identifier AsBuiltId = (*ciasbuilt).first; - MdtAsBuiltPar* AsBuiltPar = (*ciasbuilt).second; std::string stType = ""; int jff = 0; int jzz = 0; int job = 0; - AsBuiltPar->getAmdbId(stType, jff, jzz, job); - if (!AsBuiltPar->isNew()) + AsBuiltPar.getAmdbId(stType, jff, jzz, job); + if (!AsBuiltPar.isNew()) { if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG <<"MdtAsBuiltPar with AmdbId " <<stType<<" "<<jzz<<" "<<jff<<" "<<job <<" is not new *** skipping"<<endmsg; continue; - } else { + } - ciMdtAsBuiltMap ci = MdtAsBuiltMapBegin(); - if((ci = MdtAsBuiltContainer()->find(AsBuiltId)) != MdtAsBuiltMapEnd()) - { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in AsBuilt container for Station " - <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; - MdtAsBuiltPar* oldAsBuilt = (*ci).second; - m_AsBuiltParamsMap->erase(AsBuiltId); - delete oldAsBuilt; oldAsBuilt=0; - } else { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "New entry in AsBuilt container for Station " - <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff<<" --- in the container with key "<< m_mdtIdHelper->show_to_string(AsBuiltId)<< endmsg; - } - m_AsBuiltParamsMap->insert(std::make_pair(AsBuiltId,AsBuiltPar)); + auto [it, flag] = m_AsBuiltParamsMap.insert_or_assign (AsBuiltId, AsBuiltPar); + if (flag) { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "New entry in AsBuilt container for Station " + <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff<<" --- in the container with key "<< m_mdtIdHelper->show_to_string(AsBuiltId)<< endmsg; + } + else { + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in AsBuilt container for Station " + <<stType<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; } + if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG <<"MdtAsBuiltPar with AmdbId " <<stType<<" "<<jzz<<" "<<jff<<" "<<job<<" is new ID = "<<m_mdtIdHelper->show_to_string(AsBuiltId)<<endmsg; @@ -1854,7 +1737,7 @@ MuonDetectorManager::updateAsBuiltParams(const MdtAsBuiltMapContainer* asbuiltDa if (thisStation) { if (log.level()<=MSG::DEBUG) log<<MSG::DEBUG<<"Setting as-built parameters for Station "<<stType<<" "<<jzz<<" "<<jff<<" "<<endmsg; thisStation->clearBLineCache(); - thisStation->setMdtAsBuiltParams(AsBuiltPar); + thisStation->setMdtAsBuiltParams(&it->second); if (cacheFillingFlag()) thisStation->fillBLineCache(); nUpdates++; } else { @@ -1870,65 +1753,52 @@ MuonDetectorManager::updateAsBuiltParams(const MdtAsBuiltMapContainer* asbuiltDa return StatusCode::SUCCESS; } -void MuonDetectorManager::storeCscInternalAlignmentParams(CscInternalAlignmentPar* x) +void MuonDetectorManager::storeCscInternalAlignmentParams(const CscInternalAlignmentPar& x) { MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); - if (!m_cscALineContainer) { - log<<MSG::INFO<<"Creating now the CscInternalAlignmentMapContainer"<<endmsg; - m_cscALineContainer = new CscInternalAlignmentMapContainer; - } std::string stName="XXX"; int jff = 0; int jzz = 0; int job = 0; int wlayer = 0; - x->getAmdbId(stName, jff, jzz, job, wlayer); + x.getAmdbId(stName, jff, jzz, job, wlayer); // chamberLayer is always 2 => job is always 3 int chamberLayer = 2; if (job != 3) log<<MSG::WARNING<<"job = "<<job<<" is not 3 => chamberLayer should be 1 - not existing ! setting 2"<<endmsg; Identifier id = m_cscIdHelper->channelID(stName, jzz, jff, chamberLayer, wlayer, 0, 1); - m_cscALineContainer->insert(std::make_pair(id,x)); + m_cscALineContainer.emplace(id, x); if (log.level()<=MSG::DEBUG) { log<<MSG::DEBUG<<"Adding Aline for CSC wire layer: "<<m_cscIdHelper->show_to_string(id)<<endmsg; - log<<MSG::DEBUG<<"CscInternalAlignmentMapContainer has currently size "<<m_cscALineContainer->size()<<endmsg; + log<<MSG::DEBUG<<"CscInternalAlignmentMapContainer has currently size "<<m_cscALineContainer.size()<<endmsg; } } -void MuonDetectorManager::storeMdtAsBuiltParams(MdtAsBuiltPar* params) { +void MuonDetectorManager::storeMdtAsBuiltParams(const MdtAsBuiltPar& params) { MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); - if (!m_AsBuiltParamsMap) { - log << MSG::INFO << "Creating the Mdt AsBuilt paramerter map" << endmsg; - m_AsBuiltParamsMap = new MdtAsBuiltMapContainer; - } - std::string stName="XXX"; int jff = 0; int jzz = 0; int job = 0; - params->getAmdbId(stName, jff, jzz, job); + params.getAmdbId(stName, jff, jzz, job); Identifier id = mdtIdHelper()->elementID(stName, jzz, jff); if (!id.is_valid()) { log << MSG::ERROR << "Invalid MDT identifiers: sta=" << stName << " eta=" << jzz << " phi=" << jff << endmsg; return; } - ciMdtAsBuiltMap ci = MdtAsBuiltMapBegin(); - if((ci = MdtAsBuiltContainer()->find(id)) != MdtAsBuiltMapEnd()) + if (m_AsBuiltParamsMap.insert_or_assign (id, params).second) { - if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in AsBuilt container for Station " - <<stName<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; - MdtAsBuiltPar* oldAsBuilt = (*ci).second; - m_AsBuiltParamsMap->erase(id); - delete oldAsBuilt; oldAsBuilt=0; - } else { if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "New entry in AsBuilt container for Station " <<stName<<" at Jzz/Jff "<<jzz<<"/"<< jff<<" --- in the container with key "<< m_mdtIdHelper->show_to_string(id)<< endmsg; } - m_AsBuiltParamsMap->insert(std::make_pair(id,params)); + else{ + if (log.level()<=MSG::DEBUG) log << MSG::DEBUG<< "Updating extisting entry in AsBuilt container for Station " + <<stName<<" at Jzz/Jff "<<jzz<<"/"<< jff << endmsg; + } return; } @@ -1939,8 +1809,8 @@ const MdtAsBuiltPar* MuonDetectorManager::getMdtAsBuiltParams(Identifier id) con log << MSG::DEBUG << "No Mdt AsBuilt parameter container available" << endmsg; return nullptr; } - iMdtAsBuiltMap iter = m_AsBuiltParamsMap->find(id); - if (iter == MdtAsBuiltContainer()->end()) { + ciMdtAsBuiltMap iter = m_AsBuiltParamsMap.find(id); + if (iter == m_AsBuiltParamsMap.end()) { MsgStream log(Athena::getMessageSvc(),"MGM::MuonDetectorManager"); log << MSG::DEBUG << "No Mdt AsBuilt parameters for station " << id.getString() << " sta=" << mdtIdHelper()->stationNameString(mdtIdHelper()->stationName(id)) @@ -1949,7 +1819,7 @@ const MdtAsBuiltPar* MuonDetectorManager::getMdtAsBuiltParams(Identifier id) con << endmsg; return nullptr; } - return iter->second; + return &iter->second; } const MdtReadoutElement* MuonDetectorManager::getMdtReadoutElement(IdentifierHash id) const { diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonStation.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonStation.cxx index 7e183cc3a68a215249aa31b79313de5581289566..c9151534357b9a89513562a758ca8fa7cfb3106d 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonStation.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MuonStation.cxx @@ -466,7 +466,7 @@ void MuonStation::fillCache() } } -void MuonStation::setBline(BLinePar * bline) +void MuonStation::setBline(const BLinePar * bline) { m_hasBLines = true; std::map<int, pairRE_AlignTransf>::iterator it = m_REwithAlTransfInStation->begin(); diff --git a/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx b/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx index 35a0ffa7cc39ed5660fd77860254747375b9014e..d990eb21849548b857bc3eb1a788fad49e30c764 100755 --- a/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx +++ b/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx @@ -92,19 +92,10 @@ StatusCode MuonDetectorCondAlg::execute() if (MuonMgrData->applyCscIntAlignment()) { SG::ReadCondHandle<CscInternalAlignmentMapContainer> readILinesHandle{m_readILineKey}; const CscInternalAlignmentMapContainer* readILinesCdo{*readILinesHandle}; - if(readILinesCdo==nullptr){ - ATH_MSG_ERROR("Null pointer to the read CSC/ILINES conditions object"); - return StatusCode::FAILURE; - } writeHandle.addDependency( readILinesHandle ); - CscInternalAlignmentMapContainer tempCont; - for (const auto& p : *readILinesCdo) { - tempCont.emplace (p.first, new CscInternalAlignmentPar (*p.second)); - } - - if (MuonMgrData->updateCSCInternalAlignmentMap(&tempCont).isFailure()) ATH_MSG_ERROR("Unable to update CSC/ILINES" ); + if (MuonMgrData->updateCSCInternalAlignmentMap(*readILinesCdo).isFailure()) ATH_MSG_ERROR("Unable to update CSC/ILINES" ); else ATH_MSG_DEBUG("update CSC/ILINES DONE" ); } @@ -114,19 +105,10 @@ StatusCode MuonDetectorCondAlg::execute() if (MuonMgrData->applyMdtAsBuiltParams()) { SG::ReadCondHandle<MdtAsBuiltMapContainer> readAsBuiltHandle{m_readAsBuiltKey}; const MdtAsBuiltMapContainer* readAsBuiltCdo{*readAsBuiltHandle}; - if(readAsBuiltCdo==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MDT AsBuilt conditions object"); - return StatusCode::FAILURE; - } - writeHandle.addDependency( readAsBuiltHandle ); - MdtAsBuiltMapContainer tempCont; - for (const auto& p : *readAsBuiltCdo) { - tempCont.emplace (p.first, new MdtAsBuiltPar (*p.second)); - } - if (MuonMgrData->updateAsBuiltParams(&tempCont).isFailure()) ATH_MSG_ERROR("Unable to update MDT AsBuilt parameters" ); + if (MuonMgrData->updateAsBuiltParams(*readAsBuiltCdo).isFailure()) ATH_MSG_ERROR("Unable to update MDT AsBuilt parameters" ); else ATH_MSG_DEBUG("update MDT AsBuilt parameters DONE" ); } @@ -135,13 +117,7 @@ StatusCode MuonDetectorCondAlg::execute() // ======================= SG::ReadCondHandle<ALineMapContainer> readALinesHandle{m_readALineKey}; - const ALineMapContainer* readALinesCdo{*readALinesHandle}; - if(readALinesCdo==nullptr){ - ATH_MSG_ERROR("Null pointer to the read ALINES conditions object"); - return StatusCode::FAILURE; - } - - if (MuonMgrData->updateAlignment(readALinesCdo).isFailure()) ATH_MSG_ERROR("Unable to update Alignment" ); + if (MuonMgrData->updateAlignment(**readALinesHandle).isFailure()) ATH_MSG_ERROR("Unable to update Alignment" ); else ATH_MSG_DEBUG("update Alignment DONE" ); // ======================= @@ -149,15 +125,10 @@ StatusCode MuonDetectorCondAlg::execute() // ======================= SG::ReadCondHandle<BLineMapContainer> readBLinesHandle{m_readBLineKey}; - const BLineMapContainer* readBLinesCdo{*readBLinesHandle}; - if(readBLinesCdo==nullptr){ - ATH_MSG_ERROR("Null pointer to the read BLINES conditions object"); - return StatusCode::FAILURE; - } writeHandle.addDependency( readALinesHandle, readBLinesHandle ); - if (MuonMgrData->updateDeformations(readBLinesCdo).isFailure()) ATH_MSG_ERROR("Unable to update Deformations" ); + if (MuonMgrData->updateDeformations(**readBLinesHandle).isFailure()) ATH_MSG_ERROR("Unable to update Deformations" ); else ATH_MSG_DEBUG("update Deformations DONE" ); // !!!!!!!! UPDATE ANYTHING ELSE ??????? diff --git a/MuonSpectrometer/MuonGeoModel/src/RDBReaderAtlas.cxx b/MuonSpectrometer/MuonGeoModel/src/RDBReaderAtlas.cxx index f7828b499747417131b5fcd145d1405f5a66da33..c97bcbe22dade87fb376e4c73bf27d5cb775b5a0 100755 --- a/MuonSpectrometer/MuonGeoModel/src/RDBReaderAtlas.cxx +++ b/MuonSpectrometer/MuonGeoModel/src/RDBReaderAtlas.cxx @@ -361,9 +361,9 @@ void RDBReaderAtlas::ProcessCscInternalAlignments() tras = m_iacsc[ipos].tras ; // T ROTATION } } - CscInternalAlignmentPar * myPar = new CscInternalAlignmentPar(); - myPar->setAmdbId(name, jff, jzz, job, wireLayer); - myPar->setParameters(tras, traz, trat, rots, rotz, rott); + CscInternalAlignmentPar myPar; + myPar.setAmdbId(name, jff, jzz, job, wireLayer); + myPar.setParameters(tras, traz, trat, rots, rotz, rott); m_mgr->storeCscInternalAlignmentParams(myPar); }