diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp index d13b5e5ad5c709e0daf3a3eec0fc6bd819d65ff4..f46df648c7c807a70a2063603d1522a61e277ccf 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/CaloHitCreator.cpp @@ -240,7 +240,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col try { if(m_settings.m_debug) std::cout<<"CaloHitCreator for "<<tmp_col_name<<std::endl; - auto 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) @@ -276,8 +276,7 @@ pandora::StatusCode CaloHitCreator::CreateECalCaloHits(const CollectionMaps& col { try { - auto pCaloHit0 = pCaloHitCollection.at(i); - auto pCaloHit = &(pCaloHit0); + auto pCaloHit = const_cast<edm4hep::CalorimeterHit*>(&(pCaloHitCollection.at(i))); if (NULL == pCaloHit) throw ("CreateECalCaloHits pCaloHit Collection type mismatch"); @@ -395,7 +394,7 @@ 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 { - auto 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) @@ -431,8 +430,7 @@ pandora::StatusCode CaloHitCreator::CreateHCalCaloHits(const CollectionMaps& col { try { - auto pCaloHit0 = pCaloHitCollection.at(i); - auto pCaloHit = &(pCaloHit0); + auto pCaloHit = const_cast<edm4hep::CalorimeterHit*>(&(pCaloHitCollection.at(i))); if (NULL == pCaloHit) throw ("CreateHCalCaloHits Collection type mismatch"); @@ -520,7 +518,7 @@ 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 { - auto 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) @@ -558,8 +556,7 @@ pandora::StatusCode CaloHitCreator::CreateMuonCaloHits(const CollectionMaps& col { try { - auto pCaloHit0 = pCaloHitCollection.at(i); - auto pCaloHit = &(pCaloHit0); + auto pCaloHit = const_cast<edm4hep::CalorimeterHit*>(&(pCaloHitCollection.at(i))); if (NULL == pCaloHit) throw ("Muon Collection type mismatch"); @@ -661,7 +658,7 @@ 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 { - auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; + auto & pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; const int nElements(pCaloHitCollection.size()); if (0 == nElements) @@ -679,8 +676,7 @@ pandora::StatusCode CaloHitCreator::CreateLCalCaloHits(const CollectionMaps& col { try { - auto pCaloHit0 = pCaloHitCollection.at(i); - auto pCaloHit = &(pCaloHit0); + auto pCaloHit = const_cast<edm4hep::CalorimeterHit*>(&(pCaloHitCollection.at(i))); if (NULL == pCaloHit) throw ("LCal Collection type mismatch"); @@ -736,7 +732,7 @@ 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 { - auto pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; + auto & pCaloHitCollection = (collectionMaps.collectionMap_CaloHit.find(*iter))->second; const int nElements(pCaloHitCollection.size()); if (0 == nElements) @@ -753,8 +749,7 @@ pandora::StatusCode CaloHitCreator::CreateLHCalCaloHits(const CollectionMaps& co { try { - auto pCaloHit0 = pCaloHitCollection.at(i); - auto pCaloHit = &(pCaloHit0); + auto pCaloHit = const_cast<edm4hep::CalorimeterHit*>(&(pCaloHitCollection.at(i))); if (NULL == pCaloHit) throw ("LHCal Collection type mismatch"); diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp index ef457a7b4a0691bd0df5666d59709efa87272844..d4f46300670d94ba834712e8482aa680d1254777 100644 --- a/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp +++ b/Reconstruction/PFA/Pandora/GaudiPandora/src/MCParticleCreator.cpp @@ -41,20 +41,20 @@ pandora::StatusCode MCParticleCreator::CreateMCParticles(const CollectionMaps& c if(collectionMaps.collectionMap_MC.find(*iter) == collectionMaps.collectionMap_MC.end()) continue; try { - auto 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 { - auto 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(); - auto p_mc = &pMcParticle; + auto p_mc = const_cast<edm4hep::MCParticle*>(&pMcParticle); (*m_id_pMC_map) [p_id] = p_mc; mcParticleParameters.m_momentum = pandora::CartesianVector(pMcParticle.getMomentum()[0], pMcParticle.getMomentum()[1], pMcParticle.getMomentum()[2]); diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp b/Reconstruction/PFA/Pandora/GaudiPandora/src/TrackCreator.cpp index ae33a07c79a7bd768fb6dcd1dc6e26e5de11d49a..30044771e18d0146b15962fa2e633de49c94fda1 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 { - auto 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 { - auto pVertex0 = pKinkCollection.at(i); + 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; - auto pReconstructedParticle = pVertex->getAssociatedParticle(); + auto & pReconstructedParticle = pVertex->getAssociatedParticle(); if (this->IsConflictingRelationship(pReconstructedParticle))continue; const int vertexPdgCode(pReconstructedParticle.getType()); @@ -395,17 +395,17 @@ 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 { - auto 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 { - auto pVertex0 = pProngOrSplitCollection.at(i); + auto & pVertex0 = pProngOrSplitCollection.at(i); auto pVertex = &(pVertex0); if (NULL == pVertex) throw ("Collection type mismatch"); - const edm4hep::ReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle(); + const edm4hep::ReconstructedParticle & pReconstructedParticle = pVertex->getAssociatedParticle(); if (this->IsConflictingRelationship(pReconstructedParticle))continue; @@ -461,18 +461,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 { - auto 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 { - auto pVertex0 = pV0Collection.at(i); + auto & pVertex0 = pV0Collection.at(i); auto pVertex = &(pVertex0); if (NULL == pVertex) throw ("Collection type mismatch"); - const edm4hep::ReconstructedParticle pReconstructedParticle = pVertex->getAssociatedParticle(); + const edm4hep::ReconstructedParticle & pReconstructedParticle = pVertex->getAssociatedParticle(); if (this->IsConflictingRelationship(pReconstructedParticle))continue; @@ -552,11 +552,11 @@ edm4hep::Track* TrackCreator::GetTrackAddress(const CollectionMaps& collectionMa 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;} - auto 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) { - auto pTrack0 = pTrackCollection.at(i); - if (pTrack.id() == pTrack0.id()) return (&pTrack0); + auto & pTrack0 = pTrackCollection.at(i); + if (pTrack.id() == pTrack0.id()) return (const_cast<edm4hep::Track*>(&pTrack0)); } } return NULL; @@ -572,15 +572,14 @@ 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 { - auto 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 { - auto pTrack0 = pTrackCollection.at(i); - auto pTrack = (&pTrack0); + auto pTrack = const_cast<edm4hep::Track*>(&(pTrackCollection.at(i))); if (NULL == pTrack) throw ("Collection type mismatch"); if(m_settings.m_debug){