From 996c1537002226048fbbf13220af40701b212048 Mon Sep 17 00:00:00 2001 From: John Chapman <jchapman@cern.ch> Date: Wed, 8 Jul 2020 17:42:38 +0200 Subject: [PATCH] Migrate ISF_Core and ISF_Geant4 packages to use (Const)GenParticlePtr --- .../ISF_Event/ISF_Event/HepMCHelper.h | 2 +- .../ISF_Event/ISF_Event/HepMCHelper.icc | 4 +-- .../ISF_Event/ISF_Event/ISFTruthIncident.h | 14 +++++----- .../ISF_Event/ISF_Event/ITruthIncident.h | 10 +++---- .../ISF_Event/ISF_Event/ParticleHelper.h | 2 +- .../ISF_Event/ISF_Event/TruthBinding.h | 20 +++++++------- .../ISF_Event/ISF_Event/TruthBinding.icc | 16 ++++++------ .../ISF_Event/src/ISFTruthIncident.cxx | 20 +++++++------- .../ISF_Core/ISF_Event/src/ParticleHelper.cxx | 8 +++--- .../ISF_Services/src/InputConverter.cxx | 16 ++++++------ .../ISF_Services/src/InputConverter.h | 2 +- .../ISF_Core/ISF_Services/src/TruthSvc.cxx | 14 +++++----- .../ISF_Geant4Event/Geant4TruthIncident.h | 20 +++++++------- .../ISF_Geant4Event/ISFG4Helper.h | 2 +- .../src/Geant4TruthIncident.cxx | 26 +++++++++---------- .../ISF_Geant4Event/src/ISFG4Helper.cxx | 4 ++- .../src/PhysicsValidationUserAction.cxx | 4 +-- .../src/TrackProcessorUserActionBase.cxx | 16 ++++++------ .../src/TrackProcessorUserActionBase.h | 10 +++---- .../src/TrackProcessorUserActionPassBack.cxx | 16 ++++++------ .../src/TrackProcessorUserActionPassBack.h | 6 ++--- .../src/GenParticleGenericFilter.cxx | 2 +- .../src/GenParticlePositionFilter.cxx | 2 +- .../src/ConeSimSelector.cxx | 6 ++--- .../src/TruthAssocSimSelector.cxx | 8 +++--- 25 files changed, 126 insertions(+), 124 deletions(-) diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h index ca3491cdbf5..69ed5994ff6 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.h @@ -51,7 +51,7 @@ namespace ISF { at least one particle with one of the given PDG codes appears. returns pointer to first found particle that matches any of the given PDG codes in relativesPDG */ - static inline const HepMC::GenParticle * findRealtiveWithPDG( const HepMC::GenParticle &genParticle, + static inline HepMC::ConstGenParticlePtr findRealtiveWithPDG( const HepMC::GenParticle &genParticle, const HepMC::IteratorRange &relation, const std::set<int> &relativesPDG ); }; diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc index 9dc21beddaf..ba477d1d70c 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/HepMCHelper.icc @@ -29,7 +29,7 @@ HepMC::IteratorRange ISF::HepMCHelper::convertIteratorRange( int intItRange ) { else return ( HepMC::parents ); } -const HepMC::GenParticle * ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::GenParticle &genParticle, +HepMC::ConstGenParticlePtr ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::GenParticle &genParticle, const HepMC::IteratorRange &relation, const std::set<int> &relativesPDG ) { @@ -39,7 +39,7 @@ const HepMC::GenParticle * ISF::HepMCHelper::findRealtiveWithPDG( const HepMC::G // loop over relatives HepMC::GenVertex::particle_iterator partIt = relativesRng.begin(); const HepMC::GenVertex::particle_iterator partEnd = relativesRng.end(); - const HepMC::GenParticle *curRelative = 0; + HepMC::ConstGenParticlePtr curRelative{}; bool found = false; for ( ; (!found) && (partIt!=partEnd) ; ++partIt) { curRelative = (*partIt) ; diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h index c45ff5d3285..47b240cf900 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ISFTruthIncident.h @@ -67,7 +67,7 @@ namespace ISF { int parentPdgCode() const override final; /** Return the parent particle as a HepMC particle type (usually only called for particles that will enter the HepMC truth event) */ - HepMC::GenParticle* parentParticle() const override final; + HepMC::GenParticlePtr parentParticle() const override final; /** Return the barcode of the parent particle */ Barcode::ParticleBarcode parentBarcode() const override final; /** Return the bunch-crossing identifier of the parent particle */ @@ -76,7 +76,7 @@ namespace ISF { bool parentSurvivesIncident() const override final; /** Return the parent particle after the TruthIncident vertex (and give it a new barcode) */ - HepMC::GenParticle* parentParticleAfterIncident(Barcode::ParticleBarcode newBC) override final; + HepMC::GenParticlePtr parentParticleAfterIncident(Barcode::ParticleBarcode newBC) override final; /** Return p^2 of the i-th child particle */ double childP2(unsigned short index) const override final; @@ -89,24 +89,24 @@ namespace ISF { /** Return the i-th child as a HepMC particle type and assign the given Barcode to the simulator particle (usually only called for particles that will enter the HepMC truth event) */ - HepMC::GenParticle* childParticle(unsigned short index, + HepMC::GenParticlePtr childParticle(unsigned short index, Barcode::ParticleBarcode bc) const override final; /** Update the properties of a child particle from a pre-defined interaction based on the properties of the ith child of the current TruthIncident (only used in quasi-stable particle simulation) - TODO only a dummy implementation currently */ - virtual HepMC::GenParticle* updateChildParticle(unsigned short index, - HepMC::GenParticle *existingChild) const override final; + virtual HepMC::GenParticlePtr updateChildParticle(unsigned short index, + HepMC::GenParticlePtr existingChild) const override final; /** Set the the barcode of all child particles to the given bc */ void setAllChildrenBarcodes(Barcode::ParticleBarcode bc) override final; private: ISFTruthIncident(); /** return attached truth particle */ - inline HepMC::GenParticle* getHepMCTruthParticle( const ISF::ISFParticle& particle ) const; + inline HepMC::GenParticlePtr getHepMCTruthParticle( const ISF::ISFParticle& particle ) const; /** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */ - inline HepMC::GenParticle* updateHepMCTruthParticle( ISF::ISFParticle& particle, const ISF::ISFParticle* parent=nullptr ) const; + inline HepMC::GenParticlePtr updateHepMCTruthParticle( ISF::ISFParticle& particle, const ISF::ISFParticle* parent=nullptr ) const; ISF::ISFParticle& m_parent; const ISFParticleVector& m_children; diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h index 3882f1d43cc..843d0645c6f 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ITruthIncident.h @@ -74,7 +74,7 @@ namespace ISF { virtual int parentPdgCode() const = 0; /** Return the parent particle as a HepMC particle type (only called for particles that will enter the HepMC truth event) */ - virtual HepMC::GenParticle* parentParticle() const = 0; + virtual HepMC::GenParticlePtr parentParticle() const = 0; /** Return the barcode of the parent particle */ virtual Barcode::ParticleBarcode parentBarcode() const = 0; /** Return the bunch-crossing identifier of the parent particle */ @@ -83,7 +83,7 @@ namespace ISF { virtual bool parentSurvivesIncident() const = 0; /** Return the parent particle after the TruthIncident vertex (and assign a new barcode to it) */ - virtual HepMC::GenParticle* parentParticleAfterIncident(Barcode::ParticleBarcode newBC) = 0; + virtual HepMC::GenParticlePtr parentParticleAfterIncident(Barcode::ParticleBarcode newBC) = 0; /** Return total number of child particles */ inline unsigned short numberOfChildren() const; @@ -107,14 +107,14 @@ namespace ISF { /** Return the i-th child as a HepMC particle type and assign the given Barcode to the simulator particle (only called for particles that will enter the HepMC truth event) */ - virtual HepMC::GenParticle* childParticle(unsigned short index, + virtual HepMC::GenParticlePtr childParticle(unsigned short index, Barcode::ParticleBarcode bc = Barcode::fUndefinedBarcode) const = 0; /** Update the properties of a child particle from a pre-defined interaction based on the properties of the ith child of the current TruthIncident (only used in quasi-stable particle simulation). */ - virtual HepMC::GenParticle* updateChildParticle(unsigned short index, - HepMC::GenParticle *existingChild) const = 0; + virtual HepMC::GenParticlePtr updateChildParticle(unsigned short index, + HepMC::GenParticlePtr existingChild) const = 0; /** Set the the barcode of all child particles to the given bc */ virtual void setAllChildrenBarcodes(Barcode::ParticleBarcode bc) = 0; diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ParticleHelper.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ParticleHelper.h index 48072b67b79..65e471791f2 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ParticleHelper.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/ParticleHelper.h @@ -35,7 +35,7 @@ namespace ISF { ~ParticleHelper() {} ; /** convert the given particle to HepMC format */ - static HepMC::GenParticle *convert( const ISF::ISFParticle &p); + static HepMC::GenParticlePtr convert( const ISF::ISFParticle &p); private : }; diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.h b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.h index 599779d3571..e5352b5c7fa 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.h +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.h @@ -25,9 +25,9 @@ namespace ISF { TruthBinding() = delete; /** constructor setting all truth particle pointers to the given particle */ - inline TruthBinding(HepMC::GenParticle* allTruthP); + inline TruthBinding(HepMC::GenParticlePtr allTruthP); /** constructor setting all truth particle pointers individually */ - inline TruthBinding(HepMC::GenParticle* truthP, HepMC::GenParticle* primaryTruthP, HepMC::GenParticle* genZeroTruthP); + inline TruthBinding(HepMC::GenParticlePtr truthP, HepMC::GenParticlePtr primaryTruthP, HepMC::GenParticlePtr genZeroTruthP); /** copy constructors */ inline TruthBinding(const TruthBinding &rhs); @@ -46,20 +46,20 @@ namespace ISF { inline ~TruthBinding(); /** pointer to the particle in the simulation truth */ - inline HepMC::GenParticle* getTruthParticle() const; - inline void setTruthParticle(HepMC::GenParticle* p); + inline HepMC::GenParticlePtr getTruthParticle() const; + inline void setTruthParticle(HepMC::GenParticlePtr p); /** pointer to the primary particle in the simulation truth */ - inline HepMC::GenParticle* getPrimaryTruthParticle() const; + inline HepMC::GenParticlePtr getPrimaryTruthParticle() const; /** pointer to the simulation truth particle before any regeneration happened (eg. brem) */ - inline HepMC::GenParticle* getGenerationZeroTruthParticle() const; - inline void setGenerationZeroTruthParticle(HepMC::GenParticle* p); + inline HepMC::GenParticlePtr getGenerationZeroTruthParticle() const; + inline void setGenerationZeroTruthParticle(HepMC::GenParticlePtr p); private: - HepMC::GenParticle* m_truthParticle; //!< pointer to particle in MC truth - HepMC::GenParticle* m_primaryTruthParticle; //!< pointer to corresponding primary (generator) particle - HepMC::GenParticle* m_generationZeroTruthParticle; //!< pointer to corresponding truth particle before any regenration + HepMC::GenParticlePtr m_truthParticle{}; //!< pointer to particle in MC truth + HepMC::GenParticlePtr m_primaryTruthParticle{}; //!< pointer to corresponding primary (generator) particle + HepMC::GenParticlePtr m_generationZeroTruthParticle{}; //!< pointer to corresponding truth particle before any regenration }; } // end of namespace diff --git a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc index b97272c450b..91c73a6f98b 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc +++ b/Simulation/ISF/ISF_Core/ISF_Event/ISF_Event/TruthBinding.icc @@ -1,18 +1,18 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // this file contains all ITruthBinding inline methods namespace ISF { /** constructor setting all truth particle pointers to the given particle */ - TruthBinding::TruthBinding(HepMC::GenParticle* allTruthP) : + TruthBinding::TruthBinding(HepMC::GenParticlePtr allTruthP) : m_truthParticle(allTruthP), m_primaryTruthParticle(allTruthP), m_generationZeroTruthParticle(allTruthP) { } /** constructor setting all truth particle pointers individually */ - TruthBinding::TruthBinding(HepMC::GenParticle* truthP, HepMC::GenParticle* primaryTruthP, HepMC::GenParticle* genZeroTruthP) : + TruthBinding::TruthBinding(HepMC::GenParticlePtr truthP, HepMC::GenParticlePtr primaryTruthP, HepMC::GenParticlePtr genZeroTruthP) : m_truthParticle(truthP), m_primaryTruthParticle(primaryTruthP), m_generationZeroTruthParticle(genZeroTruthP) { } @@ -91,14 +91,14 @@ namespace ISF { } /** pointer to the particle in the simulation truth */ - HepMC::GenParticle* TruthBinding::getTruthParticle() const { return m_truthParticle; } - void TruthBinding::setTruthParticle(HepMC::GenParticle* p) { m_truthParticle = p; } + HepMC::GenParticlePtr TruthBinding::getTruthParticle() const { return m_truthParticle; } + void TruthBinding::setTruthParticle(HepMC::GenParticlePtr p) { m_truthParticle = p; } /** pointer to the primary particle in the simulation truth */ - HepMC::GenParticle* TruthBinding::getPrimaryTruthParticle() const { return m_primaryTruthParticle; } + HepMC::GenParticlePtr TruthBinding::getPrimaryTruthParticle() const { return m_primaryTruthParticle; } /** pointer to the simulation truth particle before any regeneration (eg. brem) */ - HepMC::GenParticle* TruthBinding::getGenerationZeroTruthParticle() const { return m_generationZeroTruthParticle; } - void TruthBinding::setGenerationZeroTruthParticle(HepMC::GenParticle* p) { m_generationZeroTruthParticle = p; } + HepMC::GenParticlePtr TruthBinding::getGenerationZeroTruthParticle() const { return m_generationZeroTruthParticle; } + void TruthBinding::setGenerationZeroTruthParticle(HepMC::GenParticlePtr p) { m_generationZeroTruthParticle = p; } } // end ISF namespace diff --git a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx index e91de330fe4..4c8aa3f2b17 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Event/src/ISFTruthIncident.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -77,7 +77,7 @@ int ISF::ISFTruthIncident::parentPdgCode() const { return m_parent.pdgCode(); } -HepMC::GenParticle* ISF::ISFTruthIncident::parentParticle() const { +HepMC::GenParticlePtr ISF::ISFTruthIncident::parentParticle() const { if ( m_parent.getTruthBinding() || m_parent.getParticleLink()) { return getHepMCTruthParticle(m_parent); } else { @@ -97,7 +97,7 @@ bool ISF::ISFTruthIncident::parentSurvivesIncident() const { return !(m_killsPrimary == ISF::fKillsPrimary); } -HepMC::GenParticle* ISF::ISFTruthIncident::parentParticleAfterIncident(Barcode::ParticleBarcode newBC) { +HepMC::GenParticlePtr ISF::ISFTruthIncident::parentParticleAfterIncident(Barcode::ParticleBarcode newBC) { // if parent is killed in the interaction -> return nullptr if (m_killsPrimary==ISF::fKillsPrimary) return nullptr; @@ -127,7 +127,7 @@ int ISF::ISFTruthIncident::childPdgCode(unsigned short index) const { return m_children[index]->pdgCode(); } -HepMC::GenParticle* ISF::ISFTruthIncident::childParticle(unsigned short index, +HepMC::GenParticlePtr ISF::ISFTruthIncident::childParticle(unsigned short index, Barcode::ParticleBarcode bc) const { // the child particle ISF::ISFParticle *sec = m_children[index]; @@ -141,8 +141,8 @@ HepMC::GenParticle* ISF::ISFTruthIncident::childParticle(unsigned short index, return updateHepMCTruthParticle( *sec, &m_parent ); } -HepMC::GenParticle* ISF::ISFTruthIncident::updateChildParticle(unsigned short /*index*/, - HepMC::GenParticle *existingChild) const { +HepMC::GenParticlePtr ISF::ISFTruthIncident::updateChildParticle(unsigned short /*index*/, + HepMC::GenParticlePtr existingChild) const { // Dummy implementation return existingChild; } @@ -162,7 +162,7 @@ void ISF::ISFTruthIncident::setAllChildrenBarcodes(Barcode::ParticleBarcode bc) /** return attached truth particle */ -HepMC::GenParticle* ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISFParticle& particle ) const { +HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISFParticle& particle ) const { auto* truthBinding = particle.getTruthBinding(); auto* hepTruthParticle = truthBinding ? truthBinding->getTruthParticle() : nullptr; @@ -170,7 +170,7 @@ HepMC::GenParticle* ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISF if (!hepTruthParticle) { const HepMcParticleLink* oldHMPL = particle.getParticleLink(); if (oldHMPL && oldHMPL->cptr()) - hepTruthParticle = const_cast<HepMC::GenParticle*>(oldHMPL->cptr()); + hepTruthParticle = const_cast<HepMC::GenParticlePtr>(oldHMPL->cptr()); } return hepTruthParticle; @@ -178,8 +178,8 @@ HepMC::GenParticle* ISF::ISFTruthIncident::getHepMCTruthParticle( const ISF::ISF /** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */ -HepMC::GenParticle* ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle, - const ISF::ISFParticle* parent ) const { +HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle, + const ISF::ISFParticle* parent ) const { auto* truthBinding = particle.getTruthBinding(); auto* hepTruthParticle = ParticleHelper::convert( particle ); diff --git a/Simulation/ISF/ISF_Core/ISF_Event/src/ParticleHelper.cxx b/Simulation/ISF/ISF_Core/ISF_Event/src/ParticleHelper.cxx index c8de9a6e0bd..e9326b860d8 100644 --- a/Simulation/ISF/ISF_Core/ISF_Event/src/ParticleHelper.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Event/src/ParticleHelper.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -17,7 +17,7 @@ // ISF includes #include "ISF_Event/ISFParticle.h" -HepMC::GenParticle* ISF::ParticleHelper::convert( const ISF::ISFParticle &particle) { +HepMC::GenParticlePtr ISF::ParticleHelper::convert( const ISF::ISFParticle &particle) { const Amg::Vector3D &mom = particle.momentum(); double mass = particle.mass(); @@ -25,8 +25,8 @@ HepMC::GenParticle* ISF::ParticleHelper::convert( const ISF::ISFParticle &partic HepMC::FourVector fourMomentum( mom.x(), mom.y(), mom.z(), energy); int status = 1; // stable particle not decayed by EventGenerator - auto* hepParticle = new HepMC::GenParticle( fourMomentum, particle.pdgCode(), status ); - hepParticle->suggest_barcode( particle.barcode() ); + auto hepParticle = HepMC::newGenParticlePtr( fourMomentum, particle.pdgCode(), status ); + HepMC::suggest_barcode(hepParticle, particle.barcode() ); // return a newly created GenParticle return hepParticle; diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx index a012c1c5c77..73e32314923 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.cxx @@ -187,13 +187,13 @@ StatusCode ISF::InputConverter::convertHepMCToG4Event(McEventCollection& inputGe /** get all generator particles which pass filters */ -std::vector<HepMC::GenParticle*> +std::vector<HepMC::GenParticlePtr> ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool legacyOrdering) const { auto allGenPartBegin = evnt.particles_begin(); auto allGenPartEnd = evnt.particles_end(); // reserve destination container with maximum size, i.e. number of particles in input event - std::vector<HepMC::GenParticle*> passedGenParticles{}; + std::vector<HepMC::GenParticlePtr> passedGenParticles{}; size_t maxParticles = std::distance(allGenPartBegin, allGenPartEnd); passedGenParticles.reserve(maxParticles); @@ -207,14 +207,14 @@ ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool lega std::copy_if(vtxPtr->particles_begin(HepMC::children), vtxPtr->particles_end(HepMC::children), std::back_inserter(passedGenParticles), - [this](HepMC::GenParticle* p){return this->passesFilters(*p);}); + [this](HepMC::GenParticlePtr p){return this->passesFilters(*p);}); } } else { std::copy_if(allGenPartBegin, allGenPartEnd, std::back_inserter(passedGenParticles), - [this](HepMC::GenParticle* p){return this->passesFilters(*p);}); + [this](HepMC::GenParticlePtr p){return this->passesFilters(*p);}); } passedGenParticles.shrink_to_fit(); @@ -225,7 +225,7 @@ ISF::InputConverter::getSelectedParticles(const HepMC::GenEvent& evnt, bool lega /** get all generator particles which pass filters */ ISF::ISFParticle* -ISF::InputConverter::convertParticle(HepMC::GenParticle* genPartPtr, EBC_EVCOLL kindOfCollection) const { +ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOLL kindOfCollection) const { if (!genPartPtr) { return nullptr; } auto& genPart = *genPartPtr; @@ -483,8 +483,8 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const ISF::ISFParti G4Exception("iGeant4::TransportTool", "NoISFTruthBinding", FatalException, description); return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up. } - HepMC::GenParticle* genpart = truthBinding->getTruthParticle(); - HepMC::GenParticle* primaryGenpart = truthBinding->getPrimaryTruthParticle(); + HepMC::GenParticlePtr genpart = truthBinding->getTruthParticle(); + HepMC::GenParticlePtr primaryGenpart = truthBinding->getPrimaryTruthParticle(); const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(isp.pdgCode()); @@ -595,7 +595,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const ISF::ISFParti //For backward compatibility, if all 3-momentum components agree to the g4particle momentum within 1 keV, we keep //this old method. This comparison is needed, since in ISF this code could be rerun after the ID or CALO simulation, where //real energy was lost in previous detectors and hence genpart should NOT be changed to some g4particle values! - //TODO: find a way to implement this in a backward compatible way in ISF::InputConverter::convertParticle(HepMC::GenParticle* genPartPtr, int bcid) + //TODO: find a way to implement this in a backward compatible way in ISF::InputConverter::convertParticle(HepMC::GenParticlePtr genPartPtr, int bcid) if(std::abs(px-g4px)<CLHEP::keV && std::abs(py-g4py)<CLHEP::keV && std::abs(pz-g4pz)<CLHEP::keV) { px=g4px; py=g4py; diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h index 6e15cc8ee06..59b42820c37 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/InputConverter.h @@ -102,7 +102,7 @@ namespace ISF { bool passesFilters(const HepMC::GenParticle& p) const; /** convert GenParticle to ISFParticle */ - ISF::ISFParticle* convertParticle(HepMC::GenParticle* genPartPtr, EBC_EVCOLL kindOfCollection=EBC_MAINEVCOLL) const; + ISF::ISFParticle* convertParticle(HepMC::GenParticlePtr genPartPtr, EBC_EVCOLL kindOfCollection=EBC_MAINEVCOLL) const; /** ParticlePropertyService and ParticleDataTable */ ServiceHandle<IPartPropSvc> m_particlePropSvc; //!< particle properties svc to retrieve PDT diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx index 4814b463352..f793776e574 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/TruthSvc.cxx @@ -132,12 +132,12 @@ StatusCode ISF::TruthSvc::initializeTruthCollection() } /** Delete child vertex */ -void ISF::TruthSvc::deleteChildVertex(HepMC::GenVertex* vertex) const { - std::vector<HepMC::GenVertex*> verticesToDelete; +void ISF::TruthSvc::deleteChildVertex(HepMC::GenVertexPtr vertex) const { + std::vector<HepMC::GenVertexPtr> verticesToDelete; verticesToDelete.resize(0); verticesToDelete.push_back(vertex); for ( unsigned short i = 0; i<verticesToDelete.size(); ++i ) { - HepMC::GenVertex* vtx = verticesToDelete.at(i); + HepMC::GenVertexPtr vtx = verticesToDelete.at(i); for (HepMC::GenVertex::particles_out_const_iterator iter = vtx->particles_out_const_begin(); iter != vtx->particles_out_const_end(); ++iter) { if( (*iter) && (*iter)->end_vertex() ) { @@ -292,7 +292,7 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const { ATH_MSG_INFO("New QS GenVertex 1: " << *(newVtx.get()) ); #endif HepMC::GenEvent *mcEvent = parentBeforeIncident->parent_event(); - newVtx->suggest_barcode( this->maxGeneratedVertexBarcode(mcEvent)-1 ); + HepMC::suggest_barcode(newVtx.get(), this->maxGeneratedVertexBarcode(mcEvent)-1 ); #ifdef DEBUG_TRUTHSVC ATH_MSG_INFO("New QSGenVertex 2: " << *(newVtx.get()) ); #endif @@ -332,8 +332,8 @@ void ISF::TruthSvc::recordIncidentToMCTruth( ISF::ITruthIncident& ti) const { ATH_MSG_VERBOSE("Existing vertex has " << nVertexChildren << " children. " << "Number of secondaries in current truth incident = " << numSec); } - const std::vector<HepMC::GenParticle*> childParticleVector = (isQuasiStableVertex) ? MC::findChildren(ti.parentParticle()) : std::vector<HepMC::GenParticle*>(); - std::vector<HepMC::GenParticle*> matchedChildParticles; + const std::vector<HepMC::GenParticlePtr> childParticleVector = (isQuasiStableVertex) ? MC::findChildren(ti.parentParticle()) : std::vector<HepMC::GenParticlePtr>(); + std::vector<HepMC::GenParticlePtr> matchedChildParticles; for ( unsigned short i=0; i<numSec; ++i) { bool writeOutChild = isQuasiStableVertex || m_passWholeVertex || ti.childPassedFilters(i); @@ -430,7 +430,7 @@ HepMC::GenVertex *ISF::TruthSvc::createGenVertexFromTruthIncident( ISF::ITruthIn } int vtxID = 1000 + static_cast<int>(processCode); std::unique_ptr<HepMC::GenVertex> vtx = std::make_unique<HepMC::GenVertex>( ti.position(), vtxID, weights ); - vtx->suggest_barcode( vtxbcode ); + HepMC::suggest_barcode( vtx.get(), vtxbcode ); if (parent->end_vertex()){ if(!m_quasiStableParticlesIncluded) { diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h index 27693a6dfd2..d4770981320 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/Geant4TruthIncident.h @@ -68,7 +68,7 @@ namespace iGeant4 { bool parentSurvivesIncident() const override final; /** Return the parent particle after the TruthIncident vertex (and give it a new barcode) */ - HepMC::GenParticle* parentParticleAfterIncident(Barcode::ParticleBarcode newBC) override final; + HepMC::GenParticlePtr parentParticleAfterIncident(Barcode::ParticleBarcode newBC) override final; /** Return p of the i-th child particle */ const G4ThreeVector childP(unsigned short index) const; @@ -95,17 +95,17 @@ namespace iGeant4 { // only called once accepted /** Return the parent particle as a HepMC particle type */ - HepMC::GenParticle* parentParticle() const override final; + HepMC::GenParticlePtr parentParticle() const override final; /** Return the i-th child as a HepMC particle type and assign the given Barcode to the simulator particle */ - HepMC::GenParticle* childParticle(unsigned short index, - Barcode::ParticleBarcode bc) const override final; + HepMC::GenParticlePtr childParticle(unsigned short index, + Barcode::ParticleBarcode bc) const override final; /** Update the properties of a child particle from a pre-defined interaction based on the properties of the ith child of the current TruthIncident (only used in quasi-stable particle simulation). */ - HepMC::GenParticle* updateChildParticle(unsigned short index, - HepMC::GenParticle *existingChild) const override final; + HepMC::GenParticlePtr updateChildParticle(unsigned short index, + HepMC::GenParticlePtr existingChild) const override final; private: Geant4TruthIncident(); /** prepare the child particles */ @@ -114,18 +114,18 @@ namespace iGeant4 { /** check if the given G4Track represents a particle that is alive in ISF or ISF-G4 */ inline bool particleAlive(const G4Track *track) const; - HepMC::GenParticle* convert(const G4Track *particle, const int barcode, const bool secondary) const; //*AS* might be put static + HepMC::GenParticlePtr convert(const G4Track *particle, const int barcode, const bool secondary) const; //*AS* might be put static mutable bool m_positionSet; mutable HepMC::FourVector m_position; - const G4Step* m_step; + const G4Step* m_step{}; const ISF::ISFParticle& m_baseISP; - EventInformation* m_eventInfo; + EventInformation* m_eventInfo{}; mutable bool m_childrenPrepared; mutable std::vector<const G4Track*> m_children; - HepMC::GenParticle* m_parentParticleAfterIncident; + HepMC::GenParticlePtr m_parentParticleAfterIncident{}; }; } diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/ISFG4Helper.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/ISFG4Helper.h index 443734dee6a..2cae499ed00 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/ISFG4Helper.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/ISF_Geant4Event/ISFG4Helper.h @@ -49,7 +49,7 @@ class ISFG4Helper { static TrackInformation* attachTrackInfoToNewG4Track( G4Track& aTrack, const ISF::ISFParticle& baseIsp, TrackClassification classification, - HepMC::GenParticle *nonRegeneratedTruthParticle = nullptr); + HepMC::GenParticlePtr nonRegeneratedTruthParticle = nullptr); /** return pointer to current EventInformation */ static EventInformation* getEventInformation(); diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx index 4e47e2f8ed4..e6593e152ed 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/Geant4TruthIncident.cxx @@ -121,11 +121,11 @@ int iGeant4::Geant4TruthIncident::parentPdgCode() const { Barcode::ParticleBarcode iGeant4::Geant4TruthIncident::parentBarcode() const { auto parent = parentParticle(); - return (parent) ? parent->barcode() : Barcode::fUndefinedBarcode; + return (parent) ? HepMC::barcode(parent) : Barcode::fUndefinedBarcode; } -HepMC::GenParticle* iGeant4::Geant4TruthIncident::parentParticle() const { - HepMC::GenParticle* hepParticle = m_eventInfo->GetCurrentlyTraced(); +HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::parentParticle() const { + HepMC::GenParticlePtr hepParticle = m_eventInfo->GetCurrentlyTraced(); return hepParticle; } @@ -146,7 +146,7 @@ bool iGeant4::Geant4TruthIncident::parentSurvivesIncident() const { } } -HepMC::GenParticle* iGeant4::Geant4TruthIncident::parentParticleAfterIncident(Barcode::ParticleBarcode newBarcode) { +HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::parentParticleAfterIncident(Barcode::ParticleBarcode newBarcode) { const G4Track *track = m_step->GetTrack(); // check if particle is a alive in G4 or in ISF @@ -219,8 +219,8 @@ void iGeant4::Geant4TruthIncident::setAllChildrenBarcodes(Barcode::ParticleBarco G4Exception("iGeant4::Geant4TruthIncident", "NotImplemented", FatalException, description); } -HepMC::GenParticle* iGeant4::Geant4TruthIncident::childParticle(unsigned short i, - Barcode::ParticleBarcode newBarcode) const { +HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::childParticle(unsigned short i, + Barcode::ParticleBarcode newBarcode) const { prepareChildren(); // the G4Track instance for the current child particle @@ -230,7 +230,7 @@ HepMC::GenParticle* iGeant4::Geant4TruthIncident::childParticle(unsigned short i // secondary could decay right away and create further particles which pass the // truth strategies. - HepMC::GenParticle* hepParticle = convert( thisChildTrack , newBarcode , true ); + HepMC::GenParticlePtr hepParticle = convert( thisChildTrack , newBarcode , true ); TrackHelper tHelper(thisChildTrack); TrackInformation *trackInfo = tHelper.GetTrackInformation(); @@ -249,8 +249,8 @@ HepMC::GenParticle* iGeant4::Geant4TruthIncident::childParticle(unsigned short i } -HepMC::GenParticle* iGeant4::Geant4TruthIncident::updateChildParticle(unsigned short index, - HepMC::GenParticle *existingChild) const { +HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::updateChildParticle(unsigned short index, + HepMC::GenParticlePtr existingChild) const { prepareChildren(); // the G4Track instance for the current child particle @@ -310,7 +310,7 @@ bool iGeant4::Geant4TruthIncident::particleAlive(const G4Track *track) const { } -HepMC::GenParticle* iGeant4::Geant4TruthIncident::convert(const G4Track *track, const int barcode, const bool secondary) const { +HepMC::GenParticlePtr iGeant4::Geant4TruthIncident::convert(const G4Track *track, const int barcode, const bool secondary) const { const G4ThreeVector & mom = track->GetMomentum(); const double energy = track->GetTotalEnergy(); @@ -318,7 +318,7 @@ HepMC::GenParticle* iGeant4::Geant4TruthIncident::convert(const G4Track *track, const HepMC::FourVector fourMomentum( mom.x(), mom.y(), mom.z(), energy); const int status = 1; // stable particle not decayed by EventGenerator - HepMC::GenParticle* newParticle = new HepMC::GenParticle(fourMomentum, pdgCode, status); + HepMC::GenParticlePtr newParticle = HepMC::newGenParticlePtr(fourMomentum, pdgCode, status); // This should be a *secondary* track. If it has a primary, it was a decay and // we are running with quasi-stable particle simulation. Note that if the primary @@ -330,9 +330,9 @@ HepMC::GenParticle* iGeant4::Geant4TruthIncident::convert(const G4Track *track, track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation()){ // Then the new particle should use the same barcode as the old one!! PrimaryParticleInformation* ppi = dynamic_cast<PrimaryParticleInformation*>( track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation() ); - newParticle->suggest_barcode( ppi->GetParticleBarcode() ); + HepMC::suggest_barcode( newParticle, ppi->GetParticleBarcode() ); } else { - newParticle->suggest_barcode( barcode ); + HepMC::suggest_barcode( newParticle, barcode ); } return newParticle; diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx index 004621c581a..3858d74020f 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Event/src/ISFG4Helper.cxx @@ -11,6 +11,8 @@ #include "G4EventManager.hh" #include "G4Event.hh" +#include "AtlasHepMC/GenParticle.h" + // G4Atlas includes #include "MCTruth/EventInformation.h" #include "MCTruth/TrackBarcodeInfo.h" @@ -73,7 +75,7 @@ TrackInformation* iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( G4Track& aTrack, const ISF::ISFParticle& baseIsp, TrackClassification classification, - HepMC::GenParticle *nonRegeneratedTruthParticle) + HepMC::GenParticlePtr nonRegeneratedTruthParticle) { if ( aTrack.GetUserInformation() ) { G4ExceptionDescription description; diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx index 76e11714b46..b845ede14de 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/PhysicsValidationUserAction.cxx @@ -239,14 +239,14 @@ namespace G4UA{ m_scIn = creation? creation->GetProcessSubType() : -1; VTrackInformation * trackInfo= static_cast<VTrackInformation*>(track->GetUserInformation()); - HepMC::GenParticle* genpart= trackInfo ? const_cast<HepMC::GenParticle*>(trackInfo->GetHepMCParticle()):0; + HepMC::GenParticlePtr genpart= trackInfo ? const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle()):0; HepMC::GenVertex* vtx = genpart ? genpart->production_vertex() : 0; m_gen = genpart? 0 : -1; if (genpart) { // mc truth known while (genpart && vtx ) { int pdgID=genpart->pdg_id(); - HepMC::GenParticle* genmom = vtx->particles_in_size()>0 ? *(vtx->particles_in_const_begin()) : 0; + HepMC::GenParticlePtr genmom = vtx->particles_in_size()>0 ? *(vtx->particles_in_const_begin()) : 0; if ( genmom && pdgID!=genmom->pdg_id() ) m_gen++; else if (vtx->particles_out_size()>0 && genpart!=*(vtx->particles_out_const_begin())) m_gen++; vtx = genmom ? genmom->production_vertex() : 0; diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx index 3bdb378bcb9..b69bec16eb8 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.cxx @@ -93,7 +93,7 @@ void TrackProcessorUserActionBase::UserSteppingAction(const G4Step* aStep) // G4Tracks aready returned to ISF will have a TrackInformation attached to them bool particleReturnedToISF = trackInfo && trackInfo->GetReturnedToISF(); if (!particleReturnedToISF) { - HepMC::GenParticle* generationZeroTruthParticle = nullptr; + HepMC::GenParticlePtr generationZeroTruthParticle{}; ::iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( *aSecondaryTrack, *m_curBaseISP, Secondary, @@ -191,8 +191,8 @@ void TrackProcessorUserActionBase::setupSecondary(const G4Track& aTrack) auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack); // why does TrackInformation return *const* GenParticle and ISFParticle objects!? - auto* currentlyTracedTruthParticle = const_cast<HepMC::GenParticle*>( trackInfo->GetHepMCParticle() ); - auto* primaryTruthParticle = const_cast<HepMC::GenParticle*>( trackInfo->GetPrimaryHepMCParticle() ); + HepMC::GenParticlePtr currentlyTracedTruthParticle = const_cast<HepMC::GenParticlePtr>( trackInfo->GetHepMCParticle() ); + HepMC::GenParticlePtr primaryTruthParticle = const_cast<HepMC::GenParticlePtr>( trackInfo->GetPrimaryHepMCParticle() ); auto* baseISFParticle = const_cast<ISF::ISFParticle*>( trackInfo->GetBaseISFParticle() ); setCurrentParticle(baseISFParticle, primaryTruthParticle, currentlyTracedTruthParticle); @@ -200,8 +200,8 @@ void TrackProcessorUserActionBase::setupSecondary(const G4Track& aTrack) } void TrackProcessorUserActionBase::setCurrentParticle(ISF::ISFParticle* baseISFParticle, - HepMC::GenParticle* truthPrimary, - HepMC::GenParticle* truthCurrentlyTraced) + HepMC::GenParticlePtr truthPrimary, + HepMC::GenParticlePtr truthCurrentlyTraced) { m_curBaseISP = baseISFParticle; m_eventInfo->SetCurrentPrimary( truthPrimary ); @@ -210,9 +210,9 @@ void TrackProcessorUserActionBase::setCurrentParticle(ISF::ISFParticle* baseISFP } /// Classify the particle represented by the given set of truth links -TrackClassification TrackProcessorUserActionBase::classify(const HepMC::GenParticle* primaryTruthParticle, - const HepMC::GenParticle* generationZeroTruthParticle, - const HepMC::GenParticle* currentlyTracedHepPart, +TrackClassification TrackProcessorUserActionBase::classify(HepMC::ConstGenParticlePtr primaryTruthParticle, + HepMC::ConstGenParticlePtr generationZeroTruthParticle, + HepMC::ConstGenParticlePtr currentlyTracedHepPart, int regenerationNumber) const { // if particle points to a non-zero truth particle it can not just be a 'simple' Secondary diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.h index c863ecf5238..e5b215a3826 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionBase.h @@ -64,13 +64,13 @@ private: /// Set the following information as the currently traced particle void setCurrentParticle(ISF::ISFParticle* baseISFParticle, - HepMC::GenParticle* truthPrimary, - HepMC::GenParticle* truthCurrentlyTraced); + HepMC::GenParticlePtr truthPrimary, + HepMC::GenParticlePtr truthCurrentlyTraced); /// Classify the particle represented by the given set of truth links - TrackClassification classify(const HepMC::GenParticle* primaryTruthParticle, - const HepMC::GenParticle* generationZeroTruthParticle, - const HepMC::GenParticle* currentlyTracedHepPart, + TrackClassification classify(HepMC::ConstGenParticlePtr primaryTruthParticle, + HepMC::ConstGenParticlePtr generationZeroTruthParticle, + HepMC::ConstGenParticlePtr currentlyTracedHepPart, int regenerationNumber) const; /// The most recent ISFParticle ancestor that triggers the currently processed G4Track diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx index 4495398c580..cb2774d2004 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.cxx @@ -175,7 +175,7 @@ namespace G4UA { // " and is returned to ISF."); const ISF::ISFParticle* parent = curISP; - HepMC::GenParticle* truthParticle = m_eventInfo->GetCurrentlyTraced(); + HepMC::GenParticlePtr truthParticle = m_eventInfo->GetCurrentlyTraced(); this->returnParticleToISF(aTrack, parent, truthParticle, nextGeoID); } @@ -214,13 +214,13 @@ namespace G4UA { // attach TrackInformation instance to the new secondary G4Track const ISF::ISFParticle *parent = curISP; - HepMC::GenParticle* generationZeroTruthParticle = nullptr; + HepMC::GenParticlePtr generationZeroTruthParticle = nullptr; ::iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( *aTrack_2nd, *parent, Secondary, generationZeroTruthParticle ); - HepMC::GenParticle* truthParticle = nullptr; + HepMC::GenParticlePtr truthParticle{}; returnParticleToISF(aTrack_2nd, parent, truthParticle, nextGeoID_2nd); } } @@ -230,7 +230,7 @@ namespace G4UA { return; } - ISF::TruthBinding* TrackProcessorUserActionPassBack::newTruthBinding(const G4Track* aTrack, HepMC::GenParticle* truthParticle) const + ISF::TruthBinding* TrackProcessorUserActionPassBack::newTruthBinding(const G4Track* aTrack, HepMC::GenParticlePtr truthParticle) const { auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(*aTrack); if (!trackInfo) { @@ -242,8 +242,8 @@ namespace G4UA { return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up. } - HepMC::GenParticle* primaryHepParticle = const_cast<HepMC::GenParticle*>(trackInfo->GetPrimaryHepMCParticle()); - HepMC::GenParticle* generationZeroHepParticle = const_cast<HepMC::GenParticle*>(trackInfo->GetHepMCParticle()); + HepMC::GenParticlePtr primaryHepParticle = const_cast<HepMC::GenParticlePtr>(trackInfo->GetPrimaryHepMCParticle()); + HepMC::GenParticlePtr generationZeroHepParticle = const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle()); ISF::TruthBinding* tBinding = new ISF::TruthBinding(truthParticle, primaryHepParticle, generationZeroHepParticle); @@ -252,7 +252,7 @@ namespace G4UA { ISF::ISFParticle* TrackProcessorUserActionPassBack::newISFParticle(G4Track* aTrack, const ISF::ISFParticle* parentISP, - HepMC::GenParticle* truthParticle, + HepMC::GenParticlePtr truthParticle, AtlasDetDescr::AtlasRegion nextGeoID) { ISF::TruthBinding* tBinding = newTruthBinding(aTrack, truthParticle); @@ -271,7 +271,7 @@ namespace G4UA { void TrackProcessorUserActionPassBack::returnParticleToISF( G4Track *aTrack, const ISF::ISFParticle* parentISP, - HepMC::GenParticle* truthParticle, + HepMC::GenParticlePtr truthParticle, AtlasDetDescr::AtlasRegion nextGeoID ) { // kill track inside G4 diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.h index b54d7df05f4..f96fd65309e 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TrackProcessorUserActionPassBack.h @@ -55,17 +55,17 @@ namespace G4UA{ Config m_config; /** create a new TruthBinding object for the given G4Track (may return 0 if unable) */ - ISF::TruthBinding* newTruthBinding(const G4Track* aTrack, HepMC::GenParticle* truthParticle) const; + ISF::TruthBinding* newTruthBinding(const G4Track* aTrack, HepMC::GenParticlePtr truthParticle) const; ISF::ISFParticle* newISFParticle(G4Track* aTrack, const ISF::ISFParticle* parent, - HepMC::GenParticle* truthParticle, + HepMC::GenParticlePtr truthParticle, AtlasDetDescr::AtlasRegion nextGeoID); /** kills the given G4Track, converts it into an ISFParticle and returns it to the ISF particle broker */ void returnParticleToISF( G4Track *aTrack, const ISF::ISFParticle *parentISP, - HepMC::GenParticle* truthParticle, + HepMC::GenParticlePtr truthParticle, AtlasDetDescr::AtlasRegion nextGeoID ); ISF::IParticleBroker *m_particleBrokerQuick; //!< quickaccess avoiding gaudi ovehead diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx index 51531a82191..f4a54d5845c 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticleGenericFilter.cxx @@ -85,7 +85,7 @@ bool ISF::GenParticleGenericFilter::pass(const HepMC::GenParticle& particle) con { bool pass = true; - const auto* productionVertex = particle.production_vertex(); + HepMC::ConstGenVertexPtr productionVertex = particle.production_vertex(); const auto* position = productionVertex ? &productionVertex->position() : nullptr; if (!position || position->perp()<=m_maxApplicableRadius) { pass = check_cuts_passed(particle); diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx index 2dbbb15df18..597933ec224 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenParticlePositionFilter.cxx @@ -51,7 +51,7 @@ StatusCode ISF::GenParticlePositionFilter::initialize() bool ISF::GenParticlePositionFilter::pass(const HepMC::GenParticle& particle) const { // the GenParticle production vertex - HepMC::GenVertex* vtx = particle.production_vertex(); + HepMC::GenVertexPtr vtx = particle.production_vertex(); // no production vertex? if (!vtx) { diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx index eb164b1b07d..d298c9de756 100644 --- a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx +++ b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx @@ -134,7 +134,7 @@ void ISF::ConeSimSelector::update(const ISFParticle& particle) if (truth) { // get GenParticle from truth binding - const HepMC::GenParticle* genParticle = truth->getTruthParticle(); + HepMC::ConstGenParticlePtr genParticle = truth->getTruthParticle(); if (!genParticle) { // cone conditions not fulfilled @@ -142,13 +142,13 @@ void ISF::ConeSimSelector::update(const ISFParticle& particle) } // test whether any of the pdg codes is found in the genParticle history - const HepMC::GenParticle *relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives); + HepMC::ConstGenParticlePtr relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives); if (relative) { ATH_MSG_VERBOSE("Current particle has valid relative particle:" << " (pdg=" << relative->pdg_id() << "," - << " barcode=" << relative->barcode() << ")." + << " barcode=" << HepMC::barcode(relative) << ")." << " Will now check whether cone cuts apply" ); } else diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx index ac71596f114..4bf6af110ea 100644 --- a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx +++ b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -69,11 +69,11 @@ bool ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle) if (truth) { // get GenParticle from truth binding - const HepMC::GenParticle* genParticle = truth->getTruthParticle(); + HepMC::ConstGenParticlePtr genParticle = truth->getTruthParticle(); if (genParticle) { // test whether any of the pdg codes is found in the genParticle history - const HepMC::GenParticle* relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives); + HepMC::ConstGenParticlePtr relative = HepMCHelper::findRealtiveWithPDG( *genParticle, m_relation, m_relatives); // in case a relative was found if (relative) { @@ -84,7 +84,7 @@ bool ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle) << " barcode=" << particle.barcode() << ")" << " passes due relative particle" << " (pdg=" << relative->pdg_id() << "," - << " barcode=" << relative->barcode() << ")" ); + << " barcode=" << HepMC::barcode(*relative) << ")" ); // selector cuts passed return true; } // found relative -- GitLab