diff --git a/Analysis/TotalInvMass/CMakeLists.txt b/Analysis/TotalInvMass/CMakeLists.txt
index 6a9be88ec6a7332efd371b9aa91c4f5a0956623b..25c509a0a74d36b45664760b9a36d736305d6ddc 100644
--- a/Analysis/TotalInvMass/CMakeLists.txt
+++ b/Analysis/TotalInvMass/CMakeLists.txt
@@ -11,6 +11,9 @@ gaudi_add_module(TotalInvMass
                       ${ROOT_LIBRARIES}
 )
 
+target_include_directories(TotalInvMass
+  PUBLIC ${LCIO_INCLUDE_DIRS})
+
 install(TARGETS TotalInvMass
   EXPORT CEPCSWTargets
   RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
diff --git a/Analysis/TrackInspect/CMakeLists.txt b/Analysis/TrackInspect/CMakeLists.txt
index a004d0104da456fb2225738b481141c285281122..50314388b239adb514f5af7f0c34b25b20e005ff 100644
--- a/Analysis/TrackInspect/CMakeLists.txt
+++ b/Analysis/TrackInspect/CMakeLists.txt
@@ -2,7 +2,8 @@
 # Modules
 gaudi_add_module(TrackInspect
                  SOURCES src/TrackInspectAlg.cpp
-                 LINK DataHelperLib 
+                 LINK DataHelperLib
+                      k4FWCore::k4FWCore
                       Gaudi::GaudiKernel 
                       EDM4HEP::edm4hep 
                       k4FWCore::k4FWCore
diff --git a/Detector/GeomSvc/CMakeLists.txt b/Detector/GeomSvc/CMakeLists.txt
index 137aa0e58561f914a5f8b194b5038c11b9f7d308..997f9e97f1ab2683391f93464f83f3def84c70a9 100644
--- a/Detector/GeomSvc/CMakeLists.txt
+++ b/Detector/GeomSvc/CMakeLists.txt
@@ -14,6 +14,10 @@ gaudi_add_module(GeomSvc
                    ${ROOT_LIBRARIES}
 )
 
+target_include_directories(GeomSvc
+  PUBLIC ${GEAR_INCLUDE_DIRS}
+)
+
 install(TARGETS GeomSvc
   EXPORT CEPCSWTargets
   RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
diff --git a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
index 01fb9406a6811e673a8f1d5e53c9c43bcc6893ea..4a68a1eaab65331ac733cff1ca59c05c088271a6 100644
--- a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
+++ b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
@@ -93,14 +93,21 @@ StatusCode DCHDigiAlg::execute()
 
   info() << "Processing " << _nEvt << " events " << endmsg;
   m_evt = _nEvt;
-  std::map<unsigned long long, std::vector<edm4hep::SimTrackerHit> > id_hits_map;
   edm4hep::TrackerHitCollection* Vec   = w_DigiDCHCol.createAndPut();
   edm4hep::MCRecoTrackerAssociationCollection* AssoVec   = w_AssociationCol.createAndPut();
   const edm4hep::SimTrackerHitCollection* SimHitCol =  r_SimDCHCol.get();
+  if (SimHitCol->size() == 0) {
+    return StatusCode::SUCCESS;
+  }
   debug()<<"input sim hit size="<< SimHitCol->size() <<endmsg;
+
+  auto SimHit0 = SimHitCol->at(0);
+  std::map<unsigned long long, std::vector<decltype(SimHit0)> > id_hits_map;
+  //std::map<unsigned long long, std::vector<edm4hep::ConstSimTrackerhit> > id_hits_map;
+
   for( int i = 0; i < SimHitCol->size(); i++ ) 
   {
-      edm4hep::SimTrackerHit SimHit = SimHitCol->at(i);
+      auto SimHit = SimHitCol->at(i);
       unsigned long long id = SimHit.getCellID();
       float sim_hit_mom = sqrt( SimHit.getMomentum()[0]*SimHit.getMomentum()[0] + SimHit.getMomentum()[1]*SimHit.getMomentum()[1] + SimHit.getMomentum()[2]*SimHit.getMomentum()[2] );//GeV
       if(sim_hit_mom < m_mom_threshold) continue; 
@@ -109,7 +116,7 @@ StatusCode DCHDigiAlg::execute()
       if ( id_hits_map.find(id) != id_hits_map.end()) id_hits_map[id].push_back(SimHit);
       else 
       {
-          std::vector<edm4hep::SimTrackerHit> vhit;
+          std::vector< decltype(SimHit) > vhit;
           vhit.push_back(SimHit);
           id_hits_map[id] = vhit ;
       }
@@ -118,7 +125,7 @@ StatusCode DCHDigiAlg::execute()
       m_n_sim = 0;
       m_n_digi = 0 ;
   }
-  for(std::map<unsigned long long, std::vector<edm4hep::SimTrackerHit> >::iterator iter = id_hits_map.begin(); iter != id_hits_map.end(); iter++)
+  for(auto iter = id_hits_map.begin(); iter != id_hits_map.end(); iter++)
   {
     unsigned long long wcellid = iter->first;
     auto trkHit = Vec->create();
diff --git a/Digitisers/G2CDArbor/CMakeLists.txt b/Digitisers/G2CDArbor/CMakeLists.txt
index cc6bf3892ef7ebbff268e2f9560acc8609699fbe..85949dbbe28e38d8c68c1868f327ebe30f260579 100644
--- a/Digitisers/G2CDArbor/CMakeLists.txt
+++ b/Digitisers/G2CDArbor/CMakeLists.txt
@@ -11,7 +11,13 @@ gaudi_add_module(G2CDArbor
                       ${GSL_LIBRARIES} 
                       ${LCIO_LIBRARIES}
                       EDM4HEP::edm4hep EDM4HEP::edm4hepDict
+                      DD4hep::DDRec
 )
+
+target_include_directories(G2CDArbor
+  PUBLIC ${LCIO_INCLUDE_DIRS})
+
+
 install(TARGETS G2CDArbor
   EXPORT CEPCSWTargets
   RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
diff --git a/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp b/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp
index a38826b9d85301ed9e5990145e7a21f9b47b9ef8..e90425840a7a7d3f9c1a706d81313cbb557519d1 100644
--- a/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp
+++ b/Digitisers/G2CDArbor/src/G2CDArborAlg.cpp
@@ -508,7 +508,7 @@ StatusCode G2CDArborAlg::execute()
 	       // LayerNum = idDecoder(SimEcalhit)["K-1"];
 
 	       // edm4hep::SimCalorimeterHit aa(SimEcalhit.getCellID(), SimEcalhit.getEnergy(), SimEcalhit.getPosition());
-	       ID_UTIL::CellIDDecoder<edm4hep::SimCalorimeterHit> cellIdDecoder(m_encoder_str);
+               ID_UTIL::CellIDDecoder< decltype(SimEcalhit) > cellIdDecoder(m_encoder_str);
 	       const std::string layerCodingString(m_encoder_str);
 	       const std::string layerCoding(this->GetLayerCoding(layerCodingString));
 	       if(m_readLCIO==false) LayerNum = m_decoder->get(cellid, "layer");//from 0 - 29, 0 is preshower
diff --git a/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp b/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp
index cdbcbfe22f8fb5288b23fe9ff20626087639e58c..5a447a9eb56e4baf2e0d58b6dadf227dfcbb3009 100644
--- a/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp
+++ b/Digitisers/SimHitMerge/src/SimHitMergeAlg.cpp
@@ -61,17 +61,26 @@ StatusCode SimHitMergeAlg::execute()
      for (unsigned int k0 = 0; k0 < m_inputColNames.size(); k0++)
      {
           std::map<unsigned long long, edm4hep::SimCalorimeterHit> id_hit_map;
-          std::map<unsigned long long, std::vector<edm4hep::SimCalorimeterHit> > test_id_hits_map;
           std::map<unsigned long long, std::vector<edm4hep::ConstCaloHitContribution> > id_vconb_map;
 	  edm4hep::SimCalorimeterHitCollection* mergedCol = m_OutputCollections[k0]->createAndPut();
 	  auto col = m_InputCollections[k0]->get();
           //std::cout<<"input="<<m_InputCollections[k0]->objKey()<<",size="<<col->size()<<std::endl;
+
+          if (col->size() == 0) { continue; }
+
+          auto Simhit0 = col->at(0);
+
+          std::map<unsigned long long, std::vector<decltype(Simhit0)> > test_id_hits_map;
+          
 	  for (auto Simhit: *col){
               auto id = Simhit.getCellID();
               if(Simhit.getEnergy() <=0 ) continue; 
               //std::cout<<"DD_sim_hit::ProcessHits, sp x="<<Simhit.getPosition()[0]<<", y="<<Simhit.getPosition()[1]<<", z="<<Simhit.getPosition()[2]<<",edep="<<Simhit.getEnergy()<<std::endl;
               if ( id_hit_map.find(id) != id_hit_map.end()) id_hit_map[id].setEnergy(id_hit_map[id].getEnergy() + Simhit.getEnergy());
-              else id_hit_map[id] = Simhit;
+              else {
+                  edm4hep::SimCalorimeterHit newSimhit(Simhit.getCellID(), Simhit.getEnergy(), Simhit.getPosition());
+                  id_hit_map[id] = newSimhit;
+              }
               std::vector<edm4hep::ConstCaloHitContribution> tmp_vconb ;
               for(int kk=0; kk<Simhit.contributions_size(); kk++){
                   tmp_vconb.push_back(Simhit.getContributions(kk));
@@ -91,7 +100,7 @@ StatusCode SimHitMergeAlg::execute()
           }
 
           if(m_sanity_check){
-              for(std::map<unsigned long long, std::vector<edm4hep::SimCalorimeterHit> >::iterator iter = test_id_hits_map.begin(); iter != test_id_hits_map.end(); iter++){
+              for(auto iter = test_id_hits_map.begin(); iter != test_id_hits_map.end(); iter++){
                   for(unsigned int i=0; i< iter->second.size(); i++){
                      float pos1_x = iter->second.at(i).getPosition()[0];
                      float pos1_y = iter->second.at(i).getPosition()[1];
@@ -110,9 +119,9 @@ StatusCode SimHitMergeAlg::execute()
           }
 
 
-          for(std::map<unsigned long long, edm4hep::SimCalorimeterHit>::iterator iter = id_hit_map.begin(); iter != id_hit_map.end(); iter++)
+          for(auto iter = id_hit_map.begin(); iter != id_hit_map.end(); iter++)
           {
-	       edm4hep::SimCalorimeterHit Simhit = iter->second ;
+	       auto Simhit = iter->second ;
                dd4hep::Position position = m_cellIDConverter->position(Simhit.getCellID());//cm
 	       edm4hep::Vector3f hitPos(position.x()/(dd4hep::mm), position.y()/(dd4hep::mm), position.z()/(dd4hep::mm));//to mm
                //std::cout<<"id="<<Simhit.getCellID()<<",hitPos.x="<<hitPos[0]<<",y="<<hitPos[1]<<",z="<<hitPos[2]<<",ori x="<<Simhit.getPosition()[0]<<",y="<<Simhit.getPosition()[1]<<",z="<<Simhit.getPosition()[2]<<std::endl;
diff --git a/Digitisers/SimpleDigi/src/TPCDigiAlg.cpp b/Digitisers/SimpleDigi/src/TPCDigiAlg.cpp
index ebb1df487d017ec86f5216ec958e222114e5f505..10247c12b2fc3a2c5b9ee3b0cd77a0560fce0cce 100644
--- a/Digitisers/SimpleDigi/src/TPCDigiAlg.cpp
+++ b/Digitisers/SimpleDigi/src/TPCDigiAlg.cpp
@@ -451,7 +451,6 @@ StatusCode TPCDigiAlg::execute()
   _NRevomedHits = 0;
 
   static bool firstEvent = true;
-  _tpcHitMap.clear();
   _tpcRowHits.clear();
 
   // fg: make sure we have one message in the log file with run and event number for the DBD production ....
@@ -527,6 +526,15 @@ StatusCode TPCDigiAlg::execute()
   //  return StatusCode::SUCCESS;
   //}
 
+  if (!STHcol) {
+    return StatusCode::SUCCESS;
+  }
+  // auto SimTHit0 = STHcol->at(0);
+
+  // std::map< Voxel_tpc *, decltype(SimTHit0) > _tpcHitMap;
+  _tpcHitMap.clear();
+
+  
   if( STHcol != nullptr ){
 
     int n_sim_hits = STHcol->size()  ;
@@ -941,13 +949,11 @@ StatusCode TPCDigiAlg::execute()
                 ( (fabs(row_hits[k]->getHep3Vector().deltaPhi(row_hits[j]->getHep3Vector()))) * row_hits[j]->getR()) < _doubleHitResRPhi ) {
 
           // if neighboring in phi then compare z
-          map <Voxel_tpc*,edm4hep::SimTrackerHit> ::iterator it;
 
-          edm4hep::SimTrackerHit Hit1;
-          edm4hep::SimTrackerHit Hit2;
+          decltype(_tpcHitMap)::mapped_type Hit1, Hit2;
 
           // search of the simhit pointers in the tpchit map
-          it=_tpcHitMap.find(row_hits[j]);
+          auto it = _tpcHitMap.find(row_hits[j]);;
           if(it!= _tpcHitMap.end()) {
             Hit1 = it->second ; // hit found
           }
diff --git a/Digitisers/SimpleDigi/src/TPCDigiAlg.h b/Digitisers/SimpleDigi/src/TPCDigiAlg.h
index af0f6391f7ee9f5c4e2386221e8aa6f8dbde7151..1eb97e9c508228eb3cf0ff9fc23e057c277840c1 100644
--- a/Digitisers/SimpleDigi/src/TPCDigiAlg.h
+++ b/Digitisers/SimpleDigi/src/TPCDigiAlg.h
@@ -29,6 +29,8 @@ Steve Aplin 26 June 2009 (DESY)
 
 #include <gsl/gsl_rng.h>
 
+#include <type_traits>
+
 //#ifdef MARLIN_USE_AIDA
 
 //#include <marlin/AIDAProcessor.h>
@@ -210,7 +212,8 @@ protected:
   int _nRechits;
 
   std::vector< std::vector <Voxel_tpc *> > _tpcRowHits;
-  std::map< Voxel_tpc *,edm4hep::SimTrackerHit > _tpcHitMap;
+  // std::map< Voxel_tpc *,edm4hep::SimTrackerHit > _tpcHitMap;
+  std::map< Voxel_tpc *, edm4hep::ConstSimTrackerHit > _tpcHitMap;
 
   UTIL::BitField64* _cellid_encoder;
 
diff --git a/Generator/CMakeLists.txt b/Generator/CMakeLists.txt
index 0a244a3aa61afe39e9c8fa48ab7344a5866db4de..bf233d1b4b6ed3eed11735130ddd24ab09db84bf 100644
--- a/Generator/CMakeLists.txt
+++ b/Generator/CMakeLists.txt
@@ -27,6 +27,11 @@ gaudi_add_module(GenAlgo
                       ROOT::EG
 )
 
+target_include_directories(GenAlgo
+  PUBLIC ${LCIO_INCLUDE_DIRS}
+  PUBLIC ${HEPMC_INCLUDE_DIRS}
+)
+
 install(TARGETS GenAlgo
   EXPORT CEPCSWTargets
   RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
diff --git a/Reconstruction/Digi_Calo/src/CaloDigiAlg.cpp b/Reconstruction/Digi_Calo/src/CaloDigiAlg.cpp
index acc8533f91d4ead80ec4d74bea12d01e806cd50e..af65187c95ed83656ce9afaf6e92e96ddee7964e 100644
--- a/Reconstruction/Digi_Calo/src/CaloDigiAlg.cpp
+++ b/Reconstruction/Digi_Calo/src/CaloDigiAlg.cpp
@@ -46,7 +46,6 @@ StatusCode CaloDigiAlg::initialize()
 StatusCode CaloDigiAlg::execute()
 {
   std::map<unsigned long long, edm4hep::SimCalorimeterHit> id_hit_map;
-  std::map<unsigned long long, std::vector<edm4hep::SimCalorimeterHit> > id_hits_map;
   edm4hep::CalorimeterHitCollection* caloVec   = w_DigiCaloCol.createAndPut();
   edm4hep::MCRecoCaloAssociationCollection* caloAssoVec   = w_CaloAssociationCol.createAndPut();
   const edm4hep::SimCalorimeterHitCollection* SimHitCol =  r_SimCaloCol.get();
@@ -56,25 +55,32 @@ StatusCode CaloDigiAlg::execute()
      std::cout<<"not found SimCalorimeterHitCollection"<< std::endl;
      return StatusCode::SUCCESS;
   }
+
+  auto SimHit0 = SimHitCol->at(0);
+  std::map<unsigned long long, std::vector<decltype(SimHit0)> > id_hits_map;
+
   std::cout<<"digi, input sim hit size="<< SimHitCol->size() <<std::endl;
   for( int i = 0; i < SimHitCol->size(); i++ ) 
   {
-      edm4hep::SimCalorimeterHit SimHit = SimHitCol->at(i);
+      auto SimHit = SimHitCol->at(i);
       unsigned long long id = SimHit.getCellID();
       float en = SimHit.getEnergy();
       tot_e += en;
       if ( id_hit_map.find(id) != id_hit_map.end()) id_hit_map[id].setEnergy(id_hit_map[id].getEnergy() + en);
-      else id_hit_map[id] = SimHit ;
+      else {
+        edm4hep::SimCalorimeterHit newSimHit(SimHit.getCellID(), SimHit.getEnergy(), SimHit.getPosition());
+        id_hit_map[id] = newSimHit ;
+      }
 
       if ( id_hits_map.find(id) != id_hits_map.end()) id_hits_map[id].push_back(SimHit);
       else 
       {
-          std::vector<edm4hep::SimCalorimeterHit> vhit;
+          std::vector<decltype(SimHit)> vhit;
           vhit.push_back(SimHit);
           id_hits_map[id] = vhit ;
       }
   }
-  for(std::map<unsigned long long, edm4hep::SimCalorimeterHit>::iterator iter = id_hit_map.begin(); iter != id_hit_map.end(); iter++)
+  for(auto iter = id_hit_map.begin(); iter != id_hit_map.end(); iter++)
   {
     auto caloHit = caloVec->create();
     caloHit.setCellID((iter->second).getCellID());
diff --git a/Reconstruction/PFA/Arbor/CMakeLists.txt b/Reconstruction/PFA/Arbor/CMakeLists.txt
index eb4468bd61180dea7e8e9dba8d3c0bf9e41ace6c..6508c401d98b504e4f462baaaff87302ef95619d 100644
--- a/Reconstruction/PFA/Arbor/CMakeLists.txt
+++ b/Reconstruction/PFA/Arbor/CMakeLists.txt
@@ -25,6 +25,9 @@ gaudi_add_module(Arbor
                       EDM4HEP::edm4hep EDM4HEP::edm4hepDict
 )
 
+target_include_directories(Arbor
+  PUBLIC ${LCIO_INCLUDE_DIRS}
+)
 
 install(TARGETS Arbor
   EXPORT CEPCSWTargets
diff --git a/Reconstruction/PFA/Arbor/src/BushConnect.hh b/Reconstruction/PFA/Arbor/src/BushConnect.hh
index e0f23ba8ca625d4ef32d9ad62ca3c78b3e260e05..80403feb8bff907a7697dd577e11a9540288707e 100644
--- a/Reconstruction/PFA/Arbor/src/BushConnect.hh
+++ b/Reconstruction/PFA/Arbor/src/BushConnect.hh
@@ -60,7 +60,7 @@ class BushConnect  : public GaudiAlgorithm
 		std::map<edm4hep::ConstTrack, float> Track_Phi;	
 
 		std::map<edm4hep::ConstCluster, int> ClusterType_1stID;
-		std::map<edm4hep::ReconstructedParticle, int> ChCoreID; 
+		std::map<edm4hep::ConstReconstructedParticle, int> ChCoreID; 
 
 		std::vector<edm4hep::ConstCluster> ecalchcore_tight;         //TightCores
 		std::vector<edm4hep::ConstCluster> ecalchcore_medium;
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
index 80307e39ad0df371f0a6fd107cf04155a8571136..01a0267f1890ca67df4831a5067719b65e73d88c 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
@@ -26,7 +26,12 @@ gaudi_add_module(GaudiPandora
 
 target_include_directories(GaudiPandora PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>/include
-  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+  ${GEAR_INCLUDE_DIRS}
+  ${PandoraSDK_INCLUDE_DIRS}
+  ${LCContent_INCLUDE_DIRS}
+  ${LCIO_INCLUDE_DIRS}
+)
 
 install(TARGETS GaudiPandora
   EXPORT CEPCSWTargets
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/CaloHitCreator.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/CaloHitCreator.h
index df9793abc42eca3ebf7c83ae6a968077ec65ee3a..7be4f3eda09de92d827794c49f94d740a838b41d 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/include/CaloHitCreator.h
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/CaloHitCreator.h
@@ -25,7 +25,7 @@
 
 #include <string>
 
-typedef std::vector<edm4hep::CalorimeterHit *> CalorimeterHitVector;
+typedef std::vector<edm4hep::ConstCalorimeterHit *> CalorimeterHitVector;
 
 namespace gear { class GearMgr; }
 
@@ -174,25 +174,25 @@ private:
      *  @brief  Get common calo hit properties: position, parent address, input energy and time
      * 
      */
-    void GetCommonCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const;
+    void GetCommonCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const;
 
     /**
      *  @brief  Get end cap specific calo hit properties: cell size, absorber radiation and interaction lengths, normal vector
      * 
      */
-    void GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+    void GetEndCapCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
         PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const;
-    void GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
+    void GetEndCapCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
     PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const;
 
     /**
      *  @brief  Get barrel specific calo hit properties: cell size, absorber radiation and interaction lengths, normal vector
      * 
      */
-    void GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+    void GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
         unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
         float &absorberCorrection) const;
-    void GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
+    void GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
         unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
         float &absorberCorrection) const;
 
@@ -200,13 +200,13 @@ private:
      *  @brief  Get number of active layers from position of a calo hit to the edge of the detector
      * 
      */
-    int GetNLayersFromEdge(const edm4hep::CalorimeterHit *const pCaloHit) const;
+    int GetNLayersFromEdge(edm4hep::ConstCalorimeterHit *const pCaloHit) const;
 
     /**
      *  @brief  Get the maximum radius of a calo hit in a polygonal detector structure
      * 
      */
-    float GetMaximumRadius(const edm4hep::CalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const;
+    float GetMaximumRadius(edm4hep::ConstCalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const;
 
     /**
      *  @brief  Get the layer coding string from the provided cell id encoding string
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/MCParticleCreator.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/MCParticleCreator.h
index 4e446cf9c59ed15ea3f28034f99adedd8f407917..90281ef238e4b9eaad4b94814e2e29f5e66d9deb 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/include/MCParticleCreator.h
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/MCParticleCreator.h
@@ -78,7 +78,7 @@ private:
     const Settings          m_settings;                         ///< The mc particle creator settings
     const pandora::Pandora *m_pPandora;                         ///< Address of the pandora object to create the mc particles
     const float             m_bField;                           ///< The bfield
-    std::map<unsigned int, const edm4hep::MCParticle*>*  m_id_pMC_map;
+    std::map<unsigned int, edm4hep::ConstMCParticle*>*  m_id_pMC_map;
 };
 
 inline void MCParticleCreator::Reset()
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h
index 6a7a1bacfe9a26b462c645215dcc63370707d35a..7f6b57d2aa0ff26dae5b450d5da1a976f264c217 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/PandoraPFAlg.h
@@ -54,12 +54,12 @@ class CollectionMaps
 public:
     CollectionMaps();
     void clear();
-    std::map<std::string, std::vector<edm4hep::MCParticle> >     collectionMap_MC;
-    std::map<std::string, std::vector<edm4hep::CalorimeterHit> > collectionMap_CaloHit;
-    std::map<std::string, std::vector<edm4hep::Vertex> >         collectionMap_Vertex;
-    std::map<std::string, std::vector<edm4hep::Track> >          collectionMap_Track;
-    std::map<std::string, std::vector<edm4hep::MCRecoCaloAssociation> > collectionMap_CaloRel;
-    std::map<std::string, std::vector<edm4hep::MCRecoTrackerAssociation> > collectionMap_TrkRel;
+    std::map<std::string, std::vector<edm4hep::ConstMCParticle> >     collectionMap_MC;
+    std::map<std::string, std::vector<edm4hep::ConstCalorimeterHit> > collectionMap_CaloHit;
+    std::map<std::string, std::vector<edm4hep::ConstVertex> >         collectionMap_Vertex;
+    std::map<std::string, std::vector<edm4hep::ConstTrack> >          collectionMap_Track;
+    std::map<std::string, std::vector<edm4hep::ConstMCRecoCaloAssociation> > collectionMap_CaloRel;
+    std::map<std::string, std::vector<edm4hep::ConstMCRecoTrackerAssociation> > collectionMap_TrkRel;
 };
 
 
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/include/TrackCreator.h b/Reconstruction/PFA/Pandora/GaudiPandora/include/TrackCreator.h
index ad8f903451f4cea1a2a9b2a1879a615fd01d4139..1094a3dd7803c140a008ba109855e2f2d4a3db37 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/include/TrackCreator.h
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/include/TrackCreator.h
@@ -24,7 +24,7 @@ namespace gear { class GearMgr; }
 
 class CollectionMaps;
 
-typedef std::vector<const edm4hep::Track *> TrackVector;
+typedef std::vector<edm4hep::ConstTrack *> TrackVector;
 typedef std::set<unsigned int> TrackList;
 typedef std::map<edm4hep::ConstTrack, int> TrackToPidMap;
 /*
@@ -125,7 +125,7 @@ public:
      */
     pandora::StatusCode CreateTrackAssociations(const CollectionMaps& collectionMaps);
 
-    const edm4hep::Track* GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack );
+    edm4hep::ConstTrack* GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack );
     /**
      *  @brief  Create tracks, insert user code here
      * 
@@ -198,7 +198,7 @@ private:
      *  @brief  Copy track states stored in tracks to pandora track parameters
      * 
      */
-    void GetTrackStates(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
+    void GetTrackStates(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Copy track state from track state instance to pandora input track state
@@ -210,13 +210,13 @@ private:
      *  @brief  Obtain track time when it reaches ECAL
      * 
      */
-    float CalculateTrackTimeAtCalorimeter(const edm4hep::Track *const pTrack) const;
+    float CalculateTrackTimeAtCalorimeter(edm4hep::ConstTrack *const pTrack) const;
 
     /**
      *  @brief  Decide whether track reaches the ecal surface
      * 
      */
-    void TrackReachesECAL(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
+    void TrackReachesECAL(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Determine whether a track can be used to form a pfo under the following conditions:
@@ -224,7 +224,7 @@ private:
      *          2) if the track proves to have no cluster associations
      * 
      */
-    void DefineTrackPfoUsage(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
+    void DefineTrackPfoUsage(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Whether track passes the quality cuts required in order to be used to form a pfo
@@ -232,19 +232,19 @@ private:
      * 
      *  @return boolean
      */
-    bool PassesQualityCuts(const edm4hep::Track *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const;
+    bool PassesQualityCuts(edm4hep::ConstTrack *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Get number of hits in TPC of a track
      * 
      */
-    int GetNTpcHits(const edm4hep::Track *const pTrack) const;
+    int GetNTpcHits(edm4hep::ConstTrack *const pTrack) const;
 
     /**
      *  @brief  Get number of hits in FTD of a track
      * 
      */
-    int GetNFtdHits(const edm4hep::Track *const pTrack) const;
+    int GetNFtdHits(edm4hep::ConstTrack *const pTrack) const;
 
     const Settings          m_settings;                     ///< The track creator settings
     const pandora::Pandora *m_pPandora;                     ///< Address of the pandora object to create tracks and track relationships
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp
index e3bd6e3c3e9812a2fe75637c9ca3a0782c7b3933..ae958c84b875b7d50ed759182a22c6145e0b06ce 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp
@@ -240,14 +240,15 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
         try
         {
             if(m_settings.m_debug) std::cout<<"CaloHitCreator for "<<tmp_col_name<<std::endl;
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second;
             const int nElements(pCaloHitCollection.size());
 
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str);
             const std::string layerCodingString(m_encoder_str);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
             const std::string staveCoding(this->GetStaveCoding(layerCodingString));
@@ -275,8 +276,8 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("CreateECalCaloHits pCaloHit Collection type mismatch");
@@ -363,7 +364,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
                     }
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -394,14 +395,15 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(tmp_col_name) == collectionMaps.collectionMap_CaloHit.end()) { if(m_settings.m_debug) std::cout<<"not find "<<tmp_col_name<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second;
             const int nElements(pCaloHitCollection.size());
 
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str);
             const std::string layerCodingString(m_encoder_str);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
             const std::string staveCoding(this->GetStaveCoding(layerCodingString));
@@ -429,8 +431,8 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("CreateHCalCaloHits Collection type mismatch");
@@ -487,7 +489,7 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col
                     caloHitParameters.m_electromagneticEnergy = m_settings.m_hCalToEMGeV * pCaloHit->getEnergy();
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -518,14 +520,15 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(tmp_col_name) == collectionMaps.collectionMap_CaloHit.end()) {if(m_settings.m_debug) std::cout<<"not find "<<tmp_col_name<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(tmp_col_name))->second;
             const int nElements(pCaloHitCollection.size());
 
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_MUON);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str_MUON);
             const std::string layerCodingString(m_encoder_str_MUON);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
             const std::string staveCoding(this->GetStaveCoding(layerCodingString));
@@ -555,8 +558,8 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("Muon Collection type mismatch");
@@ -627,7 +630,7 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col
                     }
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -658,15 +661,17 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) {if(m_settings.m_debug)std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
+
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getLcalParameters().getLayerLayout()); 
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_LCal);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str_LCal);
             const std::string layerCodingString(m_encoder_str_LCal);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
 
@@ -674,8 +679,8 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("LCal Collection type mismatch");
@@ -700,7 +705,7 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col
                     caloHitParameters.m_hadronicEnergy = m_settings.m_eCalToHadGeVEndCap * pCaloHit->getEnergy();
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -731,15 +736,16 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) {if(m_settings.m_debug) std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             if (0 == nElements)
                 continue;
 
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getLHcalParameters().getLayerLayout());
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_LHCal);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str_LHCal);
             const std::string layerCodingString(m_encoder_str_LHCal);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
 
@@ -747,8 +753,8 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("LHCal Collection type mismatch");
@@ -773,7 +779,7 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
                     caloHitParameters.m_electromagneticEnergy = m_settings.m_hCalToEMGeV * pCaloHit->getEnergy();
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -796,7 +802,7 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void CaloHitCreator::GetCommonCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const
+void CaloHitCreator::GetCommonCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const
 {
     const float pCaloHitPosition[3]={pCaloHit->getPosition()[0], pCaloHit->getPosition()[1], pCaloHit->getPosition()[2]};
     const pandora::CartesianVector positionVector(pCaloHitPosition[0], pCaloHitPosition[1], pCaloHitPosition[2]);
@@ -811,7 +817,7 @@ void CaloHitCreator::GetCommonCaloHitProperties(const edm4hep::CalorimeterHit *c
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void CaloHitCreator::GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+void CaloHitCreator::GetEndCapCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
     PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const
 {
     caloHitParameters.m_hitRegion = pandora::ENDCAP;
@@ -856,7 +862,7 @@ void CaloHitCreator::GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *c
 }
 
 //------------------------------------------------------------------------------------------------------------------------------------------
-void CaloHitCreator::GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
+void CaloHitCreator::GetEndCapCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
     PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const
 {
     caloHitParameters.m_hitRegion = pandora::ENDCAP;
@@ -908,7 +914,7 @@ void CaloHitCreator::GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *c
 }
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+void CaloHitCreator::GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
     unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
     float &absorberCorrection) const
 {
@@ -971,7 +977,7 @@ void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *c
     }
 }
 
-void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
+void CaloHitCreator::GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterStruct::Layer> &layers,
     unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
     float &absorberCorrection) const
 {
@@ -1048,7 +1054,7 @@ void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *c
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-int CaloHitCreator::GetNLayersFromEdge(const edm4hep::CalorimeterHit *const pCaloHit) const
+int CaloHitCreator::GetNLayersFromEdge(edm4hep::ConstCalorimeterHit *const pCaloHit) const
 {
     // Calo hit coordinate calculations
     const float barrelMaximumRadius(this->GetMaximumRadius(pCaloHit, m_hCalBarrelOuterSymmetry, m_hCalBarrelOuterPhi0));
@@ -1090,7 +1096,7 @@ int CaloHitCreator::GetNLayersFromEdge(const edm4hep::CalorimeterHit *const pCal
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-float CaloHitCreator::GetMaximumRadius(const edm4hep::CalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const
+float CaloHitCreator::GetMaximumRadius(edm4hep::ConstCalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const
 {
     
     const float pCaloHitPosition[3]={pCaloHit->getPosition()[0], pCaloHit->getPosition()[1], pCaloHit->getPosition()[2]};
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp
index a9042a82183231212b3362656c9d38ab8ef6bbf0..ce8b42d8519f51ec472103c402c41a0088b0e776 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp
@@ -26,7 +26,7 @@ MCParticleCreator::MCParticleCreator(const Settings &settings, const pandora::Pa
     m_pPandora(pPandora),
     m_bField(settings.m_bField)
 {
-m_id_pMC_map = new std::map<unsigned int, const edm4hep::MCParticle*>;
+m_id_pMC_map = new std::map<unsigned int, edm4hep::ConstMCParticle*>;
 }
 
 //------------------------------------------------------------------------------------------------------------------------------------------
@@ -45,20 +45,20 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c
         if(collectionMaps.collectionMap_MC.find(*iter) == collectionMaps.collectionMap_MC.end()) continue;
         try
         {
-            const std::vector<edm4hep::MCParticle>& pMCParticleCollection = (collectionMaps.collectionMap_MC.find(*iter))->second;
+            auto pMCParticleCollection = (collectionMaps.collectionMap_MC.find(*iter))->second;
             std::cout<<"Do CreateMCParticles, collection:"<<(*iter)<<", size="<<pMCParticleCollection.size()<<std::endl;
             for (int im = 0; im < pMCParticleCollection.size(); im++)
             {
                 try
                 {
-                    const edm4hep::MCParticle& pMcParticle = pMCParticleCollection.at(im);
+                    auto pMcParticle = pMCParticleCollection.at(im);
                     PandoraApi::MCParticle::Parameters mcParticleParameters;
                     mcParticleParameters.m_energy =   sqrt(pMcParticle.getMomentum()[0] * pMcParticle.getMomentum()[0] + pMcParticle.getMomentum()[1] * pMcParticle.getMomentum()[1] + pMcParticle.getMomentum()[2] * pMcParticle.getMomentum()[2] + pMcParticle.getMass() * pMcParticle.getMass());
                     mcParticleParameters.m_particleId = pMcParticle.getPDG();
                     mcParticleParameters.m_mcParticleType = pandora::MC_3D;
                     mcParticleParameters.m_pParentAddress = &pMcParticle;
                     unsigned int p_id = pMcParticle.id();
-                    const edm4hep::MCParticle* p_mc = &pMcParticle;
+                    auto p_mc = &pMcParticle;
                     (*m_id_pMC_map) [p_id]   = p_mc;
                     mcParticleParameters.m_momentum = pandora::CartesianVector(pMcParticle.getMomentum()[0], pMcParticle.getMomentum()[1],
                         pMcParticle.getMomentum()[2]);
@@ -78,7 +78,7 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c
                            if(pMCParticleCollection.at(ida).id()==(*itDaughter).id())
                            {
                               
-                                const edm4hep::MCParticle& dMcParticle = pMCParticleCollection.at(ida);
+                                auto dMcParticle = pMCParticleCollection.at(ida);
                                 if(&pMcParticle == &dMcParticle){std::cout<< "error, mother and daughter are the same mc particle, don't save SetMCParentDaughterRelationship"<<std::endl;}
                                 else PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::SetMCParentDaughterRelationship(*m_pPandora, &pMcParticle, &dMcParticle));
                                 break;
@@ -108,7 +108,7 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c
 
 pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(const CollectionMaps& collectionMaps, const CalorimeterHitVector &calorimeterHitVector) const
 {
-    typedef std::map<const edm4hep::MCParticle *, float> MCParticleToEnergyWeightMap;
+    typedef std::map<edm4hep::ConstMCParticle *, float> MCParticleToEnergyWeightMap;
     MCParticleToEnergyWeightMap mcParticleToEnergyWeightMap;
 
     for (StringVector::const_iterator iter = m_settings.m_CaloHitRelationCollections.begin(), iterEnd = m_settings.m_CaloHitRelationCollections.end();
@@ -117,7 +117,7 @@ pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(co
         if(collectionMaps.collectionMap_CaloRel.find(*iter) == collectionMaps.collectionMap_CaloRel.end()) continue;
         try
         {
-            const std::vector<edm4hep::MCRecoCaloAssociation>& pMCRecoCaloAssociationCollection = (collectionMaps.collectionMap_CaloRel.find(*iter))->second;
+            auto pMCRecoCaloAssociationCollection = (collectionMaps.collectionMap_CaloRel.find(*iter))->second;
 
             for (unsigned i_calo=0; i_calo < calorimeterHitVector.size(); i_calo++)
             {
@@ -128,14 +128,14 @@ pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(co
                     {
                         if( pMCRecoCaloAssociationCollection.at(ic).getRec().id() != (*(calorimeterHitVector.at(i_calo))).id() ) continue;
                         
-                        const edm4hep::ConstSimCalorimeterHit pSimHit = pMCRecoCaloAssociationCollection.at(ic).getSim();
+                        auto pSimHit = pMCRecoCaloAssociationCollection.at(ic).getSim();
                         for (int iCont = 0, iEnd = pSimHit.contributions_size(); iCont < iEnd; ++iCont)
                         {
-                            edm4hep::ConstCaloHitContribution conb = pSimHit.getContributions(iCont);
-                            const edm4hep::ConstMCParticle ipa = conb.getParticle();
+                            auto conb = pSimHit.getContributions(iCont);
+                            auto ipa = conb.getParticle();
                             float  ien = conb.getEnergy();
                             if( m_id_pMC_map->find(ipa.id()) == m_id_pMC_map->end() ) continue;
-                            const edm4hep::MCParticle * p_tmp = (*m_id_pMC_map)[ipa.id()]; 
+                            auto p_tmp = (*m_id_pMC_map)[ipa.id()]; 
                             mcParticleToEnergyWeightMap[p_tmp] += ien;
                         }
                         
@@ -172,32 +172,32 @@ pandora::StatusCode MCParticleCreator::CreateTrackToMCParticleRelationships(cons
 {
     for (unsigned ik = 0; ik < trackVector.size(); ik++)
     {
-        const edm4hep::Track *pTrack = trackVector.at(ik);
+        auto pTrack = trackVector.at(ik);
         // Get reconstructed momentum at dca
         const pandora::Helix helixFit(pTrack->getTrackStates(0).phi, pTrack->getTrackStates(0).D0, pTrack->getTrackStates(0).Z0, pTrack->getTrackStates(0).omega, pTrack->getTrackStates(0).tanLambda, m_bField);
         const float recoMomentum(helixFit.GetMomentum().GetMagnitude());
         // Use momentum magnitude to identify best mc particle
-        edm4hep::MCParticle *pBestMCParticle = NULL;
+        edm4hep::ConstMCParticle *pBestMCParticle = NULL;
         float bestDeltaMomentum(std::numeric_limits<float>::max());
         try
         {
             for (StringVector::const_iterator iter = m_settings.m_TrackRelationCollections.begin(), iterEnd = m_settings.m_TrackRelationCollections.end(); iter != iterEnd; ++iter)
             {
                 if(collectionMaps.collectionMap_TrkRel.find(*iter) == collectionMaps.collectionMap_TrkRel.end()) continue;
-                const std::vector<edm4hep::MCRecoTrackerAssociation>& pMCRecoTrackerAssociationCollection = (collectionMaps.collectionMap_TrkRel.find(*iter))->second;
+                auto pMCRecoTrackerAssociationCollection = (collectionMaps.collectionMap_TrkRel.find(*iter))->second;
                 for(unsigned ith=0 ; ith<pTrack->trackerHits_size(); ith++)
                 {
                     for(unsigned ic=0; ic < pMCRecoTrackerAssociationCollection.size(); ic++)
                     {
                         if( pMCRecoTrackerAssociationCollection.at(ic).getRec().id() != pTrack->getTrackerHits(ith).id() ) continue;
-                        const edm4hep::ConstSimTrackerHit pSimHit = pMCRecoTrackerAssociationCollection.at(ic).getSim();
-                        const edm4hep::ConstMCParticle ipa = pSimHit.getMCParticle();
+                        auto pSimHit = pMCRecoTrackerAssociationCollection.at(ic).getSim();
+                        auto ipa = pSimHit.getMCParticle();
                         if( m_id_pMC_map->find(ipa.id()) == m_id_pMC_map->end() ) continue;
                         const float trueMomentum(pandora::CartesianVector(ipa.getMomentum()[0], ipa.getMomentum()[1], ipa.getMomentum()[2]).GetMagnitude());
                         const float deltaMomentum(std::fabs(recoMomentum - trueMomentum));
                         if (deltaMomentum < bestDeltaMomentum)
                         {
-                            pBestMCParticle =const_cast<edm4hep::MCParticle*>((*m_id_pMC_map)[ipa.id()]);
+                            pBestMCParticle =((*m_id_pMC_map)[ipa.id()]);
                             bestDeltaMomentum = deltaMomentum;
                         }
                     }
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp
index 18030dbdb33cf0a5f62876fe64e237e550753855..0e16f4e61e09dc01e9913d8349585045f99a3ec7 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/PandoraPFAlg.cpp
@@ -479,8 +479,8 @@ StatusCode PandoraPFAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::MCParticleCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::MCParticle> v_mc;
-                    m_CollectionMaps->collectionMap_MC [v.first] = v_mc;
+                    // std::vector<edm4hep::MCParticle> v_mc;
+                    // m_CollectionMaps->collectionMap_MC [v.first] = v_mc;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_MC [v.first].push_back(po->at(i));
                     debug()<<"saved col name="<<v.first<<endmsg;
                 }
@@ -493,8 +493,8 @@ StatusCode PandoraPFAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::CalorimeterHitCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::CalorimeterHit> v_cal;
-                    m_CollectionMaps->collectionMap_CaloHit[v.first] = v_cal ;
+                    // std::vector<edm4hep::CalorimeterHit> v_cal;
+                    // m_CollectionMaps->collectionMap_CaloHit[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloHit [v.first].push_back(po->at(i));
                     debug()<<"saved col name="<<v.first<<endmsg;
                 }
@@ -507,8 +507,8 @@ StatusCode PandoraPFAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::TrackCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::Track> v_cal;
-                    m_CollectionMaps->collectionMap_Track[v.first] = v_cal ;
+                    // std::vector<edm4hep::Track> v_cal;
+                    // m_CollectionMaps->collectionMap_Track[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Track [v.first].push_back(po->at(i));
                     debug() <<"saved col name="<<v.first<<endmsg;
                     m_marlinTrack = po->size();
@@ -522,8 +522,8 @@ StatusCode PandoraPFAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::VertexCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::Vertex> v_cal;
-                    m_CollectionMaps->collectionMap_Vertex[v.first] = v_cal ;
+                    // std::vector<edm4hep::Vertex> v_cal;
+                    // m_CollectionMaps->collectionMap_Vertex[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Vertex [v.first].push_back(po->at(i));
                     debug() <<"saved col name="<<v.first<<endmsg;
                 }
@@ -536,8 +536,8 @@ StatusCode PandoraPFAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::MCRecoCaloAssociationCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::MCRecoCaloAssociation> v_cal;
-                    m_CollectionMaps->collectionMap_CaloRel[v.first] = v_cal ;
+                    // std::vector<edm4hep::MCRecoCaloAssociation> v_cal;
+                    // m_CollectionMaps->collectionMap_CaloRel[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloRel [v.first].push_back(po->at(i));
                     debug() <<"saved col name="<<v.first<<endmsg;
                 }
@@ -550,8 +550,8 @@ StatusCode PandoraPFAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::MCRecoTrackerAssociationCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::MCRecoTrackerAssociation> v_cal;
-                    m_CollectionMaps->collectionMap_TrkRel[v.first] = v_cal ;
+                    // std::vector<edm4hep::MCRecoTrackerAssociation> v_cal;
+                    // m_CollectionMaps->collectionMap_TrkRel[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_TrkRel [v.first].push_back(po->at(i));
                     debug() <<"saved col name="<<v.first<<endmsg;
                 }
@@ -584,7 +584,7 @@ StatusCode PandoraPFAlg::Ana()
     for(int i=0; i<reco_col->size();i++)
     {
         if( m_n_rec >= m_max_rec) break;
-        const edm4hep::ReconstructedParticle pReco = reco_col->at(i);
+        auto pReco = reco_col->at(i);
         const float px = pReco.getMomentum()[0];
         const float py = pReco.getMomentum()[1];
         const float pz = pReco.getMomentum()[2];
@@ -656,19 +656,19 @@ StatusCode PandoraPFAlg::CreateMCRecoParticleAssociation()
         std::map<int, edm4hep::ConstMCParticle> mc_map;
         std::map<int, float > id_edep_map;
         float tot_en = 0 ;
-        const edm4hep::ReconstructedParticle pReco = reco_col->at(i);
+        auto pReco = reco_col->at(i);
         for(int j=0; j < pReco.clusters_size(); j++)
         {
             edm4hep::ConstCluster cluster = pReco.getClusters(j);
             for(int k=0; k < cluster.hits_size(); k++)
             {
                 edm4hep::ConstCalorimeterHit hit = cluster.getHits(k);
-                for(std::map<std::string, std::vector<edm4hep::MCRecoCaloAssociation> >::iterator iter = m_CollectionMaps->collectionMap_CaloRel.begin(); iter != m_CollectionMaps->collectionMap_CaloRel.end(); iter++)
+                for(auto iter = m_CollectionMaps->collectionMap_CaloRel.begin(); iter != m_CollectionMaps->collectionMap_CaloRel.end(); iter++)
                 {
-                    for(std::vector<edm4hep::MCRecoCaloAssociation>::iterator it = iter->second.begin(); it != iter->second.end(); it ++)
+                    for(auto it = iter->second.begin(); it != iter->second.end(); it ++)
                     {
                         if(it->getRec().id() != hit.id()) continue;
-                        for(std::vector<edm4hep::ConstCaloHitContribution>::const_iterator itc = it->getSim().contributions_begin(); itc != it->getSim().contributions_end(); itc++)
+                        for(auto itc = it->getSim().contributions_begin(); itc != it->getSim().contributions_end(); itc++)
                         {
                             if(mc_map.find(itc->getParticle().id()) == mc_map.end()) mc_map[itc->getParticle().id()] = itc->getParticle() ;
                             if(id_edep_map.find(itc->getParticle().id()) != id_edep_map.end()) id_edep_map[itc->getParticle().id()] = id_edep_map[itc->getParticle().id()] + itc->getEnergy() ;
@@ -679,7 +679,7 @@ StatusCode PandoraPFAlg::CreateMCRecoParticleAssociation()
                 }
             }
         }
-        for(std::map<int, edm4hep::ConstMCParticle>::iterator it = mc_map.begin(); it != mc_map.end(); it ++)
+        for(auto it = mc_map.begin(); it != mc_map.end(); it ++)
         {      
             edm4hep::MCRecoParticleAssociation association = pMCRecoParticleAssociationCollection->create();
             association.setRec(pReco);
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp
index 4b67db277fcb73218e559c6acd1521b7a28a637f..82d60b63a231b85bc5ca2cf29a6b8dc6f1a68b7c 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp
@@ -291,20 +291,20 @@ pandora::StatusCode TrackCreator::ExtractKinks(const CollectionMaps& collectionM
         if(collectionMaps.collectionMap_Vertex.find(*iter) == collectionMaps.collectionMap_Vertex.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Vertex>& pKinkCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
+            auto pKinkCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
 
             for (int i = 0, iMax = pKinkCollection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Vertex  pVertex0 = pKinkCollection.at(i);
-                    const edm4hep::Vertex* pVertex  = &(pVertex0);
+                    auto  pVertex0 = pKinkCollection.at(i);
+                    auto pVertex  = &(pVertex0);
 
                     if (NULL == pVertex) throw ("Collection type mismatch");
 
                     //std::cout<<"pVertex getChi2="<<pVertex->getChi2()<<std::endl;
                     //std::cout<<"pReconstructedParticle en="<<pReconstructedParticle.getEnergy()<<",type="<<pReconstructedParticle.getType()<<std::endl;
-                    const edm4hep::ConstReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle();
+                    auto pReconstructedParticle = pVertex->getAssociatedParticle();
                     if (this->IsConflictingRelationship(pReconstructedParticle))continue;
 
                     const int vertexPdgCode(pReconstructedParticle.getType());
@@ -312,7 +312,7 @@ pandora::StatusCode TrackCreator::ExtractKinks(const CollectionMaps& collectionM
                     // Extract the kink vertex information
                     for (unsigned int iTrack = 0, nTracks = pReconstructedParticle.tracks_size(); iTrack < nTracks; ++iTrack)
                     {
-                        edm4hep::ConstTrack pTrack = pReconstructedParticle.getTracks(iTrack);
+                        auto pTrack = pReconstructedParticle.getTracks(iTrack);
                         (0 == iTrack) ? m_parentTrackList.insert(pTrack.id()) : m_daughterTrackList.insert(pTrack.id());
 
                         int trackPdgCode = pandora::UNKNOWN_PARTICLE_TYPE;
@@ -395,14 +395,14 @@ pandora::StatusCode TrackCreator::ExtractProngsAndSplits(const CollectionMaps& c
         if(collectionMaps.collectionMap_Vertex.find(*iter) == collectionMaps.collectionMap_Vertex.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Vertex>& pProngOrSplitCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
+            auto pProngOrSplitCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
 
             for (int i = 0, iMax = pProngOrSplitCollection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Vertex  pVertex0 = pProngOrSplitCollection.at(i);
-                    const edm4hep::Vertex* pVertex  = &(pVertex0);
+                    auto  pVertex0 = pProngOrSplitCollection.at(i);
+                    auto pVertex  = &(pVertex0);
 
                     if (NULL == pVertex) throw ("Collection type mismatch");
                     const edm4hep::ConstReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle();
@@ -461,14 +461,14 @@ pandora::StatusCode TrackCreator::ExtractV0s(const CollectionMaps& collectionMap
         if(collectionMaps.collectionMap_Vertex.find(*iter) == collectionMaps.collectionMap_Vertex.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Vertex>& pV0Collection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
+            auto pV0Collection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
 
             for (int i = 0, iMax = pV0Collection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Vertex  pVertex0 = pV0Collection.at(i);
-                    const edm4hep::Vertex* pVertex  = &(pVertex0);
+                    auto  pVertex0 = pV0Collection.at(i);
+                    auto  pVertex  = &(pVertex0);
 
                     if (NULL == pVertex) throw ("Collection type mismatch");
 
@@ -547,16 +547,16 @@ bool TrackCreator::IsConflictingRelationship(const edm4hep::ConstReconstructedPa
     return false;
 }
 
-const edm4hep::Track* TrackCreator::GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack )
+edm4hep::ConstTrack* TrackCreator::GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack )
 {
     for (StringVector::const_iterator iter = m_settings.m_trackCollections.begin(), iterEnd = m_settings.m_trackCollections.end(); iter != iterEnd; ++iter)
     {
         if(collectionMaps.collectionMap_Track.find(*iter) == collectionMaps.collectionMap_Track.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
-        const std::vector<edm4hep::Track>& pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
+        auto pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
         for (int i = 0, iMax = pTrackCollection.size(); i < iMax; ++i)
         {
-            const edm4hep::Track& pTrack0 = pTrackCollection.at(i);
-            if (pTrack.id() == pTrack0.id()) return (const edm4hep::Track*) (&pTrack0);
+            auto pTrack0 = pTrackCollection.at(i);
+            if (pTrack.id() == pTrack0.id()) return (&pTrack0);
         }
     }
     return NULL;
@@ -572,20 +572,20 @@ pandora::StatusCode TrackCreator::CreateTracks(const CollectionMaps& collectionM
         if(collectionMaps.collectionMap_Track.find(*iter) == collectionMaps.collectionMap_Track.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Track>& pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
+            auto pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
 
             if(m_settings.m_debug) std::cout<<"TrackSize:"<<pTrackCollection.size()<<std::endl;
             for (int i = 0, iMax = pTrackCollection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Track& pTrack0 = pTrackCollection.at(i);
-                    const edm4hep::Track* pTrack  = (const edm4hep::Track*)(&pTrack0);
+                    auto pTrack0 = pTrackCollection.at(i);
+                    auto pTrack  = (&pTrack0);
 
                     if (NULL == pTrack) throw ("Collection type mismatch");
                     if(m_settings.m_debug){
                         for(int ip=0; ip<pTrack->trackStates_size(); ip++){
-                            edm4hep::TrackState tmp_pTrackState = pTrack->getTrackStates(ip);
+                            auto tmp_pTrackState = pTrack->getTrackStates(ip);
                             const double tmp_pt(m_bField * 2.99792e-4 / std::fabs(tmp_pTrackState.omega));
                             edm4hep::Vector3f pref = tmp_pTrackState.referencePoint;
                             std::cout<<"ip="<<ip<<",pt=" << tmp_pt <<",refx="<<pref[0]<<",refy="<<pref[1]<<",refz="<<pref[2]<<",tanLambda=" << tmp_pTrackState.tanLambda<<",D0="<<tmp_pTrackState.D0<<",Z0="<<tmp_pTrackState.Z0<<",phi="<<tmp_pTrackState.phi<< std::endl;
@@ -665,7 +665,7 @@ pandora::StatusCode TrackCreator::CreateTracks(const CollectionMaps& collectionM
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void TrackCreator::GetTrackStates(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
+void TrackCreator::GetTrackStates(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
 {
     // for DD4HEP, 0 is IP, 1 is AtFirstHit, 2 is AtLastHit, 3 is AtCalo
     edm4hep::TrackState pTrackState = pTrack->getTrackStates(0); 
@@ -691,7 +691,7 @@ void TrackCreator::GetTrackStates(const edm4hep::Track *const pTrack, PandoraApi
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-float TrackCreator::CalculateTrackTimeAtCalorimeter(const edm4hep::Track *const pTrack) const
+float TrackCreator::CalculateTrackTimeAtCalorimeter(edm4hep::ConstTrack *const pTrack) const
 {
     const pandora::Helix helix(pTrack->getTrackStates(0).phi, pTrack->getTrackStates(0).D0, pTrack->getTrackStates(0).Z0, pTrack->getTrackStates(0).omega, pTrack->getTrackStates(0).tanLambda, m_bField);
     const pandora::CartesianVector &referencePoint(helix.GetReferencePoint());
@@ -764,7 +764,7 @@ void TrackCreator::CopyTrackState(const edm4hep::TrackState & pTrackState, pando
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void TrackCreator::TrackReachesECAL(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
+void TrackCreator::TrackReachesECAL(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
 {
     
     // Calculate hit position information
@@ -847,7 +847,7 @@ void TrackCreator::TrackReachesECAL(const edm4hep::Track *const pTrack, PandoraA
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void TrackCreator::DefineTrackPfoUsage(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
+void TrackCreator::DefineTrackPfoUsage(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
 {
     bool canFormPfo(false);
     bool canFormClusterlessPfo(false);
@@ -858,7 +858,7 @@ void TrackCreator::DefineTrackPfoUsage(const edm4hep::Track *const pTrack, Pando
 
         float rInner(std::numeric_limits<float>::max()), zMin(std::numeric_limits<float>::max());
 
-        for (std::vector<edm4hep::ConstTrackerHit>::const_iterator iter = pTrack->trackerHits_begin(), iterEnd = pTrack->trackerHits_end(); iter != iterEnd; ++iter)
+        for (auto iter = pTrack->trackerHits_begin(), iterEnd = pTrack->trackerHits_end(); iter != iterEnd; ++iter)
         {
             const edm4hep::Vector3d pPosition = (*iter).getPosition(); 
             const float x(pPosition[0]), y(pPosition[1]), absoluteZ(std::fabs(pPosition[2]));
@@ -932,7 +932,7 @@ void TrackCreator::DefineTrackPfoUsage(const edm4hep::Track *const pTrack, Pando
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-bool TrackCreator::PassesQualityCuts(const edm4hep::Track *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const
+bool TrackCreator::PassesQualityCuts(edm4hep::ConstTrack *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const
 {
     // First simple sanity checks
     if (trackParameters.m_trackStateAtCalorimeter.Get().GetPosition().GetMagnitude() < m_settings.m_minTrackECalDistanceFromIp)
@@ -1009,7 +1009,7 @@ bool TrackCreator::PassesQualityCuts(const edm4hep::Track *const pTrack, const P
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-int TrackCreator::GetNTpcHits(const edm4hep::Track *const pTrack) const
+int TrackCreator::GetNTpcHits(edm4hep::ConstTrack *const pTrack) const
 {
     // ATTN
     //fg: hit numbers are now given in different order wrt LOI:  
@@ -1028,7 +1028,7 @@ int TrackCreator::GetNTpcHits(const edm4hep::Track *const pTrack) const
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-int TrackCreator::GetNFtdHits(const edm4hep::Track *const pTrack) const
+int TrackCreator::GetNFtdHits(edm4hep::ConstTrack *const pTrack) const
 {
     // ATTN
     //fg: hit numbers are now given in different order wrt LOI:  
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt b/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt
index 84ba59b342928ec9b6819285eb2aad4c8a265788..79186a5a532f1d28a3050109d8efc3b0f2e27e59 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt
@@ -24,7 +24,12 @@ gaudi_add_module(MatrixPandora
 
 target_include_directories(MatrixPandora PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>/include
-  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+  ${GEAR_INCLUDE_DIRS}
+  ${PandoraSDK_INCLUDE_DIRS}
+  ${LCContent_INCLUDE_DIRS}
+  ${LCIO_INCLUDE_DIRS}
+)
 
 install(TARGETS MatrixPandora
   EXPORT CEPCSWTargets
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/include/CaloHitCreator.h b/Reconstruction/PFA/Pandora/MatrixPandora/include/CaloHitCreator.h
index fb601edbaa87f0ba0d547308097692ed54ab1911..cdde80f0b47cd80d43a2ee361991b12c928b5ff0 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/include/CaloHitCreator.h
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/include/CaloHitCreator.h
@@ -25,7 +25,7 @@
 
 #include <string>
 
-typedef std::vector<edm4hep::CalorimeterHit *> CalorimeterHitVector;
+typedef std::vector<edm4hep::ConstCalorimeterHit *> CalorimeterHitVector;
 
 namespace gear { class GearMgr; }
 
@@ -165,7 +165,7 @@ private:
      *  @brief  Get common calo hit properties: position, parent address, input energy and time
      * 
      */
-    void GetCommonCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const;
+    void GetCommonCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const;
 
     /**
      *  @brief  Get end cap specific calo hit properties: cell size, absorber radiation and interaction lengths, normal vector
@@ -175,7 +175,7 @@ private:
      *  @param  caloHitParameters the calo hit parameters to populate
      *  @param  absorberCorrection to receive the absorber thickness correction for the mip equivalent energy
      */
-    void GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+    void GetEndCapCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
         PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const;
 
     /**
@@ -189,11 +189,11 @@ private:
      *  @param  caloHitParameters the calo hit parameters to populate
      *  @param  absorberCorrection to receive the absorber thickness correction for the mip equivalent energy
      */
-    void GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+    void GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
         unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
         float &absorberCorrection) const;
 
-    void GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout,
+    void GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout,
         unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
         float &absorberCorrection) const;
     /**
@@ -201,7 +201,7 @@ private:
      * 
      *  @param  pCaloHit the lcio calorimeter hit
      */
-    int GetNLayersFromEdge(const edm4hep::CalorimeterHit *const pCaloHit) const;
+    int GetNLayersFromEdge(edm4hep::ConstCalorimeterHit *const pCaloHit) const;
 
     /**
      *  @brief  Get the maximum radius of a calo hit in a polygonal detector structure
@@ -212,10 +212,10 @@ private:
      * 
      *  @return the maximum radius
      */
-    float GetMaximumRadius(const edm4hep::CalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const;
+    float GetMaximumRadius(edm4hep::ConstCalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const;
 
-    void GetCoding(const edm4hep::CalorimeterHit* pCaloHit, long& sys, long& x, long& y, long& z) const ;
-    int GetBarrelLayer(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout) const;
+    void GetCoding(edm4hep::ConstCalorimeterHit* pCaloHit, long& sys, long& x, long& y, long& z) const ;
+    int GetBarrelLayer(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout) const;
     /**
      *  @brief  Get the layer coding string from the provided cell id encoding string
      * 
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/include/MCParticleCreator.h b/Reconstruction/PFA/Pandora/MatrixPandora/include/MCParticleCreator.h
index 3c1ea57efa4ebd5d6015830af7feec301deac09f..d7c882f588255efdc3b269de3f020f228d781968 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/include/MCParticleCreator.h
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/include/MCParticleCreator.h
@@ -86,7 +86,7 @@ private:
     const Settings          m_settings;                         ///< The mc particle creator settings
     const pandora::Pandora *m_pPandora;                         ///< Address of the pandora object to create the mc particles
     const float             m_bField;                           ///< The bfield
-    std::map<unsigned int, const edm4hep::MCParticle*>*  m_id_pMC_map;
+    std::map<unsigned int, edm4hep::ConstMCParticle*>*  m_id_pMC_map;
 };
 
 inline void MCParticleCreator::Reset()
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/include/PandoraMatrixAlg.h b/Reconstruction/PFA/Pandora/MatrixPandora/include/PandoraMatrixAlg.h
index 1c1c96315c5bd36fb6b081b8a7f214dafb14618a..7a11b8137e4e6a564a23c92353d8fc0180c631c2 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/include/PandoraMatrixAlg.h
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/include/PandoraMatrixAlg.h
@@ -59,12 +59,12 @@ public:
     CollectionMaps();
     void clear();
 
-    std::map<std::string, std::vector<edm4hep::MCParticle> >     collectionMap_MC;
-    std::map<std::string, std::vector<edm4hep::CalorimeterHit> > collectionMap_CaloHit;
-    std::map<std::string, std::vector<edm4hep::Vertex> >         collectionMap_Vertex;
-    std::map<std::string, std::vector<edm4hep::Track> >          collectionMap_Track;
-    std::map<std::string, std::vector<edm4hep::MCRecoCaloAssociation> > collectionMap_CaloRel;
-    std::map<std::string, std::vector<edm4hep::MCRecoTrackerAssociation> > collectionMap_TrkRel;
+    std::map<std::string, std::vector<edm4hep::ConstMCParticle> >     collectionMap_MC;
+    std::map<std::string, std::vector<edm4hep::ConstCalorimeterHit> > collectionMap_CaloHit;
+    std::map<std::string, std::vector<edm4hep::ConstVertex> >         collectionMap_Vertex;
+    std::map<std::string, std::vector<edm4hep::ConstTrack> >          collectionMap_Track;
+    std::map<std::string, std::vector<edm4hep::ConstMCRecoCaloAssociation> > collectionMap_CaloRel;
+    std::map<std::string, std::vector<edm4hep::ConstMCRecoTrackerAssociation> > collectionMap_TrkRel;
 };
 
 
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/include/TrackCreator.h b/Reconstruction/PFA/Pandora/MatrixPandora/include/TrackCreator.h
index b5daa829d8b6ef94a5d14d7a01c9a93558fde5e3..ffa8b90ab0a99d6e1022f43dddae40ca6de78d0b 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/include/TrackCreator.h
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/include/TrackCreator.h
@@ -25,7 +25,7 @@ namespace gear { class GearMgr; }
 
 class CollectionMaps;
 
-typedef std::vector<const edm4hep::Track *> TrackVector;
+typedef std::vector<edm4hep::ConstTrack *> TrackVector;
 typedef std::set<unsigned int> TrackList;
 typedef std::map<edm4hep::ConstTrack, int> TrackToPidMap;
 /*
@@ -127,7 +127,7 @@ public:
      */
     pandora::StatusCode CreateTrackAssociations(const CollectionMaps& collectionMaps);
 
-    const edm4hep::Track* GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack );
+    edm4hep::ConstTrack* GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack );
     /**
      *  @brief  Create tracks, insert user code here
      * 
@@ -199,7 +199,7 @@ private:
      *  @brief  Copy track states stored in lcio tracks to pandora track parameters
      * 
      */
-    void GetTrackStates(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
+    void GetTrackStates(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Copy track state from lcio track state instance to pandora input track state
@@ -211,13 +211,13 @@ private:
      *  @brief  Obtain track time when it reaches ECAL
      * 
      */
-    float CalculateTrackTimeAtCalorimeter(const edm4hep::Track *const pTrack) const;
+    float CalculateTrackTimeAtCalorimeter(edm4hep::ConstTrack *const pTrack) const;
 
     /**
      *  @brief  Decide whether track reaches the ecal surface
      * 
      */
-    void TrackReachesECAL(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
+    void TrackReachesECAL(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Determine whether a track can be used to form a pfo under the following conditions:
@@ -225,7 +225,7 @@ private:
      *          2) if the track proves to have no cluster associations
      * 
      */
-    void DefineTrackPfoUsage(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
+    void DefineTrackPfoUsage(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Whether track passes the quality cuts required in order to be used to form a pfo
@@ -233,20 +233,20 @@ private:
      * 
      *  @return boolean
      */
-    bool PassesQualityCuts(const edm4hep::Track *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const;
+    bool PassesQualityCuts(edm4hep::ConstTrack *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const;
 
     /**
      *  @brief  Get number of hits in TPC of a track
      * 
      */
-    int GetNTpcHits(const edm4hep::Track *const pTrack) const;
+    int GetNTpcHits(edm4hep::ConstTrack *const pTrack) const;
 
     /**
      *  @brief  Get number of hits in FTD of a track
      * 
      * 
      */
-    int GetNFtdHits(const edm4hep::Track *const pTrack) const;
+    int GetNFtdHits(edm4hep::ConstTrack *const pTrack) const;
 
     const Settings          m_settings;                     ///< The track creator settings
     const pandora::Pandora *m_pPandora;                     ///< Address of the pandora object to create tracks and track relationships
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/MatrixPandora/src/CaloHitCreator.cpp
index 5bda03ba495910bda0c738739736eb25eab68c3c..b8343a145ac5e09f1c1319dba2814f21d9db5a99 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/src/CaloHitCreator.cpp
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/src/CaloHitCreator.cpp
@@ -137,18 +137,20 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             std::cout<<(*iter)<<"has nElements="<<nElements<<std::endl;
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
+            
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getEcalEndcapParameters().getLayerLayout());
             const dd4hep::DetElement &detElement = m_dd4hep->detector("CaloDetector");
             dd4hep::rec::LayeredCalorimeterData* Data = detElement.extension<dd4hep::rec::LayeredCalorimeterData>() ;
             const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer>& barrelLayerLayout = Data->layers;
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str);
             const std::string layerCodingString(m_encoder_str);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
             const std::string staveCoding(this->GetStaveCoding(layerCodingString));
@@ -157,8 +159,8 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("CreateECalCaloHits pCaloHit Collection type mismatch");
@@ -231,7 +233,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col
                     }
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -262,17 +264,19 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             std::cout<<(*iter)<<"has nElements="<<nElements<<std::endl;
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
+
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getHcalEndcapParameters().getLayerLayout());
             const gear::LayerLayout &barrelLayerLayout(_GEAR->getHcalBarrelParameters().getLayerLayout());
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str);
             const std::string layerCodingString(m_encoder_str);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
             const std::string staveCoding(this->GetStaveCoding(layerCodingString));
@@ -281,8 +285,8 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("CreateHCalCaloHits Collection type mismatch");
@@ -315,7 +319,7 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col
                     caloHitParameters.m_electromagneticEnergy = m_settings.m_hCalToEMGeV * pCaloHit->getEnergy();
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -346,18 +350,20 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             std::cout<<(*iter)<<"has nElements="<<nElements<<std::endl;
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
+
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getYokeEndcapParameters().getLayerLayout());
             const gear::LayerLayout &barrelLayerLayout(_GEAR->getYokeBarrelParameters().getLayerLayout()); 
             const gear::LayerLayout &plugLayerLayout(_GEAR->getYokePlugParameters().getLayerLayout());
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_MUON);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str_MUON);
             const std::string layerCodingString(m_encoder_str_MUON);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
             const std::string staveCoding(this->GetStaveCoding(layerCodingString));
@@ -366,8 +372,8 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("Muon Collection type mismatch");
@@ -418,7 +424,7 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col
                     }
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -449,16 +455,18 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             std::cout<<(*iter)<<"has nElements="<<nElements<<std::endl;
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
+
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getLcalParameters().getLayerLayout()); 
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_LCal);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str_LCal);
             const std::string layerCodingString(m_encoder_str_LCal);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
 
@@ -466,8 +474,8 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("LCal Collection type mismatch");
@@ -491,7 +499,7 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col
                     caloHitParameters.m_hadronicEnergy = m_settings.m_eCalToHadGeVEndCap * pCaloHit->getEnergy();
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -522,16 +530,19 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
         if(collectionMaps.collectionMap_CaloHit.find(*iter) == collectionMaps.collectionMap_CaloHit.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::CalorimeterHit>& pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
+            auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second;
             const int nElements(pCaloHitCollection.size());
 
             std::cout<<(*iter)<<"has nElements="<<nElements<<std::endl;
             if (0 == nElements)
                 continue;
 
+            auto tmpCaloHit0 = pCaloHitCollection.at(0);
+
+
             const gear::LayerLayout &endcapLayerLayout(_GEAR->getLHcalParameters().getLayerLayout());
 
-            ID_UTIL::CellIDDecoder<const edm4hep::CalorimeterHit> cellIdDecoder(m_encoder_str_LHCal);
+            ID_UTIL::CellIDDecoder<decltype(tmpCaloHit0)> cellIdDecoder(m_encoder_str_LHCal);
             const std::string layerCodingString(m_encoder_str_LHCal);
             const std::string layerCoding(this->GetLayerCoding(layerCodingString));
 
@@ -539,8 +550,8 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
             {
                 try
                 {
-                    const edm4hep::CalorimeterHit& pCaloHit0 = pCaloHitCollection.at(i);
-                    const edm4hep::CalorimeterHit* pCaloHit = &(pCaloHit0);
+                    auto pCaloHit0 = pCaloHitCollection.at(i);
+                    auto pCaloHit = &(pCaloHit0);
 
                     if (NULL == pCaloHit)
                         throw ("LHCal Collection type mismatch");
@@ -564,7 +575,7 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
                     caloHitParameters.m_electromagneticEnergy = m_settings.m_hCalToEMGeV * pCaloHit->getEnergy();
 
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*m_pPandora, caloHitParameters));
-                    m_calorimeterHitVector.push_back(const_cast<edm4hep::CalorimeterHit*>(pCaloHit));
+                    m_calorimeterHitVector.push_back((pCaloHit));
                 }
                 catch (pandora::StatusCodeException &statusCodeException)
                 {
@@ -587,7 +598,7 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void CaloHitCreator::GetCommonCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const
+void CaloHitCreator::GetCommonCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const
 {
     const float pCaloHitPosition[3]={pCaloHit->getPosition()[0], pCaloHit->getPosition()[1], pCaloHit->getPosition()[2]};
     const pandora::CartesianVector positionVector(pCaloHitPosition[0], pCaloHitPosition[1], pCaloHitPosition[2]);
@@ -602,7 +613,7 @@ void CaloHitCreator::GetCommonCaloHitProperties(const edm4hep::CalorimeterHit *c
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void CaloHitCreator::GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+void CaloHitCreator::GetEndCapCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
     PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const
 {
     caloHitParameters.m_hitRegion = pandora::ENDCAP;
@@ -648,7 +659,7 @@ void CaloHitCreator::GetEndCapCaloHitProperties(const edm4hep::CalorimeterHit *c
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
+void CaloHitCreator::GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const gear::LayerLayout &layerLayout,
     unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
     float &absorberCorrection) const
 {
@@ -713,7 +724,7 @@ void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *c
     }
 }
 
-void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout,
+void CaloHitCreator::GetBarrelCaloHitProperties(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout,
     unsigned int barrelSymmetryOrder, float barrelPhi0, unsigned int staveNumber, PandoraApi::CaloHit::Parameters &caloHitParameters,
     float &absorberCorrection) const
 {
@@ -778,7 +789,7 @@ void CaloHitCreator::GetBarrelCaloHitProperties(const edm4hep::CalorimeterHit *c
     }
 }
 //------------------------------------------------------------------------------------------------------------------------------------------
-int CaloHitCreator::GetBarrelLayer(const edm4hep::CalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout) const
+int CaloHitCreator::GetBarrelLayer(edm4hep::ConstCalorimeterHit *const pCaloHit, const std::vector<dd4hep::rec::LayeredCalorimeterData::Layer> &layerLayout) const
 {
     int layer = -1 ;   
     for (unsigned int i = 0, iMax = layerLayout.size(); i < iMax; ++i)
@@ -796,7 +807,7 @@ int CaloHitCreator::GetBarrelLayer(const edm4hep::CalorimeterHit *const pCaloHit
     return layer;
 }
 
-int CaloHitCreator::GetNLayersFromEdge(const edm4hep::CalorimeterHit *const pCaloHit) const
+int CaloHitCreator::GetNLayersFromEdge(edm4hep::ConstCalorimeterHit *const pCaloHit) const
 {
     // Calo hit coordinate calculations
     const float barrelMaximumRadius(this->GetMaximumRadius(pCaloHit, m_hCalBarrelOuterSymmetry, m_hCalBarrelOuterPhi0));
@@ -838,7 +849,7 @@ int CaloHitCreator::GetNLayersFromEdge(const edm4hep::CalorimeterHit *const pCal
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-float CaloHitCreator::GetMaximumRadius(const edm4hep::CalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const
+float CaloHitCreator::GetMaximumRadius(edm4hep::ConstCalorimeterHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const
 {
     
     const float pCaloHitPosition[3]={pCaloHit->getPosition()[0], pCaloHit->getPosition()[1], pCaloHit->getPosition()[2]};
@@ -860,7 +871,7 @@ float CaloHitCreator::GetMaximumRadius(const edm4hep::CalorimeterHit *const pCal
     return maximumRadius;
 }
 
-void CaloHitCreator::GetCoding(const edm4hep::CalorimeterHit* pCaloHit, long& sys, long& x, long& y, long& z) const
+void CaloHitCreator::GetCoding(edm4hep::ConstCalorimeterHit* pCaloHit, long& sys, long& x, long& y, long& z) const
 {
     //sys = (pCaloHit->getCellID() << (64-8)) >> (64-8) ;
     //x   = (pCaloHit->getCellID() << (64-(8+16))) >> (64-(8+16)) ;
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/src/MCParticleCreator.cpp b/Reconstruction/PFA/Pandora/MatrixPandora/src/MCParticleCreator.cpp
index c05190ebebc7efc39813bcaf22820743406afa1d..06c5aa2cb2dd541c43674d838f9dc5821804a83d 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/src/MCParticleCreator.cpp
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/src/MCParticleCreator.cpp
@@ -30,7 +30,7 @@ MCParticleCreator::MCParticleCreator(const Settings &settings, const pandora::Pa
     m_pPandora(pPandora),
     m_bField(settings.m_bField)
 {
-m_id_pMC_map = new std::map<unsigned int, const edm4hep::MCParticle*>;
+m_id_pMC_map = new std::map<unsigned int, edm4hep::ConstMCParticle*>;
 }
 
 //------------------------------------------------------------------------------------------------------------------------------------------
@@ -49,20 +49,20 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c
         if(collectionMaps.collectionMap_MC.find(*iter) == collectionMaps.collectionMap_MC.end()) continue;
         try
         {
-            const std::vector<edm4hep::MCParticle>& pMCParticleCollection = (collectionMaps.collectionMap_MC.find(*iter))->second;
+            auto pMCParticleCollection = (collectionMaps.collectionMap_MC.find(*iter))->second;
             std::cout<<"Do CreateMCParticles, collection:"<<(*iter)<<", size="<<pMCParticleCollection.size()<<std::endl;
             for (int im = 0; im < pMCParticleCollection.size(); im++)
             {
                 try
                 {
-                    const edm4hep::MCParticle& pMcParticle = pMCParticleCollection.at(im);
+                    auto pMcParticle = pMCParticleCollection.at(im);
                     PandoraApi::MCParticle::Parameters mcParticleParameters;
                     mcParticleParameters.m_energy =   sqrt(pMcParticle.getMomentum()[0] * pMcParticle.getMomentum()[0] + pMcParticle.getMomentum()[1] * pMcParticle.getMomentum()[1] + pMcParticle.getMomentum()[2] * pMcParticle.getMomentum()[2] + pMcParticle.getMass() * pMcParticle.getMass());
                     mcParticleParameters.m_particleId = pMcParticle.getPDG();
                     mcParticleParameters.m_mcParticleType = pandora::MC_3D;
                     mcParticleParameters.m_pParentAddress = &pMcParticle;
                     unsigned int p_id = pMcParticle.id();
-                    const edm4hep::MCParticle* p_mc = &pMcParticle;
+                    auto p_mc = &pMcParticle;
                     (*m_id_pMC_map) [p_id]   = p_mc;
                     mcParticleParameters.m_momentum = pandora::CartesianVector(pMcParticle.getMomentum()[0], pMcParticle.getMomentum()[1],
                         pMcParticle.getMomentum()[2]);
@@ -74,7 +74,7 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c
                     PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::MCParticle::Create(*m_pPandora, mcParticleParameters));
 
                     // Create parent-daughter relationships
-                    for(std::vector<edm4hep::ConstMCParticle>::const_iterator itDaughter = pMcParticle.daughters_begin(),
+                    for(auto itDaughter = pMcParticle.daughters_begin(),
                         itDaughterEnd = pMcParticle.daughters_end(); itDaughter != itDaughterEnd; ++itDaughter)
                     {   
                         for (int ida = 0; ida < pMCParticleCollection.size(); ida++)
@@ -82,7 +82,7 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c
                            if(pMCParticleCollection.at(ida).id()==(*itDaughter).id())
                            {
                               
-                                const edm4hep::MCParticle& dMcParticle = pMCParticleCollection.at(ida);
+                                auto dMcParticle = pMCParticleCollection.at(ida);
                                 if(&pMcParticle == &dMcParticle){std::cout<< "error, mother and daughter are the same mc particle, don't save SetMCParentDaughterRelationship"<<std::endl;}
                                 else PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::SetMCParentDaughterRelationship(*m_pPandora, &pMcParticle, &dMcParticle));
                                 break;
@@ -249,7 +249,7 @@ pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(co
 pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(const CollectionMaps& collectionMaps, const CalorimeterHitVector &calorimeterHitVector) const
 {
     std::cout<<"Do CreateCaloHitToMCParticleRelationships"<<std::endl;
-    typedef std::map<const edm4hep::MCParticle *, float> MCParticleToEnergyWeightMap;
+    typedef std::map<edm4hep::ConstMCParticle *, float> MCParticleToEnergyWeightMap;
     MCParticleToEnergyWeightMap mcParticleToEnergyWeightMap;
 
     for (StringVector::const_iterator iter = m_settings.m_CaloHitRelationCollections.begin(), iterEnd = m_settings.m_CaloHitRelationCollections.end();
@@ -258,7 +258,7 @@ pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(co
         if(collectionMaps.collectionMap_CaloRel.find(*iter) == collectionMaps.collectionMap_CaloRel.end()) continue;
         try
         {
-            const std::vector<edm4hep::MCRecoCaloAssociation>& pMCRecoCaloAssociationCollection = (collectionMaps.collectionMap_CaloRel.find(*iter))->second;
+            auto pMCRecoCaloAssociationCollection = (collectionMaps.collectionMap_CaloRel.find(*iter))->second;
 
             for (unsigned i_calo=0; i_calo < calorimeterHitVector.size(); i_calo++)
             {
@@ -269,14 +269,14 @@ pandora::StatusCode MCParticleCreator::CreateCaloHitToMCParticleRelationships(co
                     {
                         if( pMCRecoCaloAssociationCollection.at(ic).getRec().id() != (*(calorimeterHitVector.at(i_calo))).id() ) continue;
                         
-                        const edm4hep::ConstSimCalorimeterHit pSimHit = pMCRecoCaloAssociationCollection.at(ic).getSim();
+                        auto pSimHit = pMCRecoCaloAssociationCollection.at(ic).getSim();
                         for (int iCont = 0, iEnd = pSimHit.contributions_size(); iCont < iEnd; ++iCont)
                         {
                             edm4hep::ConstCaloHitContribution conb = pSimHit.getContributions(iCont);
-                            const edm4hep::ConstMCParticle ipa = conb.getParticle();
+                            auto ipa = conb.getParticle();
                             float  ien = conb.getEnergy();
                             if( m_id_pMC_map->find(ipa.id()) == m_id_pMC_map->end() ) continue;
-                            const edm4hep::MCParticle * p_tmp = (*m_id_pMC_map)[ipa.id()]; 
+                            auto p_tmp = (*m_id_pMC_map)[ipa.id()]; 
                             mcParticleToEnergyWeightMap[p_tmp] += ien;
                         }
                         
@@ -315,32 +315,32 @@ pandora::StatusCode MCParticleCreator::CreateTrackToMCParticleRelationships(cons
     std::cout<<"Do CreateTrackToMCParticleRelationships"<<std::endl;
     for (unsigned ik = 0; ik < trackVector.size(); ik++)
     {
-        const edm4hep::Track *pTrack = trackVector.at(ik);
+        auto pTrack = trackVector.at(ik);
         // Get reconstructed momentum at dca
         const pandora::Helix helixFit(pTrack->getTrackStates(0).phi, pTrack->getTrackStates(0).D0, pTrack->getTrackStates(0).Z0, pTrack->getTrackStates(0).omega, pTrack->getTrackStates(0).tanLambda, m_bField);
         const float recoMomentum(helixFit.GetMomentum().GetMagnitude());
         // Use momentum magnitude to identify best mc particle
-        edm4hep::MCParticle *pBestMCParticle = NULL;
+        edm4hep::ConstMCParticle *pBestMCParticle = NULL;
         float bestDeltaMomentum(std::numeric_limits<float>::max());
         try
         {
             for (StringVector::const_iterator iter = m_settings.m_TrackRelationCollections.begin(), iterEnd = m_settings.m_TrackRelationCollections.end(); iter != iterEnd; ++iter)
             {
                 if(collectionMaps.collectionMap_TrkRel.find(*iter) == collectionMaps.collectionMap_TrkRel.end()) continue;
-                const std::vector<edm4hep::MCRecoTrackerAssociation>& pMCRecoTrackerAssociationCollection = (collectionMaps.collectionMap_TrkRel.find(*iter))->second;
+                auto pMCRecoTrackerAssociationCollection = (collectionMaps.collectionMap_TrkRel.find(*iter))->second;
                 for(unsigned ith=0 ; ith<pTrack->trackerHits_size(); ith++)
                 {
                     for(unsigned ic=0; ic < pMCRecoTrackerAssociationCollection.size(); ic++)
                     {
                         if( pMCRecoTrackerAssociationCollection.at(ic).getRec().id() != pTrack->getTrackerHits(ith).id() ) continue;
-                        const edm4hep::ConstSimTrackerHit pSimHit = pMCRecoTrackerAssociationCollection.at(ic).getSim();
-                        const edm4hep::ConstMCParticle ipa = pSimHit.getMCParticle();
+                        auto pSimHit = pMCRecoTrackerAssociationCollection.at(ic).getSim();
+                        auto ipa = pSimHit.getMCParticle();
                         if( m_id_pMC_map->find(ipa.id()) == m_id_pMC_map->end() ) continue;
                         const float trueMomentum(pandora::CartesianVector(ipa.getMomentum()[0], ipa.getMomentum()[1], ipa.getMomentum()[2]).GetMagnitude());
                         const float deltaMomentum(std::fabs(recoMomentum - trueMomentum));
                         if (deltaMomentum < bestDeltaMomentum)
                         {
-                            pBestMCParticle =const_cast<edm4hep::MCParticle*>((*m_id_pMC_map)[ipa.id()]);
+                            pBestMCParticle = ((*m_id_pMC_map)[ipa.id()]);
                             bestDeltaMomentum = deltaMomentum;
                         }
                     }
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/src/PandoraMatrixAlg.cpp b/Reconstruction/PFA/Pandora/MatrixPandora/src/PandoraMatrixAlg.cpp
index d59c1a063d9ae4734ef1944d42db35930e594edf..9ea004bb085efe009aa3a25fa59082f5ef0740c0 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/src/PandoraMatrixAlg.cpp
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/src/PandoraMatrixAlg.cpp
@@ -474,8 +474,8 @@ StatusCode PandoraMatrixAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::MCParticleCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::MCParticle> v_mc;
-                    m_CollectionMaps->collectionMap_MC [v.first] = v_mc;
+                    // std::vector<edm4hep::MCParticle> v_mc;
+                    // m_CollectionMaps->collectionMap_MC [v.first] = v_mc;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_MC [v.first].push_back(po->at(i));
                     std::cout<<"saved col name="<<v.first<<std::endl;
                 }
@@ -487,8 +487,8 @@ StatusCode PandoraMatrixAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::CalorimeterHitCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::CalorimeterHit> v_cal;
-                    m_CollectionMaps->collectionMap_CaloHit[v.first] = v_cal ;
+                    // std::vector<edm4hep::CalorimeterHit> v_cal;
+                    // m_CollectionMaps->collectionMap_CaloHit[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloHit [v.first].push_back(po->at(i));
                     std::cout<<"saved col name="<<v.first<<std::endl;
                 }
@@ -500,8 +500,8 @@ StatusCode PandoraMatrixAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::TrackCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::Track> v_cal;
-                    m_CollectionMaps->collectionMap_Track[v.first] = v_cal ;
+                    // std::vector<edm4hep::Track> v_cal;
+                    // m_CollectionMaps->collectionMap_Track[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Track [v.first].push_back(po->at(i));
                     std::cout<<"saved col name="<<v.first<<std::endl;
                 }
@@ -513,8 +513,8 @@ StatusCode PandoraMatrixAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::VertexCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::Vertex> v_cal;
-                    m_CollectionMaps->collectionMap_Vertex[v.first] = v_cal ;
+                    // std::vector<edm4hep::Vertex> v_cal;
+                    // m_CollectionMaps->collectionMap_Vertex[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_Vertex [v.first].push_back(po->at(i));
                     std::cout<<"saved col name="<<v.first<<std::endl;
                 }
@@ -526,8 +526,8 @@ StatusCode PandoraMatrixAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::MCRecoCaloAssociationCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::MCRecoCaloAssociation> v_cal;
-                    m_CollectionMaps->collectionMap_CaloRel[v.first] = v_cal ;
+                    // std::vector<edm4hep::MCRecoCaloAssociation> v_cal;
+                    // m_CollectionMaps->collectionMap_CaloRel[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_CaloRel [v.first].push_back(po->at(i));
                     std::cout<<"saved col name="<<v.first<<std::endl;
                 }
@@ -539,8 +539,8 @@ StatusCode PandoraMatrixAlg::updateMap()
                 auto handle = dynamic_cast<DataHandle<edm4hep::MCRecoTrackerAssociationCollection>*> (v.second);
                 auto po = handle->get();
                 if(po != NULL){
-                    std::vector<edm4hep::MCRecoTrackerAssociation> v_cal;
-                    m_CollectionMaps->collectionMap_TrkRel[v.first] = v_cal ;
+                    // std::vector<edm4hep::MCRecoTrackerAssociation> v_cal;
+                    // m_CollectionMaps->collectionMap_TrkRel[v.first] = v_cal ;
                     for(unsigned int i=0 ; i< po->size(); i++) m_CollectionMaps->collectionMap_TrkRel [v.first].push_back(po->at(i));
                     std::cout<<"saved col name="<<v.first<<std::endl;
                 }
@@ -570,7 +570,7 @@ StatusCode PandoraMatrixAlg::Ana()
     for(int i=0; i<reco_col->size();i++)
     {
         std::cout<<"reco="<<i<<std::endl;
-        const edm4hep::ReconstructedParticle pReco = reco_col->at(i);
+        auto pReco = reco_col->at(i);
         const float px = pReco.getMomentum()[0];
         const float py = pReco.getMomentum()[1];
         const float pz = pReco.getMomentum()[2];
@@ -642,19 +642,19 @@ StatusCode PandoraMatrixAlg::CreateMCRecoParticleAssociation()
         std::map<int, edm4hep::ConstMCParticle> mc_map;
         std::map<int, float > id_edep_map;
         float tot_en = 0 ;
-        const edm4hep::ReconstructedParticle pReco = reco_col->at(i);
+        auto pReco = reco_col->at(i);
         for(int j=0; j < pReco.clusters_size(); j++)
         {
             edm4hep::ConstCluster cluster = pReco.getClusters(j);
             for(int k=0; k < cluster.hits_size(); k++)
             {
                 edm4hep::ConstCalorimeterHit hit = cluster.getHits(k);
-                for(std::map<std::string, std::vector<edm4hep::MCRecoCaloAssociation> >::iterator iter = m_CollectionMaps->collectionMap_CaloRel.begin(); iter != m_CollectionMaps->collectionMap_CaloRel.end(); iter++)
+                for(auto iter = m_CollectionMaps->collectionMap_CaloRel.begin(); iter != m_CollectionMaps->collectionMap_CaloRel.end(); iter++)
                 {
-                    for(std::vector<edm4hep::MCRecoCaloAssociation>::iterator it = iter->second.begin(); it != iter->second.end(); it ++)
+                    for(auto it = iter->second.begin(); it != iter->second.end(); it ++)
                     {
                         if(it->getRec().id() != hit.id()) continue;
-                        for(std::vector<edm4hep::ConstCaloHitContribution>::const_iterator itc = it->getSim().contributions_begin(); itc != it->getSim().contributions_end(); itc++)
+                        for(auto itc = it->getSim().contributions_begin(); itc != it->getSim().contributions_end(); itc++)
                         {
                             if(mc_map.find(itc->getParticle().id()) == mc_map.end()) mc_map[itc->getParticle().id()] = itc->getParticle() ;
                             if(id_edep_map.find(itc->getParticle().id()) != id_edep_map.end()) id_edep_map[itc->getParticle().id()] = id_edep_map[itc->getParticle().id()] + itc->getEnergy() ;
@@ -665,7 +665,7 @@ StatusCode PandoraMatrixAlg::CreateMCRecoParticleAssociation()
                 }
             }
         }
-        for(std::map<int, edm4hep::ConstMCParticle>::iterator it = mc_map.begin(); it != mc_map.end(); it ++)
+        for(auto it = mc_map.begin(); it != mc_map.end(); it ++)
         {      
             edm4hep::MCRecoParticleAssociation association = pMCRecoParticleAssociationCollection->create();
             association.setRec(pReco);
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/src/TrackCreator.cpp b/Reconstruction/PFA/Pandora/MatrixPandora/src/TrackCreator.cpp
index 2a5c8f0084f15dcb3f22a22e97a67081db215844..945c49f93bf3855f31669a3beabb7cd16ddb27a3 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/src/TrackCreator.cpp
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/src/TrackCreator.cpp
@@ -157,18 +157,18 @@ pandora::StatusCode TrackCreator::ExtractKinks(const CollectionMaps& collectionM
         if(collectionMaps.collectionMap_Vertex.find(*iter) == collectionMaps.collectionMap_Vertex.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Vertex>& pKinkCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
+            auto pKinkCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
 
             for (int i = 0, iMax = pKinkCollection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Vertex  pVertex0 = pKinkCollection.at(i);
-                    const edm4hep::Vertex* pVertex  = &(pVertex0);
+                    auto  pVertex0 = pKinkCollection.at(i);
+                    auto  pVertex  = &(pVertex0);
 
                     if (NULL == pVertex) throw ("Collection type mismatch");
 
-                    const edm4hep::ConstReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle();
+                    auto pReconstructedParticle = pVertex->getAssociatedParticle();
                     if (this->IsConflictingRelationship(pReconstructedParticle))continue;
 
                     const int vertexPdgCode(pReconstructedParticle.getType());
@@ -176,7 +176,7 @@ pandora::StatusCode TrackCreator::ExtractKinks(const CollectionMaps& collectionM
                     // Extract the kink vertex information
                     for (unsigned int iTrack = 0, nTracks = pReconstructedParticle.tracks_size(); iTrack < nTracks; ++iTrack)
                     {
-                        edm4hep::ConstTrack pTrack = pReconstructedParticle.getTracks(iTrack);
+                        auto pTrack = pReconstructedParticle.getTracks(iTrack);
                         (0 == iTrack) ? m_parentTrackList.insert(pTrack.id()) : m_daughterTrackList.insert(pTrack.id());
 
                         int trackPdgCode = pandora::UNKNOWN_PARTICLE_TYPE;
@@ -259,24 +259,24 @@ pandora::StatusCode TrackCreator::ExtractProngsAndSplits(const CollectionMaps& c
         if(collectionMaps.collectionMap_Vertex.find(*iter) == collectionMaps.collectionMap_Vertex.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Vertex>& pProngOrSplitCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
+            auto pProngOrSplitCollection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
 
             for (int i = 0, iMax = pProngOrSplitCollection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Vertex  pVertex0 = pProngOrSplitCollection.at(i);
-                    const edm4hep::Vertex* pVertex  = &(pVertex0);
+                    auto  pVertex0 = pProngOrSplitCollection.at(i);
+                    auto  pVertex  = &(pVertex0);
 
                     if (NULL == pVertex) throw ("Collection type mismatch");
-                    const edm4hep::ConstReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle();
+                    auto pReconstructedParticle = pVertex->getAssociatedParticle();
 
                     if (this->IsConflictingRelationship(pReconstructedParticle))continue;
 
                     // Extract the prong/split vertex information
                     for (unsigned int iTrack = 0, nTracks = pReconstructedParticle.tracks_size(); iTrack < nTracks; ++iTrack)
                     {
-                        edm4hep::ConstTrack pTrack = pReconstructedParticle.getTracks(iTrack);
+                        auto pTrack = pReconstructedParticle.getTracks(iTrack);
                         (0 == iTrack) ? m_parentTrackList.insert(pTrack.id()) : m_daughterTrackList.insert(pTrack.id());
 
                         if (0 == m_settings.m_shouldFormTrackRelationships) continue;
@@ -325,18 +325,18 @@ pandora::StatusCode TrackCreator::ExtractV0s(const CollectionMaps& collectionMap
         if(collectionMaps.collectionMap_Vertex.find(*iter) == collectionMaps.collectionMap_Vertex.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Vertex>& pV0Collection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
+            auto pV0Collection = (collectionMaps.collectionMap_Vertex.find(*iter))->second;
 
             for (int i = 0, iMax = pV0Collection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Vertex  pVertex0 = pV0Collection.at(i);
-                    const edm4hep::Vertex* pVertex  = &(pVertex0);
+                    auto  pVertex0 = pV0Collection.at(i);
+                    auto  pVertex  = &(pVertex0);
 
                     if (NULL == pVertex) throw ("Collection type mismatch");
 
-                    const edm4hep::ConstReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle();
+                    auto pReconstructedParticle = pVertex->getAssociatedParticle();
 
                     if (this->IsConflictingRelationship(pReconstructedParticle))continue;
 
@@ -345,7 +345,7 @@ pandora::StatusCode TrackCreator::ExtractV0s(const CollectionMaps& collectionMap
 
                     for (unsigned int iTrack = 0, nTracks = pReconstructedParticle.tracks_size(); iTrack < nTracks; ++iTrack)
                     {
-                        edm4hep::ConstTrack pTrack = pReconstructedParticle.getTracks(iTrack);
+                        auto pTrack = pReconstructedParticle.getTracks(iTrack);
                         m_v0TrackList.insert(pTrack.id());
 
                         int trackPdgCode = pandora::UNKNOWN_PARTICLE_TYPE;
@@ -410,16 +410,16 @@ bool TrackCreator::IsConflictingRelationship(const edm4hep::ConstReconstructedPa
     return false;
 }
 
-const edm4hep::Track* TrackCreator::GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack )
+edm4hep::ConstTrack* TrackCreator::GetTrackAddress(const CollectionMaps& collectionMaps, const edm4hep::ConstTrack& pTrack )
 {
     for (StringVector::const_iterator iter = m_settings.m_trackCollections.begin(), iterEnd = m_settings.m_trackCollections.end(); iter != iterEnd; ++iter)
     {
         if(collectionMaps.collectionMap_Track.find(*iter) == collectionMaps.collectionMap_Track.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
-        const std::vector<edm4hep::Track>& pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
+        auto pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
         for (int i = 0, iMax = pTrackCollection.size(); i < iMax; ++i)
         {
-            const edm4hep::Track& pTrack0 = pTrackCollection.at(i);
-            if (pTrack.id() == pTrack0.id()) return (const edm4hep::Track*) (&pTrack0);
+            auto pTrack0 = pTrackCollection.at(i);
+            if (pTrack.id() == pTrack0.id()) return (&pTrack0);
         }
     }
     return NULL;
@@ -435,15 +435,15 @@ pandora::StatusCode TrackCreator::CreateTracks(const CollectionMaps& collectionM
         if(collectionMaps.collectionMap_Track.find(*iter) == collectionMaps.collectionMap_Track.end()) { std::cout<<"not find "<<(*iter)<<std::endl; continue;}
         try
         {
-            const std::vector<edm4hep::Track>& pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
+            auto pTrackCollection = (collectionMaps.collectionMap_Track.find(*iter))->second;
             std::cout<<(*iter)<<" size="<<pTrackCollection.size()<<std::endl;
 
             for (int i = 0, iMax = pTrackCollection.size(); i < iMax; ++i)
             {
                 try
                 {
-                    const edm4hep::Track& pTrack0 = pTrackCollection.at(i);
-                    const edm4hep::Track* pTrack  = (const edm4hep::Track*)(&pTrack0);
+                    auto pTrack0 = pTrackCollection.at(i);
+                    auto pTrack  = (&pTrack0);
 
                     if (NULL == pTrack) throw ("Collection type mismatch");
 
@@ -521,7 +521,7 @@ pandora::StatusCode TrackCreator::CreateTracks(const CollectionMaps& collectionM
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void TrackCreator::GetTrackStates(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
+void TrackCreator::GetTrackStates(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
 {
     edm4hep::TrackState pTrackState = pTrack->getTrackStates(1); // ref  /cvmfs/cepcsw.ihep.ac.cn/prototype/LCIO/include/EVENT/TrackState.h 
 
@@ -551,7 +551,7 @@ void TrackCreator::GetTrackStates(const edm4hep::Track *const pTrack, PandoraApi
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-float TrackCreator::CalculateTrackTimeAtCalorimeter(const edm4hep::Track *const pTrack) const
+float TrackCreator::CalculateTrackTimeAtCalorimeter(edm4hep::ConstTrack *const pTrack) const
 {
     const pandora::Helix helix(pTrack->getTrackStates(0).phi, pTrack->getTrackStates(0).D0, pTrack->getTrackStates(0).Z0, pTrack->getTrackStates(0).omega, pTrack->getTrackStates(0).tanLambda, m_bField);
     const pandora::CartesianVector &referencePoint(helix.GetReferencePoint());
@@ -624,7 +624,7 @@ void TrackCreator::CopyTrackState(const edm4hep::TrackState & pTrackState, pando
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void TrackCreator::TrackReachesECAL(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
+void TrackCreator::TrackReachesECAL(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
 {
     
     // Calculate hit position information
@@ -707,7 +707,7 @@ void TrackCreator::TrackReachesECAL(const edm4hep::Track *const pTrack, PandoraA
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-void TrackCreator::DefineTrackPfoUsage(const edm4hep::Track *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
+void TrackCreator::DefineTrackPfoUsage(edm4hep::ConstTrack *const pTrack, PandoraApi::Track::Parameters &trackParameters) const
 {
     bool canFormPfo(false);
     bool canFormClusterlessPfo(false);
@@ -718,7 +718,7 @@ void TrackCreator::DefineTrackPfoUsage(const edm4hep::Track *const pTrack, Pando
 
         float rInner(std::numeric_limits<float>::max()), zMin(std::numeric_limits<float>::max());
 
-        for (std::vector<edm4hep::ConstTrackerHit>::const_iterator iter = pTrack->trackerHits_begin(), iterEnd = pTrack->trackerHits_end(); iter != iterEnd; ++iter)
+        for (auto iter = pTrack->trackerHits_begin(), iterEnd = pTrack->trackerHits_end(); iter != iterEnd; ++iter)
         {
             const edm4hep::Vector3d pPosition = (*iter).getPosition(); 
             const float x(pPosition[0]), y(pPosition[1]), absoluteZ(std::fabs(pPosition[2]));
@@ -791,7 +791,7 @@ void TrackCreator::DefineTrackPfoUsage(const edm4hep::Track *const pTrack, Pando
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-bool TrackCreator::PassesQualityCuts(const edm4hep::Track *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const
+bool TrackCreator::PassesQualityCuts(edm4hep::ConstTrack *const pTrack, const PandoraApi::Track::Parameters &trackParameters) const
 {
     // First simple sanity checks
     if (trackParameters.m_trackStateAtCalorimeter.Get().GetPosition().GetMagnitude() < m_settings.m_minTrackECalDistanceFromIp)
@@ -868,14 +868,14 @@ bool TrackCreator::PassesQualityCuts(const edm4hep::Track *const pTrack, const P
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-int TrackCreator::GetNTpcHits(const edm4hep::Track *const pTrack) const
+int TrackCreator::GetNTpcHits(edm4hep::ConstTrack *const pTrack) const
 {
     return pTrack->getSubDetectorHitNumbers(2 * lcio::ILDDetID::TPC - 1);// still use LCIO code now
 }
 
 //------------------------------------------------------------------------------------------------------------------------------------------
 
-int TrackCreator::GetNFtdHits(const edm4hep::Track *const pTrack) const
+int TrackCreator::GetNFtdHits(edm4hep::ConstTrack *const pTrack) const
 {
     return pTrack->getSubDetectorHitNumbers( 2 * lcio::ILDDetID::FTD - 1 );
 }
diff --git a/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp b/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp
index 88d71d3c05c70a4e57d64454cc8f2ed7847d44e3..a3fde79c5e4ffb9894c9d9d70450152c44155dbd 100644
--- a/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp
+++ b/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp
@@ -660,7 +660,7 @@ int SiliconTrackingAlg::InitialiseVTX() {
     
     for (int ielem=0; ielem<nelem; ++ielem) {
     //for(auto hit : *hitVTXCol){ 
-      edm4hep::TrackerHit hit = hitVTXCol->at(ielem);
+      auto hit = hitVTXCol->at(ielem);
       //gear::Vector3D U(1.0,hit->getU()[1],hit->getU()[0],gear::Vector3D::spherical);
       //gear::Vector3D V(1.0,hit->getV()[1],hit->getV()[0],gear::Vector3D::spherical);
       gear::Vector3D U(1.0,hit.getCovMatrix()[1],hit.getCovMatrix()[0],gear::Vector3D::spherical);
diff --git a/Reconstruction/SiliconTracking/src/SpacePointBuilderAlg.cpp b/Reconstruction/SiliconTracking/src/SpacePointBuilderAlg.cpp
index 956b425122cb65927647ffa885bb3e3524b7e96e..fdd5118dab14d0c693f674335ee01f415bb853d0 100644
--- a/Reconstruction/SiliconTracking/src/SpacePointBuilderAlg.cpp
+++ b/Reconstruction/SiliconTracking/src/SpacePointBuilderAlg.cpp
@@ -108,10 +108,17 @@ StatusCode SpacePointBuilderAlg::execute(){
     
     unsigned nHits = hitCol->size();
     debug() << "Number of hits: " << nHits << endmsg;
+
+    if (!nHits) {
+        return sc;
+    }
+
+    auto tmpHit0 = hitCol->at(0);
     
     //store hits in map according to their CellID0
-    std::map<long long, std::vector<edm4hep::TrackerHit> > map_cellID0_hits;
-    std::map<long long, std::vector<edm4hep::TrackerHit> >::iterator it;
+    
+    std::map<long long, std::vector<decltype(tmpHit0)> > map_cellID0_hits;
+    decltype(map_cellID0_hits)::iterator it;
     for(auto trkHit : *hitCol){
       debug() << "Add hit with CellID0 = " << trkHit.getCellID() << " " << getCellID0Info( trkHit.getCellID() ) << endmsg;
       map_cellID0_hits[ trkHit.getCellID() ].push_back( trkHit );
@@ -121,14 +128,14 @@ StatusCode SpacePointBuilderAlg::execute(){
     // now loop over all CellID0s
     for( it= map_cellID0_hits.begin(); it!= map_cellID0_hits.end(); it++ ){
       rawStripHits += it->second.size();
-      std::vector<edm4hep::TrackerHit>& hitsFront = it->second;
+      auto hitsFront = it->second;
       unsigned long long cellID0 = it->first;
       //get the CellID0s at the back of this sensor
       std::vector<int> cellID0sBack = getCellID0sAtBack( cellID0 );
       
       for( unsigned i=0; i< cellID0sBack.size(); i++ ){ 
         int cellID0Back = cellID0sBack[i];
-        std::vector<edm4hep::TrackerHit>& hitsBack = map_cellID0_hits[ cellID0Back ];
+        auto hitsBack = map_cellID0_hits[ cellID0Back ];
         debug() << "strips: CellID0 " << cellID0  << " " << getCellID0Info( cellID0 )  << "(" << hitsFront.size()
 		<< " hits) <---> CellID0 " << cellID0Back << getCellID0Info( cellID0Back )
 		<< "(" << hitsBack.size() << " hits)" << endmsg
@@ -137,9 +144,9 @@ StatusCode SpacePointBuilderAlg::execute(){
         possibleSpacePoints += hitsFront.size() * hitsBack.size();
 	// Now iterate over all combinations and store those that make sense
         for( unsigned ifront=0; ifront<hitsFront.size(); ifront++ ){
-	  edm4hep::TrackerHit& hitFront = hitsFront[ifront];
+	  auto hitFront = hitsFront[ifront];
 	  for( unsigned j=0; j<hitsBack.size(); j++ ){
-	    edm4hep::TrackerHit& hitBack = hitsBack[j];
+	    auto hitBack = hitsBack[j];
 
 	    std::vector<edm4hep::ConstSimTrackerHit> simHitsFront;
 	    std::vector<edm4hep::ConstSimTrackerHit> simHitsBack;
diff --git a/Reconstruction/SiliconTracking/src/TrackSubsetAlg.cpp b/Reconstruction/SiliconTracking/src/TrackSubsetAlg.cpp
index 2efe0f52c1fae8cbb0f154b88844469b568d4540..3d049e6ae8e318eef46cff80e71fc1e49ff1abe6 100644
--- a/Reconstruction/SiliconTracking/src/TrackSubsetAlg.cpp
+++ b/Reconstruction/SiliconTracking/src/TrackSubsetAlg.cpp
@@ -96,7 +96,7 @@ StatusCode TrackSubsetAlg::finalize(){
 }
 
 StatusCode TrackSubsetAlg::execute(){ 
-  std::vector<edm4hep::Track> tracks;
+  std::vector<edm4hep::ConstTrack> tracks;
 
   auto trkCol = _outColHdl.createAndPut();
   /**********************************************************************************************/
@@ -151,9 +151,9 @@ StatusCode TrackSubsetAlg::execute(){
   
   debug() << "The tracks and their qualities (and their hits ): " << endmsg;
 
-  std::vector<edm4hep::Track*> tracks_p;
+  std::vector<edm4hep::ConstTrack*> tracks_p;
   for( unsigned i=0; i < tracks.size(); i++ ){
-    edm4hep::Track* track = &tracks[i];
+    auto* track = &tracks[i];
     tracks_p.push_back(track);
     double qi = trackQI( track );
     debug() << "Track " << track->id() << " address " << track << "\t" << qi << "( ";
@@ -174,14 +174,14 @@ StatusCode TrackSubsetAlg::execute(){
   
   TrackCompatibility comp;
   
-  SubsetHopfieldNN<edm4hep::Track*> subset;
+  SubsetHopfieldNN<edm4hep::ConstTrack*> subset;
   //SubsetSimple<edm4hep::Track* > subset;
   subset.add( tracks_p );
   subset.setOmega( _omega );
   subset.calculateBestSet( comp, trackQI );
 
-  std::vector<edm4hep::Track*> accepted = subset.getAccepted();
-  std::vector<edm4hep::Track*> rejected = subset.getRejected();
+  auto accepted = subset.getAccepted();
+  auto rejected = subset.getRejected();
   
   debug() << "\tThe accepted tracks:" << endmsg;
   for( unsigned i=0; i < accepted.size(); i++ ){
@@ -203,7 +203,7 @@ StatusCode TrackSubsetAlg::execute(){
   for( unsigned i=0; i < accepted.size(); i++ ){
     edm4hep::Track trackImpl;
     
-    edm4hep::Track* track = accepted[i];
+    auto track = accepted[i];
     
     std::vector<edm4hep::ConstTrackerHit> trackerHitsObj;
     std::vector<edm4hep::ConstTrackerHit> trackerHits;
diff --git a/Reconstruction/SiliconTracking/src/TrackSubsetAlg.h b/Reconstruction/SiliconTracking/src/TrackSubsetAlg.h
index c6e59d81799a82a49936153a2d15d4d5778995b6..e6f710ddf096c4a1fda91d546bb222e3b850a00b 100644
--- a/Reconstruction/SiliconTracking/src/TrackSubsetAlg.h
+++ b/Reconstruction/SiliconTracking/src/TrackSubsetAlg.h
@@ -5,6 +5,7 @@
 #include "GaudiAlg/GaudiAlgorithm.h"
 
 #include "edm4hep/TrackCollection.h"
+#include "edm4hep/TrackerHitCollection.h"
 //#include "edm4hep/Track.h"
 #include "TrackSystemSvc/IMarlinTrkSystem.h"
 
@@ -83,7 +84,7 @@ class TrackSubsetAlg : public GaudiAlgorithm {
 /** A functor to return whether two tracks are compatible: The criterion is if the share a TrackerHit or more */
 class TrackCompatibility{
  public:
-  inline bool operator()( edm4hep::Track* trackA, edm4hep::Track* trackB ){
+  inline bool operator()( edm4hep::ConstTrack* trackA, edm4hep::ConstTrack* trackB ){
     unsigned nHitsA = trackA->trackerHits_size();
     unsigned nHitsB = trackB->trackerHits_size();
     for( unsigned i=0; i < nHitsA; i++){
@@ -103,7 +104,7 @@ class TrackQI{
   /** @param trkSystem a pointer to an IMarlinTrkSystem, needed for fitting of tracks */
   TrackQI( MarlinTrk::IMarlinTrkSystem* trkSystem ): _trkSystem(trkSystem){}
   
-  inline double operator()( edm4hep::Track* track ){
+  inline double operator()( edm4hep::ConstTrack* track ){
     return ROOT::Math::chisquared_cdf_c( track->getChi2() , track->getNdf() );   
   }
   
diff --git a/Reconstruction/Tracking/src/Clupatra/ClupatraAlg.h b/Reconstruction/Tracking/src/Clupatra/ClupatraAlg.h
index fc680dc2f52d6cdf44ff126daaf7d6ae2f61a3bd..1f1b832207c65e6f63d5fb3220ff45938e9c40b0 100644
--- a/Reconstruction/Tracking/src/Clupatra/ClupatraAlg.h
+++ b/Reconstruction/Tracking/src/Clupatra/ClupatraAlg.h
@@ -9,6 +9,7 @@
 #include "GaudiAlg/GaudiAlgorithm.h"
 #include "edm4hep/Track.h"
 #include "edm4hep/TrackerHitConst.h"
+#include "edm4hep/TrackerHitCollection.h"
 #include "edm4hep/TrackCollection.h"
 #include <string>
 
diff --git a/Service/GearSvc/CMakeLists.txt b/Service/GearSvc/CMakeLists.txt
index a70dae702f0d31a63bd831d083bde979ad2e31eb..686ad1cd1570e3aa9ebca4af781aebb4c1e07c9a 100644
--- a/Service/GearSvc/CMakeLists.txt
+++ b/Service/GearSvc/CMakeLists.txt
@@ -11,6 +11,10 @@ gaudi_add_module(GearSvcPlugins
 		      DetSegmentation
 )
 
+target_include_directories(GearSvcPlugins
+  PUBLIC ${GEAR_INCLUDE_DIRS}
+)
+
 install(TARGETS GearSvc GearSvcPlugins
   EXPORT CEPCSWTargets
   RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
index 2736ac984c15b53f291dfac472a5e3307f823a60..f038658b5498ebd258ef8ffbed8070c79e7f3833 100644
--- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
@@ -37,7 +37,26 @@ Edm4hepWriterAnaElemTool::BeginOfEventAction(const G4Event* anEvent) {
 
 void
 Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
-    auto mcCol = m_mcParCol.get();
+    auto mcGenCol = m_mcParCol.get();
+    mcCol = m_mcParCol.createAndPut();
+
+    // copy the MC particle first
+    for (auto mcGenParticle: *mcGenCol) {
+        auto newparticle = mcCol->create();
+        newparticle.setPDG            (mcGenParticle.getPDG());
+        newparticle.setGeneratorStatus(mcGenParticle.getGeneratorStatus());
+        newparticle.setSimulatorStatus(mcGenParticle.getSimulatorStatus());
+        newparticle.setCharge         (mcGenParticle.getCharge());
+        newparticle.setTime           (mcGenParticle.getTime());
+        newparticle.setMass           (mcGenParticle.getMass());
+        newparticle.setVertex         (mcGenParticle.getVertex());
+        newparticle.setEndpoint       (mcGenParticle.getEndpoint());
+        newparticle.setMomentum       (mcGenParticle.getMomentum());
+        newparticle.setMomentumAtEndpoint(mcGenParticle.getMomentumAtEndpoint());
+        newparticle.setSpin           (mcGenParticle.getSpin());
+        newparticle.setColorFlow      (mcGenParticle.getColorFlow());
+    }
+    
     msg() << "mcCol size: " << mcCol->size() << endmsg;
     // save all data
 
@@ -328,7 +347,7 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
 
     if (curparid == 0) {
         // select the primary tracks (parentID == 0)
-        auto mcCol = m_mcParCol.get();
+        // auto mcCol = m_mcParCol.get();
 
         if (curtrkid-1>=mcCol->size()) {
             error() << "out of range: curtrkid is " << curtrkid
@@ -400,7 +419,7 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
 
                     // create secondaries in MC particles
                     // todo: convert the const collection to non-const
-                    auto mcCol = const_cast<edm4hep::MCParticleCollection*>(m_mcParCol.get());
+                    // auto mcCol = const_cast<edm4hep::MCParticleCollection*>(m_mcParCol.get());
                     edm4hep::MCParticle mcp = mcCol->create();
                     mcp.setPDG(secparticle->GetPDGEncoding());
                     mcp.setGeneratorStatus(0); // not created by Generator
diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
index 26a1ba48a1ab00a05fa65a4fa011320d1770d988..7b992d3076c0ddfa7b7bd9f5d8639274ba0538b1 100644
--- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
+++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
@@ -41,8 +41,13 @@ public:
 
 private:
     // In order to associate MCParticle with contribution, we need to access MC Particle.
-    DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle", 
+    // - collection MCParticle: the particles in Generator
+    DataHandle<edm4hep::MCParticleCollection> m_mcParGenCol{"MCParticle", 
             Gaudi::DataHandle::Writer, this};
+    // - collection MCParticleG4: the simulated particles in Geant4
+    DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticleG4", 
+            Gaudi::DataHandle::Writer, this};
+    edm4hep::MCParticleCollection* mcCol;
 
     // Generic collections for Tracker and Calorimeter
     DataHandle<edm4hep::SimTrackerHitCollection> m_trackerCol{"SimTrackerCol", 
diff --git a/Simulation/DetSimCore/CMakeLists.txt b/Simulation/DetSimCore/CMakeLists.txt
index 933406ceb023dc43651c0b025a471d2f80056f8d..e64cd3c467c388767914324bd1db37c23120a6ab 100644
--- a/Simulation/DetSimCore/CMakeLists.txt
+++ b/Simulation/DetSimCore/CMakeLists.txt
@@ -22,6 +22,7 @@ gaudi_add_module(DetSimCore
                       ${DD4hep_COMPONENT_LIBRARIES} 
                       k4FWCore::k4FWCore
                       EDM4HEP::edm4hep EDM4HEP::edm4hepDict
+                      k4FWCore::k4FWCore
 )
 
 install(TARGETS DetSimCore
diff --git a/Utilities/DataHelper/CMakeLists.txt b/Utilities/DataHelper/CMakeLists.txt
index c2d23702b687d3aa123186e8ec348b10543ca825..8398a6557a29db9dd46c8cb5b8518ae6ff7ecc3e 100644
--- a/Utilities/DataHelper/CMakeLists.txt
+++ b/Utilities/DataHelper/CMakeLists.txt
@@ -18,7 +18,7 @@ gaudi_add_library(DataHelperLib
 			  src/TrackerHitHelper.cpp
                   LINK EDM4HEP::edm4hep
                        EDM4HEP::edm4hepDict
-                       ${GSL_LIBRARIES}
+                       GSL::gsl
                        ${CLHEP_LIBRARIES}
 		       Identifier
 )
diff --git a/Utilities/KalDet/CMakeLists.txt b/Utilities/KalDet/CMakeLists.txt
index 3b7497713d64ebe552de5104a6edbb095c64b560..b584868258eb8237af72b869ad0a338b979e872f 100644
--- a/Utilities/KalDet/CMakeLists.txt
+++ b/Utilities/KalDet/CMakeLists.txt
@@ -76,6 +76,11 @@ gaudi_add_library(KalDetLib
 
 )
 
+target_include_directories(KalDetLib
+  PUBLIC ${GEAR_INCLUDE_DIRS}
+  PUBLIC ${LCIO_INCLUDE_DIRS}
+)
+
 install(TARGETS KalDetLib
   EXPORT CEPCSWTargets
   RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
diff --git a/Utilities/KiTrack/include/ILDImpl/FTDHit01.h b/Utilities/KiTrack/include/ILDImpl/FTDHit01.h
index 6750231efe04a04032f1e90a987f689ff7ed1771..66b975e5d27e5a0b423ad7c4b8f5d921efe0438a 100644
--- a/Utilities/KiTrack/include/ILDImpl/FTDHit01.h
+++ b/Utilities/KiTrack/include/ILDImpl/FTDHit01.h
@@ -14,7 +14,7 @@ namespace KiTrackMarlin{
   class FTDHit01 : public IFTDHit{
   public:
       
-    FTDHit01( edm4hep::TrackerHit trackerHit , const SectorSystemFTD* const sectorSystemFTD );
+    FTDHit01( edm4hep::ConstTrackerHit trackerHit , const SectorSystemFTD* const sectorSystemFTD );
   };
 }
 #endif
diff --git a/Utilities/KiTrack/include/ILDImpl/IFTDHit.h b/Utilities/KiTrack/include/ILDImpl/IFTDHit.h
index 33b817bf5bc5f0aaa73edb6188574977dbb757fe..cb497dfafabb9e99d954feb980f12893991fedc7 100644
--- a/Utilities/KiTrack/include/ILDImpl/IFTDHit.h
+++ b/Utilities/KiTrack/include/ILDImpl/IFTDHit.h
@@ -16,7 +16,7 @@ namespace KiTrackMarlin{
   class IFTDHit : public IHit{
   public:
         
-    edm4hep::TrackerHit* getTrackerHit() { return &_trackerHit; };
+    edm4hep::ConstTrackerHit* getTrackerHit() { return &_trackerHit; };
             
     int getSide() { return _side; }
     unsigned getModule() { return _module; }
@@ -31,7 +31,7 @@ namespace KiTrackMarlin{
     
   protected:
     
-    edm4hep::TrackerHit _trackerHit;
+    edm4hep::ConstTrackerHit _trackerHit;
             
     int _side;
     unsigned _layer;
diff --git a/Utilities/KiTrack/src/ILDImpl/FTDHit01.cc b/Utilities/KiTrack/src/ILDImpl/FTDHit01.cc
index a5eaab1ca29a184eb0ff8cc2e457ee7f03450b42..5d53538cac4f9c9d9c42ee666a99928ac4aaa9ee 100644
--- a/Utilities/KiTrack/src/ILDImpl/FTDHit01.cc
+++ b/Utilities/KiTrack/src/ILDImpl/FTDHit01.cc
@@ -6,7 +6,7 @@
 using namespace KiTrackMarlin;
 
 
-FTDHit01::FTDHit01( edm4hep::TrackerHit trackerHit , const SectorSystemFTD* const sectorSystemFTD ){
+FTDHit01::FTDHit01( edm4hep::ConstTrackerHit trackerHit , const SectorSystemFTD* const sectorSystemFTD ){
    
    
    _sectorSystemFTD = sectorSystemFTD;
diff --git a/cmake/CEPCSWDependencies.cmake b/cmake/CEPCSWDependencies.cmake
index 710091d1b28296358a083dc18566e4dedcee8208..ae8964747f332d378117988da346491a9dff4a98 100644
--- a/cmake/CEPCSWDependencies.cmake
+++ b/cmake/CEPCSWDependencies.cmake
@@ -22,7 +22,8 @@ Find all the dependencies here, so in each package user don't need to find the p
 find_package(CLHEP REQUIRED;CONFIG)
 find_package(DD4hep COMPONENTS DDCore DDG4 DDParsers DDRec REQUIRED)
 find_package(EDM4HEP REQUIRED)
-find_package(Garfield REQUIRED)
+#find_package(Garfield REQUIRED)
+find_package(Garfield)
 find_package(Geant4 REQUIRED ui_all vis_all)
 find_package(GEAR REQUIRED)
 find_package(GSL REQUIRED)