From f256e6880f7b61ca470419cf78ac60176134a43c Mon Sep 17 00:00:00 2001
From: Adam Edward Barton <adam.edward.barton@cern.ch>
Date: Wed, 1 Jul 2020 09:59:13 +0000
Subject: [PATCH] IDC: Adjust random IDC access in various packages 3

---
 .../src/CscCalibDataContainer.cxx             |  5 +-
 .../src/CscRdoToCscDigit.cxx                  |  6 +-
 .../src/MM_RdoToDigit.cxx                     |  6 +-
 .../src/MdtRdoToMdtDigit.cxx                  |  6 +-
 .../src/RpcRdoToRpcDigit.cxx                  |  6 +-
 .../src/STGC_RdoToDigit.cxx                   |  6 +-
 .../src/TgcRdoToTgcDigit.cxx                  |  6 +-
 .../src/RpcPadContainerCnv_p1.cxx             |  6 +-
 .../src/RpcPadContainerCnv_p2.cxx             |  6 +-
 .../src/MuonEventCnvTool.cxx                  |  8 +--
 .../src/MdtRdoToPrepDataToolCore.cxx          | 44 ++++++-------
 .../MuonPrepRawDataCollectionProviderTool.h   |  8 +--
 .../src/sTgcRdoToPrepDataToolCore.cxx         |  2 +-
 .../src/TGC_RodDecoderRawdata.cxx             |  3 +-
 .../src/TgcRdoToPrepDataToolCore.cxx          |  4 +-
 .../src/MdtDigitizationTool.cxx               |  6 +-
 .../src/MM_DigitizationTool.cxx               |  6 +-
 .../src/RpcDigitizationTool.cxx               |  6 +-
 .../src/TgcDigitizationTool.cxx               |  6 +-
 .../src/CscClusterUtilTool.cxx                |  6 +-
 .../CscPeakThresholdClusterBuilderTool.cxx    |  7 +-
 .../src/CscThresholdClusterBuilderTool.cxx    |  9 ++-
 .../src/MuonPRD_Provider.h                    |  5 +-
 .../src/MuonEDMPrinterTool.cxx                | 20 +++---
 .../src/MuonTrackSummaryHelperTool.cxx        |  6 +-
 .../src/DCMathSegmentMaker.cxx                | 18 ++---
 .../src/MuonClusterSegmentFinder.cxx          |  8 +--
 .../src/MuonChamberHoleRecoveryTool.cxx       | 36 +++++-----
 .../src/MuonSeededSegmentFinder.cxx           | 66 +++++++++----------
 .../src/CscClusterValAlg.cxx                  |  9 ++-
 .../src/CscClusterValMonAlg.cxx               |  7 +-
 .../MuonPRDTest/src/MMPRDVariables.cxx        |  2 +-
 32 files changed, 169 insertions(+), 176 deletions(-)

diff --git a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibEvent/src/CscCalibDataContainer.cxx b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibEvent/src/CscCalibDataContainer.cxx
index 3f29a3a630f..a2ffefdc0ac 100755
--- a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibEvent/src/CscCalibDataContainer.cxx
+++ b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibEvent/src/CscCalibDataContainer.cxx
@@ -25,9 +25,8 @@ void CscCalibDataContainer::push_back(CscCalibData* calibData) {
   IdentifierHash channelHash = calibData->idHash(); 
   // I don't think there's any need for this any more. EJWM
   // Not sure if the "Identifier existing" check is important though
-     MyBase::const_iterator it = MyBase::indexFind(channelHash);
-     if(it!=MyBase::end()) {
-       const CscCalibDataCollection* const_coll = (*it)  ;
+     const CscCalibDataCollection* const_coll = MyBase::indexFindPtr(channelHash);
+     if(const_coll!=nullptr) {
        CscCalibDataCollection * coll = const_cast<CscCalibDataCollection*>(const_coll);
        coll->push_back(calibData); 
      } else {
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/CscRdoToCscDigit.cxx b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/CscRdoToCscDigit.cxx
index fb97e09f32f..8dfb410a38c 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/CscRdoToCscDigit.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/CscRdoToCscDigit.cxx
@@ -117,8 +117,8 @@ StatusCode CscRdoToCscDigit::decodeCsc(const CscRawDataCollection *rdoColl, CscD
       }
 
       if (oldId != stationId) {
-        CscDigitContainer::const_iterator it_coll = cscContainer->indexFind(coll_hash);
-        if (cscContainer->end() ==  it_coll) {
+        const CscDigitCollection * coll = cscContainer->indexFindPtr(coll_hash);
+        if (nullptr ==  coll) {
           CscDigitCollection *newCollection = new CscDigitCollection(stationId, coll_hash);
           newCollection->push_back(newDigit);
           collection = newCollection;
@@ -128,7 +128,7 @@ StatusCode CscRdoToCscDigit::decodeCsc(const CscRawDataCollection *rdoColl, CscD
           }
         }
         else {
-          CscDigitCollection *oldCollection ATLAS_THREAD_SAFE = const_cast<CscDigitCollection*>( *it_coll ); // FIXME
+          CscDigitCollection *oldCollection ATLAS_THREAD_SAFE = const_cast<CscDigitCollection*>( coll ); // FIXME
           oldCollection->push_back(newDigit);
           collection = oldCollection;
         }
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MM_RdoToDigit.cxx b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MM_RdoToDigit.cxx
index a26db8769e2..c93a9664ed2 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MM_RdoToDigit.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MM_RdoToDigit.cxx
@@ -76,8 +76,8 @@ StatusCode MM_RdoToDigit::decodeMM( const Muon::MM_RawDataCollection * rdoColl,
 
 
       if (oldId != elementId) {
-        MmDigitContainer::const_iterator it_coll = mmContainer->indexFind(coll_hash);
-        if (mmContainer->end() ==  it_coll) {
+        const MmDigitCollection * coll = mmContainer->indexFindPtr(coll_hash);
+        if (nullptr ==  coll) {
           MmDigitCollection * newCollection =
             new MmDigitCollection(elementId,coll_hash);
           newCollection->push_back(newDigit);
@@ -87,7 +87,7 @@ StatusCode MM_RdoToDigit::decodeMM( const Muon::MM_RawDataCollection * rdoColl,
                              << " in StoreGate!"  );
         }
         else {
-          MmDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<MmDigitCollection*>(*it_coll); // FIXME
+          MmDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<MmDigitCollection*>(coll); // FIXME
           oldCollection->push_back(newDigit);
           collection = oldCollection;
         }
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MdtRdoToMdtDigit.cxx b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MdtRdoToMdtDigit.cxx
index 210a55f91ad..a82409a6ac4 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MdtRdoToMdtDigit.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/MdtRdoToMdtDigit.cxx
@@ -83,8 +83,8 @@ StatusCode MdtRdoToMdtDigit::decodeMdt( const MdtCsm * rdoColl, MdtDigitContaine
 
 
       if (oldId != elementId) {
-        MdtDigitContainer::const_iterator it_coll = mdtContainer->indexFind(coll_hash);
-        if (mdtContainer->end() ==  it_coll) {
+        const MdtDigitCollection * coll = mdtContainer->indexFindPtr(coll_hash);
+        if (nullptr ==  coll) {
           MdtDigitCollection * newCollection =
             new MdtDigitCollection(elementId,coll_hash);
           newCollection->push_back(newDigit);
@@ -94,7 +94,7 @@ StatusCode MdtRdoToMdtDigit::decodeMdt( const MdtCsm * rdoColl, MdtDigitContaine
                              << " in StoreGate!"  );
         }
         else {
-          MdtDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<MdtDigitCollection*>( *it_coll ); // FIXME
+          MdtDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<MdtDigitCollection*>( coll ); // FIXME
           oldCollection->push_back(newDigit);
           collection = oldCollection;
         }
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/RpcRdoToRpcDigit.cxx b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/RpcRdoToRpcDigit.cxx
index e94672280c4..f8d286c13de 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/RpcRdoToRpcDigit.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/RpcRdoToRpcDigit.cxx
@@ -112,8 +112,8 @@ StatusCode RpcRdoToRpcDigit::decodeRpc(const RpcPad * rdoColl, RpcDigitContainer
           elementId.show();
         }
 
-        RpcDigitContainer::const_iterator it_coll = rpcContainer->indexFind(coll_hash);
-        if (rpcContainer->end() ==  it_coll) {
+        const RpcDigitCollection * coll = rpcContainer->indexFindPtr(coll_hash);
+        if (nullptr ==  coll) {
           RpcDigitCollection * newCollection = new RpcDigitCollection(elementId, coll_hash);
           newCollection->push_back(newDigit);
           collection = newCollection;
@@ -123,7 +123,7 @@ StatusCode RpcRdoToRpcDigit::decodeRpc(const RpcPad * rdoColl, RpcDigitContainer
         }
         else
           {
-            RpcDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<RpcDigitCollection*>( *it_coll ); // FIXME
+            RpcDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<RpcDigitCollection*>( coll ); // FIXME
             oldCollection->push_back(newDigit);
             collection = oldCollection;
           }
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/STGC_RdoToDigit.cxx b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/STGC_RdoToDigit.cxx
index 9ac6a5a613b..e1c838c81f6 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/STGC_RdoToDigit.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/STGC_RdoToDigit.cxx
@@ -76,8 +76,8 @@ StatusCode STGC_RdoToDigit::decodeSTGC( const Muon::STGC_RawDataCollection * rdo
 
 
       if (oldId != elementId) {
-        sTgcDigitContainer::const_iterator it_coll = stgcContainer->indexFind(coll_hash);
-        if (stgcContainer->end() ==  it_coll) {
+        const sTgcDigitCollection * coll = stgcContainer->indexFindPtr(coll_hash);
+        if (nullptr ==  coll) {
           sTgcDigitCollection * newCollection =
             new sTgcDigitCollection(elementId,coll_hash);
           newCollection->push_back(newDigit);
@@ -87,7 +87,7 @@ StatusCode STGC_RdoToDigit::decodeSTGC( const Muon::STGC_RawDataCollection * rdo
                              << " in StoreGate!"  );
         }
         else {
-          sTgcDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<sTgcDigitCollection*>(*it_coll); //FIXME
+          sTgcDigitCollection * oldCollection ATLAS_THREAD_SAFE = const_cast<sTgcDigitCollection*>(coll); //FIXME
           oldCollection->push_back(newDigit);
           collection = oldCollection;
         }
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/TgcRdoToTgcDigit.cxx b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/TgcRdoToTgcDigit.cxx
index 6a5de6e69a6..f0ce17ddafc 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/TgcRdoToTgcDigit.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStreamCnvTest/src/TgcRdoToTgcDigit.cxx
@@ -226,9 +226,9 @@ StatusCode TgcRdoToTgcDigit::decodeTgc( const TgcRdo *rdoColl,
 
           if (elementId != oldElementId) {
             // get collection
-            TgcDigitContainer::const_iterator it_coll = tgcContainer->indexFind(coll_hash);
-            if (tgcContainer->end() !=  it_coll) {
-              TgcDigitCollection* aCollection ATLAS_THREAD_SAFE = const_cast<TgcDigitCollection*>( *it_coll ); // FIXME
+            auto coll = tgcContainer->indexFindPtr(coll_hash);
+            if (nullptr !=  coll) {
+              TgcDigitCollection* aCollection ATLAS_THREAD_SAFE = const_cast<TgcDigitCollection*>( coll ); // FIXME
               collection = aCollection;
             }
             else
diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx
index ff7bbc6e9c0..a47da9759f8 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p1.cxx
@@ -128,9 +128,9 @@ void  RpcPadContainerCnv_p1::persToTrans(const RpcPadContainer_p1* persCont, Rpc
 //        }
         
         // another check - see if already added
-        RpcPadContainer::const_iterator it = transCont->indexFind(coll->identifyHash());
-        if (it!=transCont->end() ) {
-            log << MSG::WARNING<<"Collection with hash="<<coll->identifyHash()<<" already exists in container (with "<<(*it)->size()<<" elements). "
+        auto ptr = transCont->indexFindPtr(coll->identifyHash());
+        if (ptr!=nullptr ) {
+            log << MSG::WARNING<<"Collection with hash="<<coll->identifyHash()<<" already exists in container (with "<<ptr->size()<<" elements). "
                 << "Will therefore DISCARD this collection which has "<<coll->size()<<" elements)!"<<endmsg;
             delete coll;
         } else {
diff --git a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx
index 7adf612c718..53e3029b72f 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventAthenaPool/src/RpcPadContainerCnv_p2.cxx
@@ -103,9 +103,9 @@ void  RpcPadContainerCnv_p2::persToTrans(const RpcPadContainer_p2* persCont, Rpc
         RpcPad* coll = new RpcPad;
         cnv.persToTrans( &( persCont->m_pads[icoll]), coll, log);
         // another check - see if already added
-        RpcPadContainer::const_iterator it = transCont->indexFind(coll->identifyHash());
-        if (it!=transCont->end() ) {
-            log << MSG::WARNING<<"Collection with hash="<<coll->identifyHash()<<" already exists in container (with "<<(*it)->size()<<" elements). "
+        auto ptr = transCont->indexFindPtr(coll->identifyHash());
+        if (ptr!=nullptr ) {
+            log << MSG::WARNING<<"Collection with hash="<<coll->identifyHash()<<" already exists in container (with "<<ptr->size()<<" elements). "
                 << "Will therefore DISCARD this collection which has "<<coll->size()<<" elements)!"<<endmsg;
             delete coll;
         } else {
diff --git a/MuonSpectrometer/MuonCnv/MuonEventCnvTools/src/MuonEventCnvTool.cxx b/MuonSpectrometer/MuonCnv/MuonEventCnvTools/src/MuonEventCnvTool.cxx
index 87112ea879f..a3824277a09 100755
--- a/MuonSpectrometer/MuonCnv/MuonEventCnvTools/src/MuonEventCnvTool.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventCnvTools/src/MuonEventCnvTool.cxx
@@ -254,13 +254,13 @@ const Trk::PrepRawData*
       ATH_MSG_DEBUG("PRD Cluster container found at "<<prdKey);
   }
 
-  auto it = handle->indexFind(idHash);
+  auto ptr = handle->indexFindPtr(idHash);
   // if we find PRD, then recreate link
-  if (it!=handle->end()) 
+  if (ptr!=nullptr) 
   {
       //loop though collection to find matching PRD.
-      auto collIt = (*it)->begin();
-      auto collItEnd = (*it)->end();
+      auto collIt = ptr->begin();
+      auto collItEnd = ptr->end();
       // there MUST be a faster way to do this!!
       for ( ; collIt!=collItEnd; collIt++){
           if ( (*collIt)->identify()==id ) return *collIt;
diff --git a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx
index d7ebd8e5deb..799fdb5825d 100644
--- a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx
@@ -199,9 +199,9 @@ void Muon::MdtRdoToPrepDataToolCore::processRDOContainer( std::vector<Identifier
   for(unsigned int iHash = 0; iHash < m_idHelperSvc->mdtIdHelper().module_hash_max(); iHash++){
     handlePRDHash( IdentifierHash(iHash), *rdoContainer, idWithDataVect);
   }
-  //for (MdtCsmContainer::const_iterator rdoColli = rdoContainer->begin(); rdoColli!=rdoContainer->end(); ++rdoColli) {
+  //for (MdtCsmContainer::const_iterator rdoColl = rdoContainer->begin(); rdoColl!=rdoContainer->end(); ++rdoColl) {
 //
-  //  handlePRDHash( (*rdoColli)->identifyHash(), *rdoContainer, idWithDataVect);
+  //  handlePRDHash( (*rdoColl)->identifyHash(), *rdoContainer, idWithDataVect);
   //}
 
 }
@@ -239,30 +239,30 @@ bool Muon::MdtRdoToPrepDataToolCore::handlePRDHash( IdentifierHash hash, const M
       m_idHelperSvc->mdtIdHelper().get_detectorElement_hash(multilayerId2, multilayerHash2);
       IdentifierHash rdoHash2 = multilayerHash2;
       // Retrieve the two RDO
-      MdtCsmContainer::const_iterator rdoColli  = rdoContainer.indexFind(rdoHash);
-      MdtCsmContainer::const_iterator rdoColli2 = rdoContainer.indexFind(rdoHash2);
-      if( rdoColli != rdoContainer.end() && rdoColli2 != rdoContainer.end() ) {
+      auto rdoColl  = rdoContainer.indexFindPtr(rdoHash);
+      auto rdoColl2 = rdoContainer.indexFindPtr(rdoHash2);
+      if( rdoColl != nullptr && rdoColl2 != nullptr ) {
         // Handle both at once
-        if(processCsm(*rdoColli, idWithDataVect, muDetMgr, *rdoColli2).isFailure()){
+        if(processCsm(rdoColl, idWithDataVect, muDetMgr, rdoColl2).isFailure()){
           ATH_MSG_WARNING("processCsm failed for RDO id " 
-            << (unsigned long long)((*rdoColli)->identify().get_compact()) << " and " 
-            << (unsigned long long)((*rdoColli2)->identify().get_compact()));
+            << (unsigned long long)(rdoColl->identify().get_compact()) << " and " 
+            << (unsigned long long)(rdoColl2->identify().get_compact()));
           return false;
         }
       }
-      else if(rdoColli != rdoContainer.end()){
+      else if(rdoColl != nullptr){
         // Handle just one
         ATH_MSG_DEBUG("Only one RDO container was found for hash " << hash << " despite BME - Missing " << rdoHash2 );
-        if ( processCsm(*rdoColli, idWithDataVect, muDetMgr).isFailure() ) {
-          ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact()));
+        if ( processCsm(rdoColl, idWithDataVect, muDetMgr).isFailure() ) {
+          ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)(rdoColl->identify().get_compact()));
           return false;
         }
       }
-      else if(rdoColli2 != rdoContainer.end()){
+      else if(rdoColl2 != nullptr){
         // Handle just one
         ATH_MSG_DEBUG("Only one RDO container was found for hash " << hash << " despite BME - Missing " << rdoHash );
-        if ( processCsm(*rdoColli2, idWithDataVect, muDetMgr).isFailure() ) {
-          ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact()));
+        if ( processCsm(rdoColl2, idWithDataVect, muDetMgr).isFailure() ) {
+          ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)(rdoColl->identify().get_compact()));
           return false;
         }
       }
@@ -272,20 +272,20 @@ bool Muon::MdtRdoToPrepDataToolCore::handlePRDHash( IdentifierHash hash, const M
     } // End of m_BMEpresent
     else{
       // process CSM if data was found
-      MdtCsmContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash);
-      if( rdoColli != rdoContainer.end() ) {
-        if ( processCsm(*rdoColli, idWithDataVect, muDetMgr).isFailure() ) {
-          ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact()));
+      auto rdoColl = rdoContainer.indexFindPtr(rdoHash);
+      if( rdoColl != nullptr ) {
+        if ( processCsm(rdoColl, idWithDataVect, muDetMgr).isFailure() ) {
+          ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)(rdoColl->identify().get_compact()));
           return false;
         }
       } else ATH_MSG_DEBUG("handlePRDHash: hash id " << (unsigned int)(hash) << " not found in RDO container");
     } 
   } else { // using pre-BME data
     // process CSM if data was found
-    MdtCsmContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash);
-    if( rdoColli != rdoContainer.end() ) {
-      if ( processCsm(*rdoColli, idWithDataVect, muDetMgr).isFailure() ) {
-        ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact()));
+    auto rdoColl = rdoContainer.indexFindPtr(rdoHash);
+    if( rdoColl != nullptr ) {
+      if ( processCsm(rdoColl, idWithDataVect, muDetMgr).isFailure() ) {
+        ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)(rdoColl->identify().get_compact()));
         return false;
       }
     } else ATH_MSG_DEBUG("handlePRDHash: hash id " << (unsigned int)(hash) << " not found in RDO container");
diff --git a/MuonSpectrometer/MuonCnv/MuonPrepRawDataProviderTools/MuonPrepRawDataProviderTools/MuonPrepRawDataCollectionProviderTool.h b/MuonSpectrometer/MuonCnv/MuonPrepRawDataProviderTools/MuonPrepRawDataProviderTools/MuonPrepRawDataCollectionProviderTool.h
index 980ada48072..748c88137b0 100644
--- a/MuonSpectrometer/MuonCnv/MuonPrepRawDataProviderTools/MuonPrepRawDataProviderTools/MuonPrepRawDataCollectionProviderTool.h
+++ b/MuonSpectrometer/MuonCnv/MuonPrepRawDataProviderTools/MuonPrepRawDataProviderTools/MuonPrepRawDataCollectionProviderTool.h
@@ -69,12 +69,12 @@ namespace Muon {
       for( MuonLayerHashProviderTool::HashVec::const_iterator it=hashes.begin();it!=hashes.end();++it ){
         
         // skip if not found
-        typename ContainerType::const_iterator colIt = container->indexFind(*it);
-        if( colIt == container->end() ) {
+        auto col = container->indexFindPtr(*it);
+        if( col == nullptr ) {
           continue;
         }
-        ATH_MSG_VERBOSE("  adding " << m_idHelperSvc->toStringChamber((*colIt)->identify()) << " size " << (*colIt)->size());
-        output.push_back(*colIt);
+        ATH_MSG_VERBOSE("  adding " << m_idHelperSvc->toStringChamber(col->identify()) << " size " << col->size());
+        output.push_back(col);
       }
       return true;
     }
diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx
index 110f7863e25..f763c485979 100644
--- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataToolCore.cxx
@@ -53,7 +53,7 @@ StatusCode Muon::sTgcRdoToPrepDataToolCore::processCollection(const STGC_RawData
   sTgcPrepDataCollection* prdColl = nullptr;
   
   // check if the collection already exists, otherwise add it
-  if ( m_stgcPrepDataContainer->indexFind(hash) != m_stgcPrepDataContainer->end() ) {
+  if ( m_stgcPrepDataContainer->indexFindPtr(hash) != nullptr ) {
 
     ATH_MSG_DEBUG("In processCollection: collection already contained in the MM PrepData container");
     return StatusCode::FAILURE;
diff --git a/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TGC_RodDecoderRawdata.cxx b/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TGC_RodDecoderRawdata.cxx
index 1e55eebd412..232576c5b58 100644
--- a/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TGC_RodDecoderRawdata.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TGC_RodDecoderRawdata.cxx
@@ -82,9 +82,8 @@ StatusCode Muon::TGC_RodDecoderRawdata::fillCollection(const ROBFragment& robFra
   uint16_t rdoId = TgcRdo::calculateOnlineId(sid.subdetector_id(), sid.module_id());
   TgcRdoIdHash rdoIdHash;
   int idHash = rdoIdHash(rdoId);
-  TgcRdoContainer::const_iterator itColl = rdoIdc.indexFind(idHash);
         
-  if(itColl == rdoIdc.end())
+  if(rdoIdc.indexFindPtr(idHash) == nullptr)
     {	
       OFFLINE_FRAGMENTS_NAMESPACE::PointerType bs;
       robFrag.rod_data(bs);
diff --git a/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TgcRdoToPrepDataToolCore.cxx b/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TgcRdoToPrepDataToolCore.cxx
index 39a45acd92f..42dc58c60f7 100644
--- a/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TgcRdoToPrepDataToolCore.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonTGC_CnvTools/src/TgcRdoToPrepDataToolCore.cxx
@@ -1727,7 +1727,7 @@ void Muon::TgcRdoToPrepDataToolCore::showIdentifierHash() {
 bool Muon::TgcRdoToPrepDataToolCore::isIdentifierHashFoundInAnyTgcPrepDataContainer(const IdentifierHash Hash) const
 {
   for(int ibc=0; ibc<NBC+1; ibc++) {
-    if(m_tgcPrepDataContainer[ibc]->indexFind(Hash) != m_tgcPrepDataContainer[ibc]->end()) {
+    if(m_tgcPrepDataContainer[ibc]->indexFindPtr(Hash) != nullptr) {
       return true;
     }
   }
@@ -1737,7 +1737,7 @@ bool Muon::TgcRdoToPrepDataToolCore::isIdentifierHashFoundInAnyTgcPrepDataContai
 bool Muon::TgcRdoToPrepDataToolCore::isIdentifierHashFoundInAnyTgcCoinDataContainer(const IdentifierHash Hash) const
 {
   for(int ibc=0; ibc<NBC; ibc++) {
-    if(m_tgcCoinDataContainer[ibc]->indexFind(Hash) != m_tgcCoinDataContainer[ibc]->end()) {
+    if(m_tgcCoinDataContainer[ibc]->indexFindPtr(Hash) != nullptr) {
       return true;
     }
   }
diff --git a/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx
index 02b1472afa4..b5642a287e4 100644
--- a/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx
+++ b/MuonSpectrometer/MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx
@@ -944,8 +944,8 @@ MdtDigitCollection* MdtDigitizationTool::getDigitCollection(Identifier elementId
   
   StatusCode status;
   // Get the messaging service, print where you are
-  MdtDigitContainer::const_iterator it_coll = digitContainer->indexFind(coll_hash);
-  if (digitContainer->end() ==  it_coll) {
+  const MdtDigitCollection *coll = digitContainer->indexFindPtr(coll_hash);
+  if (nullptr ==  coll) {
     digitCollection = new MdtDigitCollection(elementId, coll_hash);
     status = digitContainer->addCollection(digitCollection, coll_hash);
     if (status.isFailure())
@@ -954,7 +954,7 @@ MdtDigitCollection* MdtDigitizationTool::getDigitCollection(Identifier elementId
       ATH_MSG_DEBUG ( "New MdtDigitCollection with key=" << coll_hash << " recorded in StoreGate." );
   } 
   else { 
-    digitCollection = const_cast<MdtDigitCollection*>( *it_coll );
+    digitCollection = const_cast<MdtDigitCollection*>( coll );
   }
   return digitCollection;
 }
diff --git a/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx
index 25c1f00978a..9c899ba24cd 100644
--- a/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx
+++ b/MuonSpectrometer/MuonDigitization/MM_Digitization/src/MM_DigitizationTool.cxx
@@ -1251,14 +1251,14 @@ StatusCode MM_DigitizationTool::doDigitization(const EventContext& ctx) {
     MmDigitCollection* digitCollection = nullptr;
     // put new collection in storegate
     // Get the messaging service, print where you are
-    MmDigitContainer::const_iterator it_coll = digitContainer->indexFind(moduleHash );
-    if (digitContainer->end() ==  it_coll) {
+    const MmDigitCollection* coll = digitContainer->indexFindPtr(moduleHash );
+    if (nullptr ==  coll) {
       digitCollection = new MmDigitCollection( elemId, moduleHash );
       digitCollection->push_back(std::move(newDigit));
       ATH_CHECK(digitContainer->addCollection(digitCollection, moduleHash ) );
     }
     else {
-      digitCollection = const_cast<MmDigitCollection*>( *it_coll );
+      digitCollection = const_cast<MmDigitCollection*>( coll );
       digitCollection->push_back(std::move(newDigit));
     }
     
diff --git a/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx
index 314c150ef5d..23132381482 100644
--- a/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx
+++ b/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx
@@ -873,8 +873,8 @@ StatusCode RpcDigitizationTool::doDigitization(const EventContext& ctx, RpcDigit
 	  //std::cout << "Digit Id = " << m_idHelper->show_to_string(theId)<<" digit time "<<newDigit_time << std::endl;
 
 	  // put new collection in storegate
-	  RpcDigitContainer::const_iterator it_coll = digitContainer->indexFind(coll_hash);
-	  if (digitContainer->end() ==  it_coll) {
+	  const RpcDigitCollection* coll = digitContainer->indexFindPtr(coll_hash);
+	  if (nullptr ==  coll) {
 	    digitCollection = new RpcDigitCollection(elemId,coll_hash);
 	    digitCollection->push_back(newDigit);
 	    StatusCode status = digitContainer->addCollection(digitCollection, coll_hash);
@@ -888,7 +888,7 @@ StatusCode RpcDigitizationTool::doDigitization(const EventContext& ctx, RpcDigit
 	      ATH_MSG_DEBUG ( "New RpcHitCollection with key=" << coll_hash << " recorded in StoreGate." );
 	    }
 	  } else {
-	    digitCollection = const_cast<RpcDigitCollection*>( *it_coll );
+	    digitCollection = const_cast<RpcDigitCollection*>( coll );
 	    digitCollection->push_back(newDigit);
 	  }
 
diff --git a/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx
index 4416a237901..4493b4c40c4 100644
--- a/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx
+++ b/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx
@@ -329,8 +329,8 @@ StatusCode TgcDigitizationTool::digitizeCore(const EventContext& ctx) const {
   
 	// record the digit container in StoreGate
 	bool duplicate = false;
-	TgcDigitContainer::const_iterator it_coll = digitContainer->indexFind(coll_hash);
-	if(digitContainer->end() ==  it_coll) {
+	auto coll = digitContainer->indexFindPtr(coll_hash);
+	if(nullptr ==  coll) {
 	  digitCollection = new TgcDigitCollection(elemId, coll_hash);
 	  ATH_MSG_DEBUG("Digit Id(1st) = " << m_idHelper->show_to_string(newDigiId)
 			<< " BC tag = " << newBcTag << " Coll. key = " << coll_hash); 
@@ -342,7 +342,7 @@ StatusCode TgcDigitizationTool::digitizeCore(const EventContext& ctx) const {
 	    ATH_MSG_DEBUG("New TgcHitCollection with key=" << coll_hash << " recorded in StoreGate."); 
 	  }
 	} else {
-	  digitCollection = const_cast<TgcDigitCollection*>(*it_coll);
+	  digitCollection = const_cast<TgcDigitCollection*>(coll);
 
 	  // to avoid to store digits with identical id
 	  TgcDigitCollection::const_iterator it_tgcDigit;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx
index 95349b049ff..f4959afdbc3 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx
@@ -184,14 +184,14 @@ vector<const CscStripPrepData*> CscClusterUtilTool::getStrips(const CscPrepData*
 
 
   IdentifierHash elhash=MClus->collectionHash();
-  CscStripPrepDataContainer::const_iterator it = pdigcont->indexFind(elhash);
+  auto it = pdigcont->indexFindPtr(elhash);
 
   ATH_MSG_VERBOSE ( "Hash " << elhash << " converted to iterator of container successfully");
   
-  if (it != pdigcont->end()) {
+  if (it != nullptr) {
     ATH_MSG_VERBOSE ( " it == pdigcont.end() passed");
     for ( unsigned int istrip=0; istrip<prd_digit_ids.size(); ++istrip ) {
-      const CscStripPrepDataCollection& col = **it;
+      const CscStripPrepDataCollection& col = *it;
       // Loop over digits and fill these arrays.
       for ( CscStripPrepDataCollection::const_iterator idig=col.begin();
             idig!=col.end(); ++idig ) {
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx
index f25a46bade3..6bbeef22093 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx
@@ -202,7 +202,7 @@ StatusCode CscPeakThresholdClusterBuilderTool::getClusters(std::vector<Identifie
 StatusCode CscPeakThresholdClusterBuilderTool::getClusters(IdentifierHash givenHashId, std::vector<IdentifierHash>& decodedIds) {
 
   // identifiers of collections already decoded and stored in the container will be skipped
-  if (m_cluster_handle->indexFind(givenHashId) != m_cluster_handle->end()) {
+  if (m_cluster_handle->indexFindPtr(givenHashId) != nullptr) {
     decodedIds.push_back(givenHashId);
     ATH_MSG_DEBUG ( "A collection already exists in the container for offline id hash. "
                     << (int) givenHashId );
@@ -223,14 +223,13 @@ StatusCode CscPeakThresholdClusterBuilderTool::getClusters(IdentifierHash givenH
 
   //**********************************************
   // retrieve specific collection for the givenID
-  CscStripPrepDataContainer::const_iterator it_coll = pdigcon->indexFind(givenHashId);
-  if (pdigcon->end() ==  it_coll) {
+  const CscStripPrepDataCollection * col = pdigcon->indexFindPtr(givenHashId);
+  if (nullptr ==  col) {
     unsigned int coll_hash = givenHashId;
     ATH_MSG_WARNING ( "Specific CSC Strip PrepData collection retrieving failed for collection hash = "
                       << coll_hash );
     return StatusCode::SUCCESS;
   }
-  const CscStripPrepDataCollection * col = *it_coll;
   
   ATH_MSG_DEBUG ( "Retrieved " << col->size() << " CSC Strip PrepDatas." );
   
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx
index 693e3934584..2067a000b74 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx
@@ -226,7 +226,7 @@ StatusCode CscThresholdClusterBuilderTool::getClusters(std::vector<IdentifierHas
 StatusCode CscThresholdClusterBuilderTool::getClusters(IdentifierHash givenHashId, std::vector<IdentifierHash>& decodedIds, Muon::CscPrepDataContainer *pclusters) {
 
   // identifiers of collections already decoded and stored in the container will be skipped
-  if (pclusters->indexFind(givenHashId) != pclusters->end()) {
+  if (pclusters->indexFindPtr(givenHashId) != nullptr) {
     decodedIds.push_back(givenHashId);
     ATH_MSG_DEBUG ( "A collection already exists in the container for offline id hash. "
                     << (int) givenHashId );
@@ -247,14 +247,13 @@ StatusCode CscThresholdClusterBuilderTool::getClusters(IdentifierHash givenHashI
 
   //**********************************************
   // retrieve specific collection for the givenID
-  CscStripPrepDataContainer::const_iterator it_coll = pdigcon->indexFind(givenHashId);
-  if (pdigcon->end() ==  it_coll) {
+  const CscStripPrepDataCollection * col = pdigcon->indexFindPtr(givenHashId);
+  if (nullptr ==  col) {
     unsigned int coll_hash = givenHashId;
     ATH_MSG_WARNING ( "Specific CSC Strip PrepData collection retrieving failed for collection hash = "
                       << coll_hash );
     return StatusCode::SUCCESS;
   }
-  const CscStripPrepDataCollection * col = *it_coll;
   
   ATH_MSG_DEBUG ( "Retrieved " << col->size() << " CSC Strip PrepDatas." );
   
@@ -339,7 +338,7 @@ StatusCode CscThresholdClusterBuilderTool::getClusters(std::vector<IdentifierHas
        icol!=con.end(); ++icol) {
     const CscStripPrepDataCollection& col = **icol;
     //check if the collection is already used    
-    if (pclusters->indexFind(col.identifyHash()) != pclusters->end()) {
+    if (pclusters->indexFindPtr(col.identifyHash()) != nullptr) {
       //store the identifier hash and continue
       decodedIds.push_back(col.identifyHash());
       continue;      
diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonAssociationTools/src/MuonPRD_Provider.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonAssociationTools/src/MuonPRD_Provider.h
index 4d57a27368c..c471a9894ee 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonAssociationTools/src/MuonPRD_Provider.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonAssociationTools/src/MuonPRD_Provider.h
@@ -50,12 +50,11 @@ namespace Muon {
 									       const Identifier& ideh, const IdentifierHash& ideHash ) const 
     {
       // find the collection
-      typename MuonPrepDataContainer< MuonPrepDataCollection< PrdT > >::const_iterator prdCollIter = cont.indexFind(ideHash);
-      if ( prdCollIter == cont.end() ){
+      const MuonPrepDataCollection< PrdT >* prdCollection = cont.indexFindPtr(ideHash);
+      if ( prdCollection == nullptr ){
 	ATH_MSG_VERBOSE("PRD Collection to IdentifierHash could not be found. Return 0.");
 	return 0;
       }
-      const MuonPrepDataCollection< PrdT >* prdCollection = (*prdCollIter);
       // search for the PRD in the collection --- do a loop, can be done better with std::find probably
       const PrdT* prd = 0;
       // iterate through the collections
diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx
index a1040f68da9..b693897790c 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecHelperTools/src/MuonEDMPrinterTool.cxx
@@ -729,8 +729,8 @@ namespace Muon {
 	mdtPrdContainer = rh_mdt.cptr();
         IdentifierHash hash_id;
         m_idHelperSvc->mdtIdHelper().get_module_hash(chId,hash_id );
-        MdtPrepDataContainer::const_iterator colIt = mdtPrdContainer->indexFind(hash_id);
-        if( colIt != mdtPrdContainer->end() ) nchHitsEta = (*colIt)->size();
+        auto coll = mdtPrdContainer->indexFindPtr(hash_id);
+        if( coll != nullptr ) nchHitsEta = coll->size();
         else 	  ATH_MSG_DEBUG("Collection not found: hash " << hash_id);
       }
     }else if( m_idHelperSvc->isRpc(chId) ){
@@ -742,10 +742,10 @@ namespace Muon {
 	rpcPrdContainer = rh_rpc.cptr();
         IdentifierHash hash_id;
         m_idHelperSvc->rpcIdHelper().get_module_hash(chId,hash_id );
-        RpcPrepDataContainer::const_iterator colIt = rpcPrdContainer->indexFind(hash_id);
-        if( colIt != rpcPrdContainer->end() ) {
-          RpcPrepDataCollection::const_iterator rpcIt = (*colIt)->begin();
-          RpcPrepDataCollection::const_iterator rpcIt_end = (*colIt)->end();
+        auto coll = rpcPrdContainer->indexFindPtr(hash_id);
+        if( coll != nullptr ) {
+          RpcPrepDataCollection::const_iterator rpcIt = coll->begin();
+          RpcPrepDataCollection::const_iterator rpcIt_end = coll->end();
           for( ;rpcIt!=rpcIt_end;++rpcIt ){
             if( m_idHelperSvc->measuresPhi((*rpcIt)->identify()) ) ++nchHitsPhi;
             else                                                ++nchHitsEta;
@@ -761,10 +761,10 @@ namespace Muon {
 	tgcPrdContainer = rh_tgc.cptr();
         IdentifierHash hash_id;
         m_idHelperSvc->tgcIdHelper().get_module_hash(chId,hash_id );
-        TgcPrepDataContainer::const_iterator colIt = tgcPrdContainer->indexFind(hash_id);
-        if( colIt != tgcPrdContainer->end() ) {
-          TgcPrepDataCollection::const_iterator tgcIt = (*colIt)->begin();
-          TgcPrepDataCollection::const_iterator tgcIt_end = (*colIt)->end();
+        auto coll = tgcPrdContainer->indexFindPtr(hash_id);
+        if( coll != nullptr ) {
+          TgcPrepDataCollection::const_iterator tgcIt = coll->begin();
+          TgcPrepDataCollection::const_iterator tgcIt_end = coll->end();
           for( ;tgcIt!=tgcIt_end;++tgcIt ){
             if( m_idHelperSvc->measuresPhi((*tgcIt)->identify()) ) ++nchHitsPhi;
             else                                                ++nchHitsEta;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonTrackSummaryHelperTool/src/MuonTrackSummaryHelperTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonTrackSummaryHelperTool/src/MuonTrackSummaryHelperTool.cxx
index 4482125f1b0..63b654ce806 100755
--- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonTrackSummaryHelperTool/src/MuonTrackSummaryHelperTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonTrackSummaryHelperTool/src/MuonTrackSummaryHelperTool.cxx
@@ -595,11 +595,11 @@ const Muon::MdtPrepDataCollection* Muon::MuonTrackSummaryHelperTool::findMdtPrdC
   IdentifierHash hash_id;
   m_idHelperSvc->mdtIdHelper().get_module_hash(chId,hash_id );
 
-  Muon::MdtPrepDataContainer::const_iterator colIt = mdtPrdContainer->indexFind(hash_id);
-  if( colIt == mdtPrdContainer->end() ){
+  auto coll = mdtPrdContainer->indexFindPtr(hash_id);
+  if( coll == nullptr ){
     ATH_MSG_DEBUG(" MdtPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(chId) 
 		  << "  not found in container ");
     return 0;
   }
-  return *colIt;
+  return coll;
 }
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx
index 130c7e81aa4..78911fe942c 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx
@@ -315,12 +315,12 @@ namespace Muon {
       std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
       std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
       for( ;chit!=chit_end;++chit ){
-	TgcPrepDataContainer::const_iterator colIt = prdContainer->indexFind(*chit);
-	if( colIt == prdContainer->end() || !*colIt ) {
+	auto collptr = prdContainer->indexFindPtr(*chit);
+	if( collptr == nullptr  ) {
 	  ATH_MSG_VERBOSE("Could not find collection ");
 	  continue;
 	}
-	const TgcPrepDataCollection& col = **colIt;
+	const TgcPrepDataCollection& col = *collptr;
 	ATH_MSG_VERBOSE("Found collection: " << m_idHelperSvc->toStringChamber(col.identify()) << " size " << col.size() );
 	TgcPrepDataCollection::const_iterator hit = col.begin();
 	TgcPrepDataCollection::const_iterator hit_end = col.end();
@@ -356,10 +356,10 @@ namespace Muon {
       std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
       std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
       for( ;chit!=chit_end;++chit ){
-	RpcPrepDataContainer::const_iterator colIt = prdContainer->indexFind(*chit);
-	if( colIt == prdContainer->end() || !*colIt ) continue;
+	auto collptr = prdContainer->indexFindPtr(*chit);
+	if( collptr == nullptr ) continue;
 	
-	const RpcPrepDataCollection& col = **colIt;
+	const RpcPrepDataCollection& col = *collptr;
 	RpcPrepDataCollection::const_iterator hit = col.begin();
 	RpcPrepDataCollection::const_iterator hit_end = col.end();
 	for( ;hit!=hit_end;++hit ){
@@ -2353,9 +2353,9 @@ namespace Muon {
 	ATH_MSG_WARNING("No MDT prd collection retrieved");
 	return 0;
       }
-      MdtPrepDataContainer::const_iterator colIt = prdContainer->indexFind(colHash);
-      if( colIt == prdContainer->end() || !*colIt ) return 0;
-      const MdtPrepDataCollection& col = **colIt;
+      auto collptr = prdContainer->indexFindPtr(colHash);
+      if( collptr == nullptr ) return 0;
+      const MdtPrepDataCollection& col = *collptr;
       MdtPrepDataCollection::const_iterator mdtIt = col.begin();
       MdtPrepDataCollection::const_iterator mdtIt_end = col.end();
       for( ;mdtIt!=mdtIt_end;++mdtIt ){
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx
index c727a2167fe..6f2d38b288c 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx
@@ -520,14 +520,14 @@ return (fabs(i.z()) < fabs(j.z()));}
     // loop over hashes
     for( MuonLayerHashProviderTool::HashVec::const_iterator it=hashes.begin();it!=hashes.end();++it ){
       // skip if not found
-      Muon::MdtPrepDataContainer::const_iterator colIt = input->indexFind(*it);
-      if( colIt == input->end() ) {
+      auto col = input->indexFindPtr(*it);
+      if( col == nullptr ) {
 	//ATH_MSG_WARNING("Cannot find hash " << *it << " in container at " << location);
 	continue;
       }
-      ATH_MSG_VERBOSE("  adding " << m_idHelperSvc->toStringChamber((*colIt)->identify()) << " size " << (*colIt)->size());
+      ATH_MSG_VERBOSE("  adding " << m_idHelperSvc->toStringChamber(col->identify()) << " size " << col->size());
       // else add
-      output.push_back(*colIt);
+      output.push_back(col);
     }
     return true;
   }
diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonChamberHoleRecoveryTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonChamberHoleRecoveryTool.cxx
index ab04451d3a0..5fe1fe550e5 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonChamberHoleRecoveryTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonChamberHoleRecoveryTool.cxx
@@ -1311,13 +1311,13 @@ namespace Muon {
     IdentifierHash hash_id;
     m_idHelperSvc->mdtIdHelper().get_module_hash(chId,hash_id );
     
-    MdtPrepDataContainer::const_iterator colIt = mdtPrdContainer->indexFind(hash_id);
-    if( colIt == mdtPrdContainer->end() ){
+    auto collptr = mdtPrdContainer->indexFindPtr(hash_id);
+    if( collptr == nullptr ){
       ATH_MSG_DEBUG(" MdtPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(chId)
 		    << "  not found in container " );
       return 0;
     }
-    return *colIt;
+    return collptr;
   }
 
   const CscPrepDataCollection* MuonChamberHoleRecoveryTool::findCscPrdCollection( const Identifier& detElId ) const {
@@ -1335,13 +1335,13 @@ namespace Muon {
     IdentifierHash hash_id;
     m_idHelperSvc->cscIdHelper().get_geo_module_hash(detElId,hash_id );
     
-    CscPrepDataContainer::const_iterator colIt = cscPrdContainer->indexFind(hash_id);
-    if( colIt == cscPrdContainer->end() ){
+    auto collptr = cscPrdContainer->indexFindPtr(hash_id);
+    if( collptr == nullptr ){
       ATH_MSG_DEBUG(" CscPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(detElId)
 		    << "  not found in container " );
       return 0;
     }
-    return *colIt;
+    return collptr;
   }
 
   const TgcPrepDataCollection* MuonChamberHoleRecoveryTool::findTgcPrdCollection( const Identifier& detElId ) const {
@@ -1359,13 +1359,13 @@ namespace Muon {
     IdentifierHash hash_id;
     m_idHelperSvc->tgcIdHelper().get_module_hash(detElId,hash_id );
 
-    TgcPrepDataContainer::const_iterator colIt = tgcPrdContainer->indexFind(hash_id);
-    if( colIt == tgcPrdContainer->end() ){
+    auto collptr = tgcPrdContainer->indexFindPtr(hash_id);
+    if( collptr == nullptr ){
       ATH_MSG_DEBUG(" TgcPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(detElId)
 		    << "  not found in container " );
       return 0;
     }
-    return *colIt;
+    return collptr;
   }
 
   const RpcPrepDataCollection* MuonChamberHoleRecoveryTool::findRpcPrdCollection( const Identifier& detElId ) const {
@@ -1382,12 +1382,12 @@ namespace Muon {
     if(rpcPrdContainer->size()==0) return 0;
     IdentifierHash hash_id;
     m_idHelperSvc->rpcIdHelper().get_module_hash(detElId,hash_id );
-    RpcPrepDataContainer::const_iterator colIt = rpcPrdContainer->indexFind(hash_id);
-    if( colIt == rpcPrdContainer->end() ){
+    auto collptr = rpcPrdContainer->indexFindPtr(hash_id);
+    if( collptr == nullptr ){
       ATH_MSG_DEBUG(" RpcPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(detElId) << "  not found in container " );
       return 0;
     }
-    return *colIt;
+    return collptr;
   }
 
   const sTgcPrepDataCollection* MuonChamberHoleRecoveryTool::findStgcPrdCollection( const Identifier& detElId ) const {
@@ -1405,13 +1405,13 @@ namespace Muon {
     IdentifierHash hash_id;
     m_idHelperSvc->stgcIdHelper().get_module_hash(detElId, hash_id );
     
-    sTgcPrepDataContainer::const_iterator colIt = stgcPrdContainer->indexFind(hash_id);
-    if ( colIt == stgcPrdContainer->end() ) {
+    auto collptr = stgcPrdContainer->indexFindPtr(hash_id);
+    if ( collptr == nullptr ) {
       ATH_MSG_DEBUG(" StgcPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(detElId)
 		    << "  not found in container " );
       return 0;
     }
-    return *colIt;
+    return collptr;
   }
 
   const MMPrepDataCollection* MuonChamberHoleRecoveryTool::findMmPrdCollection( const Identifier& detElId ) const {
@@ -1430,13 +1430,13 @@ namespace Muon {
     IdentifierHash hash_id;
     m_idHelperSvc->mmIdHelper().get_module_hash(detElId, hash_id );
     
-    MMPrepDataContainer::const_iterator colIt = mmPrdContainer->indexFind(hash_id);
-    if ( colIt == mmPrdContainer->end() ) {
+    auto collptr = mmPrdContainer->indexFindPtr(hash_id);
+    if ( collptr == nullptr ) {
       ATH_MSG_DEBUG(" MmPrepDataCollection for:   " << m_idHelperSvc->toStringChamber(detElId)
 		    << "  not found in container " );
       return 0;
     }
-    return *colIt;
+    return collptr;
   }
 
 }
diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx
index 89c15dfcb58..057ca04b3b9 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx
@@ -189,13 +189,13 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for( ;chit!=chit_end;++chit ){
-      MdtPrepDataContainer::const_iterator colIt = mdtPrdContainer->indexFind(*chit);
-      if( colIt == mdtPrdContainer->end() ){
+      auto collptr = mdtPrdContainer->indexFindPtr(*chit);
+      if( collptr == nullptr ){
 	continue;
       }
       
       // reserve space for the new PRDs
-      mdtPrds.insert( mdtPrds.end(), (*colIt)->begin(), (*colIt)->end() );
+      mdtPrds.insert( mdtPrds.end(), collptr->begin(), collptr->end() );
     }
 
     return mdtPrds;
@@ -219,16 +219,16 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for( ;chit!=chit_end;++chit ){
-      MdtPrepDataContainer::const_iterator colIt = mdtPrdContainer->indexFind(*chit);
-      if( colIt == mdtPrdContainer->end() || (*colIt)->empty() ){
+      auto collptr = mdtPrdContainer->indexFindPtr(*chit);
+      if( collptr == nullptr || collptr->empty() ){
 	continue;
       }
       ATH_MSG_DEBUG(" Adding for:   " 
-		    << m_idHelperSvc->toStringChamber( (*colIt)->front()->identify() ) << "  size " 
-		    << (*colIt)->size());
+		    << m_idHelperSvc->toStringChamber( collptr->front()->identify() ) << "  size " 
+		    << collptr->size());
       
       // reserve space for the new PRDs
-      target.push_back(*colIt);
+      target.push_back(collptr);
     }
   }
 
@@ -251,16 +251,16 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for( ;chit!=chit_end;++chit ){
-      RpcPrepDataContainer::const_iterator colIt = rpcPrdContainer->indexFind(*chit);
-      if( colIt == rpcPrdContainer->end() || (*colIt)->empty() ){
+      auto collptr = rpcPrdContainer->indexFindPtr(*chit);
+      if( collptr == nullptr || collptr->empty() ){
 	continue;
       }
       ATH_MSG_DEBUG(" Adding for:   " 
-		    << m_idHelperSvc->toStringChamber( (*colIt)->front()->identify() ) << "  size " 
-		    << (*colIt)->size());
+		    << m_idHelperSvc->toStringChamber( collptr->front()->identify() ) << "  size " 
+		    << collptr->size());
       
       // reserve space for the new PRDs
-      target.push_back(*colIt);
+      target.push_back(collptr);
     }
   }
 
@@ -283,16 +283,16 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for( ;chit!=chit_end;++chit ){
-      TgcPrepDataContainer::const_iterator colIt = tgcPrdContainer->indexFind(*chit);
-      if( colIt == tgcPrdContainer->end() || (*colIt)->empty() ){
+      auto collptr = tgcPrdContainer->indexFindPtr(*chit);
+      if( collptr == nullptr || collptr->empty() ){
 	continue;
       }
       ATH_MSG_DEBUG(" Adding for:   " 
-		    << m_idHelperSvc->toStringChamber( (*colIt)->front()->identify() ) << "  size " 
-		    << (*colIt)->size());
+		    << m_idHelperSvc->toStringChamber( collptr->front()->identify() ) << "  size " 
+		    << collptr->size());
 
       // reserve space for the new PRDs
-      target.push_back(*colIt);
+      target.push_back(collptr);
     }
   }
 
@@ -320,17 +320,17 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for( ;chit!=chit_end;++chit ){
-      CscPrepDataContainer::const_iterator colIt = cscPrdContainer->indexFind(*chit);
-      if( colIt == cscPrdContainer->end() || (*colIt)->empty() ){
+      auto collptr = cscPrdContainer->indexFindPtr(*chit);
+      if( collptr == nullptr || collptr->empty() ){
 	continue;
       }
       
       ATH_MSG_DEBUG(" Adding for:   " 
-		    << m_idHelperSvc->toStringChamber( (*colIt)->front()->identify() ) << "  size " 
-		    << (*colIt)->size());
+		    << m_idHelperSvc->toStringChamber( collptr->front()->identify() ) << "  size " 
+		    << collptr->size());
 
       // reserve space for the new PRDs
-      target.push_back(*colIt);
+      target.push_back(collptr);
     }
   }
 
@@ -360,16 +360,16 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for( ;chit!=chit_end;++chit ){
-      sTgcPrepDataContainer::const_iterator colIt = stgcPrdContainer->indexFind(*chit);
-      if( colIt == stgcPrdContainer->end() || (*colIt)->empty() ){                                                                                                           
+      auto collptr = stgcPrdContainer->indexFindPtr(*chit);
+      if( collptr == nullptr || collptr->empty() ){
         continue;
       }
       ATH_MSG_DEBUG(" Adding for:   "
-                    << m_idHelperSvc->toStringChamber( (*colIt)->front()->identify() ) << "  size "
-                    << (*colIt)->size());
+                    << m_idHelperSvc->toStringChamber( collptr->front()->identify() ) << "  size "
+                    << collptr->size());
 
       // reserve space for the new PRDs                                                                                                                                                                
-      target.push_back(*colIt);
+      target.push_back(collptr);
     }
 
     if(chIdHs.size()==0) {
@@ -412,15 +412,15 @@ namespace Muon {
     std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
     std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
     for ( ; chit != chit_end; ++chit ) {
-      MMPrepDataContainer::const_iterator colIt = mmPrdContainer->indexFind(*chit);
-      if ( colIt == mmPrdContainer->end() || (*colIt)->empty() ) {
+      auto collptr = mmPrdContainer->indexFindPtr(*chit);
+      if ( collptr == nullptr || collptr->empty() ) {
 	continue;
       }
       ATH_MSG_DEBUG(" Adding for:   "
-		    << m_idHelperSvc->toStringChamber( (*colIt)->front()->identify() ) << "  size "
-		    << (*colIt)->size());
+		    << m_idHelperSvc->toStringChamber( collptr->front()->identify() ) << "  size "
+		    << collptr->size());
       
-      target.push_back(*colIt);
+      target.push_back(collptr);
     }
     
     if(chIdHs.size()==0) {
diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValAlg.cxx
index 9e78fb49f11..7cce3019516 100755
--- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValAlg.cxx
+++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValAlg.cxx
@@ -841,13 +841,12 @@ void  CscClusterValAlg::FillCSCClusters( const CscPrepDataContainer* cols, const
           m_h2csc_clus_hitmap->Fill(stripid, secLayer);
 
           if(!pcol) {
-            CscStripPrepDataContainer::const_iterator icol = strips->indexFind(clus.identifyHash());
-            if ( icol == strips->end() ) {
+            const CscStripPrepDataCollection* icol = strips->indexFindPtr(clus.identifyHash());
+            if ( icol == nullptr ) {
               found_id = false;
               break;  // could not identify the strips
             } else {
-              pcol = *icol;
-              if(!pcol) found_id = false;
+              pcol = icol;
             }
           } // end if !pcol  
 
@@ -858,7 +857,7 @@ void  CscClusterValAlg::FillCSCClusters( const CscPrepDataContainer* cols, const
               found_strip = ( *istrip )->identify() == id ; 
               if(found_strip) {
                 stripVec.push_back(*istrip);
-                std::vector<float> samp_charges = ( *istrip )->sampleCharges();
+                const std::vector<float> &samp_charges = ( *istrip )->sampleCharges();
                 for(unsigned int i = 0; i < samp_charges.size(); i++ ) {
                   if(samp_charges[i] > maxsampChVal) maxsampChVal = samp_charges[i];
                 }
diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValMonAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValMonAlg.cxx
index 41196d377f3..3b426847449 100644
--- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValMonAlg.cxx
+++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/CscRawDataMonitoring/src/CscClusterValMonAlg.cxx
@@ -227,13 +227,12 @@ StatusCode CscClusterValMonAlg::fillHistograms( const EventContext& ctx ) const
           fill("CscClusMonitor",stripid, secLayer);
 
           if(!pcol) {
-            CscStripPrepDataContainer::const_iterator icol = cscStrip->indexFind(clus.identifyHash());
-            if ( icol == cscStrip->end() ) {
+            const CscStripPrepDataCollection* icol = cscStrip->indexFindPtr(clus.identifyHash());
+            if ( icol == nullptr ) {
               found_id = false;
               break;  // could not identify the strips
             } else {
-              pcol = *icol;
-              if(!pcol) found_id = false;
+              pcol = icol;
             }
           } // end if !pcol  
 
diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx
index 603629547bd..838f764948a 100644
--- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx
+++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx
@@ -38,7 +38,7 @@ StatusCode MMPRDVariables::fillVariables(const MuonGM::MuonDetectorManager* Muon
 
   for(const Muon::MMPrepDataCollection* coll : *nsw_MMPrepDataContainer) {
 
-    const Muon::MM_RawDataCollection* rdo_coll = *rdo_container->indexFind(coll->identifyHash());
+    const Muon::MM_RawDataCollection* rdo_coll = rdo_container->indexFindPtr(coll->identifyHash());
     if(rdo_coll==0){
       ATH_MSG_ERROR("Did not find rdo collection " << coll->identifyHash());
       return StatusCode::FAILURE;
-- 
GitLab