Skip to content
Snippets Groups Projects
Commit ea7df69e authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

MCTruth: use non-const particles

This is similar to !58354 and removes unnecessary `const` qualifiers on
`GenParticle` and `ISFParticle` to avoid `const_cast` downstream for
the following classes:
- `PrimaryParticleInformation`
- `TrackBarcodeInfo`
- `TrackInformation`
- `VTrackInformation`
parent 438bd91c
No related branches found
No related tags found
6 merge requests!59674InDetPerformanceMonitoring with LumiBlock selection,!59383cppcheck in trigger code: Prefer prefix ++/-- operators for non-primitive types.,!58990Draft:Fixing bug in FTF config when running with Reco_tf,!58835DataQualityConfigurations: Modify L1Calo config for web display,!58791DataQualityConfigurations: Modify L1Calo config for web display,!58456MCTruth: use non-const particles
Showing
with 87 additions and 137 deletions
/* /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef PrimaryParticleInformation_H #ifndef PrimaryParticleInformation_H
...@@ -16,21 +16,23 @@ namespace ISF { ...@@ -16,21 +16,23 @@ namespace ISF {
class PrimaryParticleInformation: public G4VUserPrimaryParticleInformation { class PrimaryParticleInformation: public G4VUserPrimaryParticleInformation {
public: public:
PrimaryParticleInformation(); PrimaryParticleInformation();
PrimaryParticleInformation(HepMC::ConstGenParticlePtr, const ISF::ISFParticle* isp=0); PrimaryParticleInformation(HepMC::GenParticlePtr, ISF::ISFParticle* isp=0);
HepMC::ConstGenParticlePtr GetHepMCParticle() const; HepMC::ConstGenParticlePtr GetHepMCParticle() const { return m_theParticle; }
HepMC::GenParticlePtr GetHepMCParticle() { return m_theParticle; }
int GetParticleBarcode() const; int GetParticleBarcode() const;
void SuggestBarcode(int bc); void SuggestBarcode(int bc);
void SetParticle(HepMC::ConstGenParticlePtr); void SetParticle(HepMC::GenParticlePtr);
void Print() const {} void Print() const {}
int GetRegenerationNr() {return m_regenerationNr;} int GetRegenerationNr() {return m_regenerationNr;}
void SetRegenerationNr(int i) {m_regenerationNr=i;} void SetRegenerationNr(int i) {m_regenerationNr=i;}
void SetISFParticle(const ISF::ISFParticle* isp); void SetISFParticle(ISF::ISFParticle* isp);
const ISF::ISFParticle* GetISFParticle() const; const ISF::ISFParticle* GetISFParticle() const { return m_theISFParticle; }
ISF::ISFParticle* GetISFParticle() { return m_theISFParticle; }
private: private:
HepMC::ConstGenParticlePtr m_theParticle{}; HepMC::GenParticlePtr m_theParticle{};
const ISF::ISFParticle* m_theISFParticle{}; ISF::ISFParticle* m_theISFParticle{};
int m_regenerationNr{0}; int m_regenerationNr{0};
int m_barcode{-1}; int m_barcode{-1};
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef TrackBarcodeInfo_H #ifndef TrackBarcodeInfo_H
...@@ -13,15 +13,17 @@ namespace ISF { ...@@ -13,15 +13,17 @@ namespace ISF {
class TrackBarcodeInfo: public VTrackInformation { class TrackBarcodeInfo: public VTrackInformation {
public: public:
TrackBarcodeInfo(int bc, const ISF::ISFParticle* baseIsp=0); TrackBarcodeInfo(int bc, ISF::ISFParticle* baseIsp=0);
int GetParticleBarcode() const; virtual int GetParticleBarcode() const override {return m_barcode;}
const ISF::ISFParticle *GetBaseISFParticle() const; virtual const ISF::ISFParticle *GetBaseISFParticle() const override {return m_theBaseISFParticle;}
void SetBaseISFParticle(const ISF::ISFParticle*); virtual ISF::ISFParticle *GetBaseISFParticle() override {return m_theBaseISFParticle;}
void SetReturnedToISF(bool returned);
bool GetReturnedToISF() const; virtual void SetBaseISFParticle(ISF::ISFParticle*) override;
virtual void SetReturnedToISF(bool returned) override;
virtual bool GetReturnedToISF() const override {return m_returnedToISF;}
private: private:
const ISF::ISFParticle *m_theBaseISFParticle; ISF::ISFParticle *m_theBaseISFParticle;
int m_barcode; int m_barcode;
bool m_returnedToISF; bool m_returnedToISF;
}; };
......
/* /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef TrackInformation_H #ifndef TrackInformation_H
...@@ -14,20 +14,22 @@ namespace ISF { ...@@ -14,20 +14,22 @@ namespace ISF {
class TrackInformation: public VTrackInformation { class TrackInformation: public VTrackInformation {
public: public:
TrackInformation(); TrackInformation();
TrackInformation(HepMC::ConstGenParticlePtr,const ISF::ISFParticle* baseIsp=0); TrackInformation(HepMC::GenParticlePtr p, ISF::ISFParticle* baseIsp=0);
HepMC::ConstGenParticlePtr GetHepMCParticle() const; virtual HepMC::ConstGenParticlePtr GetHepMCParticle() const override {return m_theParticle;}
const ISF::ISFParticle *GetBaseISFParticle() const; virtual HepMC::GenParticlePtr GetHepMCParticle() override {return m_theParticle;}
int GetParticleBarcode() const; virtual const ISF::ISFParticle *GetBaseISFParticle() const override {return m_theBaseISFParticle;}
void SetParticle(HepMC::ConstGenParticlePtr); virtual ISF::ISFParticle *GetBaseISFParticle() override {return m_theBaseISFParticle;}
void SetBaseISFParticle(const ISF::ISFParticle*); virtual int GetParticleBarcode() const override;
void SetReturnedToISF(bool returned) {m_returnedToISF=returned;}; virtual void SetParticle(HepMC::GenParticlePtr) override;
bool GetReturnedToISF() const {return m_returnedToISF;}; virtual void SetBaseISFParticle(ISF::ISFParticle*) override;
void SetRegenerationNr(int i) {m_regenerationNr=i;}; virtual void SetReturnedToISF(bool returned) override {m_returnedToISF=returned;}
int GetRegenerationNr() const {return m_regenerationNr;}; virtual bool GetReturnedToISF() const override {return m_returnedToISF;}
void SetRegenerationNr(int i) {m_regenerationNr=i;}
int GetRegenerationNr() const {return m_regenerationNr;}
private: private:
int m_regenerationNr; int m_regenerationNr;
HepMC::ConstGenParticlePtr m_theParticle; HepMC::GenParticlePtr m_theParticle;
const ISF::ISFParticle *m_theBaseISFParticle; ISF::ISFParticle *m_theBaseISFParticle;
bool m_returnedToISF; bool m_returnedToISF;
}; };
......
/* /*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef VTrackInformation_H #ifndef VTrackInformation_H
...@@ -18,21 +18,24 @@ namespace ISF { ...@@ -18,21 +18,24 @@ namespace ISF {
class VTrackInformation: public G4VUserTrackInformation { class VTrackInformation: public G4VUserTrackInformation {
public: public:
VTrackInformation(TrackClassification tc=Primary); VTrackInformation(TrackClassification tc=Primary);
HepMC::ConstGenParticlePtr GetPrimaryHepMCParticle() const; HepMC::ConstGenParticlePtr GetPrimaryHepMCParticle() const {return m_thePrimaryParticle;}
void SetPrimaryHepMCParticle(HepMC::ConstGenParticlePtr); HepMC::GenParticlePtr GetPrimaryHepMCParticle() {return m_thePrimaryParticle;}
virtual HepMC::ConstGenParticlePtr GetHepMCParticle() const; void SetPrimaryHepMCParticle(HepMC::GenParticlePtr);
virtual const ISF::ISFParticle *GetBaseISFParticle() const; virtual HepMC::ConstGenParticlePtr GetHepMCParticle() const {return nullptr;}
virtual HepMC::GenParticlePtr GetHepMCParticle() {return nullptr;}
virtual const ISF::ISFParticle *GetBaseISFParticle() const {return nullptr;}
virtual ISF::ISFParticle *GetBaseISFParticle() {return nullptr;}
virtual bool GetReturnedToISF() const; virtual bool GetReturnedToISF() const;
virtual int GetParticleBarcode() const =0; virtual int GetParticleBarcode() const =0;
virtual void SetParticle(HepMC::ConstGenParticlePtr); virtual void SetParticle(HepMC::GenParticlePtr);
virtual void SetBaseISFParticle(const ISF::ISFParticle*); virtual void SetBaseISFParticle(ISF::ISFParticle*);
virtual void SetReturnedToISF(bool) ; virtual void SetReturnedToISF(bool) ;
virtual void Print() const {} virtual void Print() const {}
void SetClassification(TrackClassification tc) {m_classify=tc;} void SetClassification(TrackClassification tc) {m_classify=tc;}
TrackClassification GetClassification() const {return m_classify;} TrackClassification GetClassification() const {return m_classify;}
private: private:
TrackClassification m_classify; TrackClassification m_classify;
HepMC::ConstGenParticlePtr m_thePrimaryParticle{}; HepMC::GenParticlePtr m_thePrimaryParticle{};
}; };
#endif #endif
/* /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "MCTruth/PrimaryParticleInformation.h" #include "MCTruth/PrimaryParticleInformation.h"
...@@ -8,20 +8,10 @@ PrimaryParticleInformation::PrimaryParticleInformation() ...@@ -8,20 +8,10 @@ PrimaryParticleInformation::PrimaryParticleInformation()
{ {
} }
PrimaryParticleInformation::PrimaryParticleInformation(HepMC::ConstGenParticlePtr p, const ISF::ISFParticle* isp):m_theParticle(p),m_theISFParticle(isp) PrimaryParticleInformation::PrimaryParticleInformation(HepMC::GenParticlePtr p, ISF::ISFParticle* isp):m_theParticle(p),m_theISFParticle(isp)
{ {
} }
HepMC::ConstGenParticlePtr PrimaryParticleInformation::GetHepMCParticle() const
{
return m_theParticle;
}
const ISF::ISFParticle* PrimaryParticleInformation::GetISFParticle() const
{
return m_theISFParticle;
}
void PrimaryParticleInformation::SuggestBarcode(int bc) void PrimaryParticleInformation::SuggestBarcode(int bc)
{ {
m_barcode=bc; m_barcode=bc;
...@@ -35,12 +25,12 @@ int PrimaryParticleInformation::GetParticleBarcode() const ...@@ -35,12 +25,12 @@ int PrimaryParticleInformation::GetParticleBarcode() const
return m_theParticle?HepMC::barcode(m_theParticle):m_barcode; return m_theParticle?HepMC::barcode(m_theParticle):m_barcode;
} }
void PrimaryParticleInformation::SetParticle(HepMC::ConstGenParticlePtr p) void PrimaryParticleInformation::SetParticle(HepMC::GenParticlePtr p)
{ {
m_theParticle=p; m_theParticle=p;
} }
void PrimaryParticleInformation::SetISFParticle(const ISF::ISFParticle* p) void PrimaryParticleInformation::SetISFParticle(ISF::ISFParticle* p)
{ {
m_theISFParticle=p; m_theISFParticle=p;
} }
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "MCTruth/TrackBarcodeInfo.h" #include "MCTruth/TrackBarcodeInfo.h"
TrackBarcodeInfo::TrackBarcodeInfo(int bc, const ISF::ISFParticle* baseIsp):VTrackInformation(BarcodeOnly),m_theBaseISFParticle(baseIsp),m_barcode(bc),m_returnedToISF(false) TrackBarcodeInfo::TrackBarcodeInfo(int bc, ISF::ISFParticle* baseIsp):VTrackInformation(BarcodeOnly),m_theBaseISFParticle(baseIsp),m_barcode(bc),m_returnedToISF(false)
{ {
} }
int TrackBarcodeInfo::GetParticleBarcode() const void TrackBarcodeInfo::SetBaseISFParticle(ISF::ISFParticle* isp)
{
return m_barcode;
}
void TrackBarcodeInfo::SetBaseISFParticle(const ISF::ISFParticle* isp)
{ {
m_theBaseISFParticle=isp; m_theBaseISFParticle=isp;
} }
const ISF::ISFParticle* TrackBarcodeInfo::GetBaseISFParticle() const
{
return m_theBaseISFParticle;
}
void TrackBarcodeInfo::SetReturnedToISF(bool returned) void TrackBarcodeInfo::SetReturnedToISF(bool returned)
{ {
m_returnedToISF = returned; m_returnedToISF = returned;
} }
bool TrackBarcodeInfo::GetReturnedToISF() const
{
return m_returnedToISF;
}
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "MCTruth/TrackHelper.h" #include "MCTruth/TrackHelper.h"
...@@ -31,7 +31,7 @@ bool TrackHelper::IsSecondary() const ...@@ -31,7 +31,7 @@ bool TrackHelper::IsSecondary() const
} }
int TrackHelper::GetBarcode() const int TrackHelper::GetBarcode() const
{ {
if (m_trackInfo==0 || m_trackInfo->GetHepMCParticle()==0) return 0; if (m_trackInfo==0 || std::as_const(m_trackInfo)->GetHepMCParticle()==0) return 0;
return m_trackInfo->GetParticleBarcode(); return m_trackInfo->GetParticleBarcode();
} }
......
/* /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "MCTruth/TrackInformation.h" #include "MCTruth/TrackInformation.h"
...@@ -11,7 +11,7 @@ TrackInformation::TrackInformation():m_regenerationNr(0),m_theParticle(0),m_theB ...@@ -11,7 +11,7 @@ TrackInformation::TrackInformation():m_regenerationNr(0),m_theParticle(0),m_theB
{ {
} }
TrackInformation::TrackInformation(HepMC::ConstGenParticlePtr p,const ISF::ISFParticle* baseIsp): TrackInformation::TrackInformation(HepMC::GenParticlePtr p, ISF::ISFParticle* baseIsp):
m_regenerationNr(0), m_regenerationNr(0),
m_theParticle(p), m_theParticle(p),
m_theBaseISFParticle(baseIsp), m_theBaseISFParticle(baseIsp),
...@@ -19,26 +19,17 @@ TrackInformation::TrackInformation(HepMC::ConstGenParticlePtr p,const ISF::ISFPa ...@@ -19,26 +19,17 @@ TrackInformation::TrackInformation(HepMC::ConstGenParticlePtr p,const ISF::ISFPa
{ {
} }
HepMC::ConstGenParticlePtr TrackInformation::GetHepMCParticle() const
{
return m_theParticle;
}
const ISF::ISFParticle* TrackInformation::GetBaseISFParticle() const
{
return m_theBaseISFParticle;
}
int TrackInformation::GetParticleBarcode() const int TrackInformation::GetParticleBarcode() const
{ {
return ( m_theParticle ? HepMC::barcode(m_theParticle) : 0 ); return ( m_theParticle ? HepMC::barcode(m_theParticle) : 0 );
} }
void TrackInformation::SetParticle(HepMC::ConstGenParticlePtr p) void TrackInformation::SetParticle(HepMC::GenParticlePtr p)
{ {
m_theParticle=p; m_theParticle=p;
} }
void TrackInformation::SetBaseISFParticle(const ISF::ISFParticle* p) void TrackInformation::SetBaseISFParticle(ISF::ISFParticle* p)
{ {
m_theBaseISFParticle=p; m_theBaseISFParticle=p;
} }
/* /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "MCTruth/VTrackInformation.h" #include "MCTruth/VTrackInformation.h"
...@@ -8,40 +8,24 @@ VTrackInformation::VTrackInformation(TrackClassification tc):m_classify(tc) ...@@ -8,40 +8,24 @@ VTrackInformation::VTrackInformation(TrackClassification tc):m_classify(tc)
{ {
} }
HepMC::ConstGenParticlePtr VTrackInformation::GetPrimaryHepMCParticle() const void VTrackInformation::SetPrimaryHepMCParticle(HepMC::GenParticlePtr p)
{
return m_thePrimaryParticle;
}
void VTrackInformation::SetPrimaryHepMCParticle(HepMC::ConstGenParticlePtr p)
{ {
m_thePrimaryParticle=p; m_thePrimaryParticle=p;
} }
HepMC::ConstGenParticlePtr VTrackInformation::GetHepMCParticle() const
{
return 0;
}
const ISF::ISFParticle* VTrackInformation::GetBaseISFParticle() const
{
return 0;
}
bool VTrackInformation::GetReturnedToISF() const bool VTrackInformation::GetReturnedToISF() const
{ {
return false; return false;
} }
void VTrackInformation::SetParticle(HepMC::ConstGenParticlePtr /*p*/) void VTrackInformation::SetParticle(HepMC::GenParticlePtr /*p*/)
{ {
// you should not call this, perhaps throw an exception? // you should not call this, perhaps throw an exception?
std::cerr<<"ERROR VTrackInformation::SetParticle() not supported "<<std::endl; std::cerr<<"ERROR VTrackInformation::SetParticle() not supported "<<std::endl;
} }
void VTrackInformation::SetBaseISFParticle(const ISF::ISFParticle* /*p*/) void VTrackInformation::SetBaseISFParticle(ISF::ISFParticle* /*p*/)
{ {
// you should not call this, perhaps throw an exception? // you should not call this, perhaps throw an exception?
std::cerr<<"ERROR VTrackInformation::SetBaseISFParticle() not supported "<<std::endl; std::cerr<<"ERROR VTrackInformation::SetBaseISFParticle() not supported "<<std::endl;
......
...@@ -43,17 +43,8 @@ namespace G4UA ...@@ -43,17 +43,8 @@ namespace G4UA
// Condition for storing the GenParticle in the AtlasG4EventUserInfo for later. // Condition for storing the GenParticle in the AtlasG4EventUserInfo for later.
if (trackHelper.IsPrimary() || trackHelper.IsRegisteredSecondary()) if (trackHelper.IsPrimary() || trackHelper.IsRegisteredSecondary())
{ {
// Why a const_cast??? HepMC::GenParticlePtr part = trackHelper.GetTrackInformation()->GetHepMCParticle();
// This is an ugly way to communicate the GenParticle...
#ifdef HEPMC3
HepMC::GenParticlePtr part =
std::const_pointer_cast<HepMC3::GenParticle>( trackHelper.GetTrackInformation()->
GetHepMCParticle() );
#else
HepMC::GenParticlePtr part =
const_cast<HepMC::GenParticlePtr>( trackHelper.GetTrackInformation()->
GetHepMCParticle() );
#endif
// Assign the GenParticle to the AtlasG4EventUserInfo. // Assign the GenParticle to the AtlasG4EventUserInfo.
AtlasG4EventUserInfo* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*> AtlasG4EventUserInfo* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*>
(G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation()); (G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
......
...@@ -112,7 +112,7 @@ namespace ISF { ...@@ -112,7 +112,7 @@ namespace ISF {
inline HepMC::GenParticlePtr getHepMCTruthParticle( ISF::ISFParticle& particle ) const; inline HepMC::GenParticlePtr getHepMCTruthParticle( ISF::ISFParticle& particle ) const;
/** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */ /** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */
inline HepMC::GenParticlePtr updateHepMCTruthParticle( ISF::ISFParticle& particle, const ISF::ISFParticle* parent=nullptr ) const; inline HepMC::GenParticlePtr updateHepMCTruthParticle( ISF::ISFParticle& particle, ISF::ISFParticle* parent=nullptr ) const;
ISF::ISFParticle& m_parent; ISF::ISFParticle& m_parent;
const ISFParticleVector& m_children; const ISFParticleVector& m_children;
......
...@@ -27,7 +27,7 @@ namespace ISF { ...@@ -27,7 +27,7 @@ namespace ISF {
/** constructor setting all truth particle pointers to the given particle */ /** constructor setting all truth particle pointers to the given particle */
inline TruthBinding(HepMC::GenParticlePtr allTruthP); inline TruthBinding(HepMC::GenParticlePtr allTruthP);
/** constructor setting all truth particle pointers individually */ /** constructor setting all truth particle pointers individually */
inline TruthBinding(HepMC::GenParticlePtr truthP, HepMC::ConstGenParticlePtr primaryTruthP, HepMC::ConstGenParticlePtr genZeroTruthP); inline TruthBinding(HepMC::GenParticlePtr truthP, HepMC::GenParticlePtr primaryTruthP, HepMC::GenParticlePtr genZeroTruthP);
/** copy constructors */ /** copy constructors */
inline TruthBinding(const TruthBinding &rhs) = default; inline TruthBinding(const TruthBinding &rhs) = default;
...@@ -51,16 +51,18 @@ namespace ISF { ...@@ -51,16 +51,18 @@ namespace ISF {
inline void setTruthParticle(HepMC::GenParticlePtr p); inline void setTruthParticle(HepMC::GenParticlePtr p);
/** pointer to the primary particle in the simulation truth */ /** pointer to the primary particle in the simulation truth */
inline HepMC::GenParticlePtr getPrimaryTruthParticle();
inline HepMC::ConstGenParticlePtr getPrimaryTruthParticle() const; inline HepMC::ConstGenParticlePtr getPrimaryTruthParticle() const;
/** pointer to the simulation truth particle before any regeneration happened (eg. brem) */ /** pointer to the simulation truth particle before any regeneration happened (eg. brem) */
inline HepMC::GenParticlePtr getGenerationZeroTruthParticle();
inline HepMC::ConstGenParticlePtr getGenerationZeroTruthParticle() const; inline HepMC::ConstGenParticlePtr getGenerationZeroTruthParticle() const;
inline void setGenerationZeroTruthParticle(HepMC::GenParticlePtr p); inline void setGenerationZeroTruthParticle(HepMC::GenParticlePtr p);
private: private:
HepMC::GenParticlePtr m_truthParticle{}; //!< pointer to particle in MC truth HepMC::GenParticlePtr m_truthParticle{}; //!< pointer to particle in MC truth
HepMC::ConstGenParticlePtr m_primaryTruthParticle{}; //!< pointer to corresponding primary (generator) particle HepMC::GenParticlePtr m_primaryTruthParticle{}; //!< pointer to corresponding primary (generator) particle
HepMC::ConstGenParticlePtr m_generationZeroTruthParticle{}; //!< pointer to corresponding truth particle before any regenration HepMC::GenParticlePtr m_generationZeroTruthParticle{}; //!< pointer to corresponding truth particle before any regenration
}; };
} // end of namespace } // end of namespace
......
...@@ -12,7 +12,7 @@ namespace ISF { ...@@ -12,7 +12,7 @@ namespace ISF {
m_generationZeroTruthParticle(allTruthP) { } m_generationZeroTruthParticle(allTruthP) { }
/** constructor setting all truth particle pointers individually */ /** constructor setting all truth particle pointers individually */
TruthBinding::TruthBinding(HepMC::GenParticlePtr truthP, HepMC::ConstGenParticlePtr primaryTruthP, HepMC::ConstGenParticlePtr genZeroTruthP) : TruthBinding::TruthBinding(HepMC::GenParticlePtr truthP, HepMC::GenParticlePtr primaryTruthP, HepMC::GenParticlePtr genZeroTruthP) :
m_truthParticle(truthP), m_truthParticle(truthP),
m_primaryTruthParticle(primaryTruthP), m_primaryTruthParticle(primaryTruthP),
m_generationZeroTruthParticle(genZeroTruthP) { } m_generationZeroTruthParticle(genZeroTruthP) { }
...@@ -80,9 +80,11 @@ namespace ISF { ...@@ -80,9 +80,11 @@ namespace ISF {
void TruthBinding::setTruthParticle(HepMC::GenParticlePtr p) { m_truthParticle = p; } void TruthBinding::setTruthParticle(HepMC::GenParticlePtr p) { m_truthParticle = p; }
/** pointer to the primary particle in the simulation truth */ /** pointer to the primary particle in the simulation truth */
HepMC::GenParticlePtr TruthBinding::getPrimaryTruthParticle() { return m_primaryTruthParticle; }
HepMC::ConstGenParticlePtr TruthBinding::getPrimaryTruthParticle() const { return m_primaryTruthParticle; } HepMC::ConstGenParticlePtr TruthBinding::getPrimaryTruthParticle() const { return m_primaryTruthParticle; }
/** pointer to the simulation truth particle before any regeneration (eg. brem) */ /** pointer to the simulation truth particle before any regeneration (eg. brem) */
HepMC::GenParticlePtr TruthBinding::getGenerationZeroTruthParticle() { return m_generationZeroTruthParticle; }
HepMC::ConstGenParticlePtr TruthBinding::getGenerationZeroTruthParticle() const { return m_generationZeroTruthParticle; } HepMC::ConstGenParticlePtr TruthBinding::getGenerationZeroTruthParticle() const { return m_generationZeroTruthParticle; }
void TruthBinding::setGenerationZeroTruthParticle(HepMC::GenParticlePtr p) { m_generationZeroTruthParticle = p; } void TruthBinding::setGenerationZeroTruthParticle(HepMC::GenParticlePtr p) { m_generationZeroTruthParticle = p; }
......
...@@ -177,7 +177,7 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( ISF::ISFPart ...@@ -177,7 +177,7 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::getHepMCTruthParticle( ISF::ISFPart
/** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */ /** convert ISFParticle to GenParticle and attach to ISFParticle's TruthBinding */
HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle, HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFParticle& particle,
const ISF::ISFParticle* parent ) const { ISF::ISFParticle* parent ) const {
auto* truthBinding = particle.getTruthBinding(); auto* truthBinding = particle.getTruthBinding();
HepMC::GenParticlePtr hepTruthParticle = ParticleHelper::convert( particle ); HepMC::GenParticlePtr hepTruthParticle = ParticleHelper::convert( particle );
......
...@@ -516,7 +516,7 @@ double SetProperTimeFromDetectorFrameDecayLength(G4PrimaryParticle& g4particle,c ...@@ -516,7 +516,7 @@ double SetProperTimeFromDetectorFrameDecayLength(G4PrimaryParticle& g4particle,c
//________________________________________________________________________ //________________________________________________________________________
#ifdef HEPMC3 #ifdef HEPMC3
G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(HepMC::ConstGenParticlePtr genpart) const{ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(HepMC::GenParticlePtr genpart) const{
ATH_MSG_VERBOSE("Creating G4PrimaryParticle from GenParticle."); ATH_MSG_VERBOSE("Creating G4PrimaryParticle from GenParticle.");
const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(genpart->pdg_id()); const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(genpart->pdg_id());
...@@ -601,7 +601,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(HepMC::ConstGenPart ...@@ -601,7 +601,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(HepMC::ConstGenPart
return g4particle.release(); return g4particle.release();
} }
#else #else
G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(const HepMC::GenParticle& genpart) const G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(HepMC::GenParticle& genpart) const
{ {
ATH_MSG_VERBOSE("Creating G4PrimaryParticle from GenParticle."); ATH_MSG_VERBOSE("Creating G4PrimaryParticle from GenParticle.");
...@@ -703,7 +703,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(ISF::ISFParticle& i ...@@ -703,7 +703,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(ISF::ISFParticle& i
return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up. return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
} }
HepMC::GenParticlePtr genpart = truthBinding->getTruthParticle(); HepMC::GenParticlePtr genpart = truthBinding->getTruthParticle();
HepMC::ConstGenParticlePtr primaryGenpart = truthBinding->getPrimaryTruthParticle(); HepMC::GenParticlePtr primaryGenpart = truthBinding->getPrimaryTruthParticle();
const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(isp.pdgCode()); const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(isp.pdgCode());
......
...@@ -80,9 +80,9 @@ namespace ISF { ...@@ -80,9 +80,9 @@ namespace ISF {
const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const; const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const;
#ifdef HEPMC3 #ifdef HEPMC3
G4PrimaryParticle* getG4PrimaryParticle(HepMC::ConstGenParticlePtr gp) const; G4PrimaryParticle* getG4PrimaryParticle(HepMC::GenParticlePtr gp) const;
#else #else
G4PrimaryParticle* getG4PrimaryParticle(const HepMC::GenParticle& gp) const; G4PrimaryParticle* getG4PrimaryParticle(HepMC::GenParticle& gp) const;
#endif #endif
G4PrimaryParticle* getG4PrimaryParticle(ISF::ISFParticle& isp, bool useHepMC) const; G4PrimaryParticle* getG4PrimaryParticle(ISF::ISFParticle& isp, bool useHepMC) const;
......
...@@ -47,9 +47,9 @@ class ISFG4Helper { ...@@ -47,9 +47,9 @@ class ISFG4Helper {
/** attach a new TrackInformation object to the given new (!) G4Track /** attach a new TrackInformation object to the given new (!) G4Track
* (the G4Track must not have a UserInformation object attached to it) */ * (the G4Track must not have a UserInformation object attached to it) */
static TrackInformation* attachTrackInfoToNewG4Track( G4Track& aTrack, static TrackInformation* attachTrackInfoToNewG4Track( G4Track& aTrack,
const ISF::ISFParticle& baseIsp, ISF::ISFParticle& baseIsp,
TrackClassification classification, TrackClassification classification,
HepMC::ConstGenParticlePtr nonRegeneratedTruthParticle = nullptr); HepMC::GenParticlePtr nonRegeneratedTruthParticle = nullptr);
/** return pointer to current AtlasG4EventUserInfo */ /** return pointer to current AtlasG4EventUserInfo */
static AtlasG4EventUserInfo* getAtlasG4EventUserInfo(); static AtlasG4EventUserInfo* getAtlasG4EventUserInfo();
......
...@@ -77,9 +77,9 @@ iGeant4::ISFG4Helper::getISFTrackInfo(const G4Track& aTrack) ...@@ -77,9 +77,9 @@ iGeant4::ISFG4Helper::getISFTrackInfo(const G4Track& aTrack)
/** link the given G4Track to the given ISFParticle */ /** link the given G4Track to the given ISFParticle */
TrackInformation* TrackInformation*
iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( G4Track& aTrack, iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( G4Track& aTrack,
const ISF::ISFParticle& baseIsp, ISF::ISFParticle& baseIsp,
TrackClassification classification, TrackClassification classification,
HepMC::ConstGenParticlePtr nonRegeneratedTruthParticle) HepMC::GenParticlePtr nonRegeneratedTruthParticle)
{ {
if ( aTrack.GetUserInformation() ) { if ( aTrack.GetUserInformation() ) {
G4ExceptionDescription description; G4ExceptionDescription description;
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
...@@ -89,7 +89,7 @@ void iGeant4::ISFTrajectory::AppendStep(const G4Step* aStep) ...@@ -89,7 +89,7 @@ void iGeant4::ISFTrajectory::AppendStep(const G4Step* aStep)
return; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up. return; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
} }
ISF::ISFParticle* baseIsp = const_cast<ISF::ISFParticle*>( trackInfo->GetBaseISFParticle() ); ISF::ISFParticle* baseIsp = trackInfo->GetBaseISFParticle();
if (!baseIsp) { if (!baseIsp) {
G4ExceptionDescription description; G4ExceptionDescription description;
description << G4String("AppendStep: ") + "NULL ISFParticle pointer for current G4Step (trackID " description << G4String("AppendStep: ") + "NULL ISFParticle pointer for current G4Step (trackID "
......
...@@ -239,11 +239,7 @@ namespace G4UA{ ...@@ -239,11 +239,7 @@ namespace G4UA{
m_scIn = creation? creation->GetProcessSubType() : -1; m_scIn = creation? creation->GetProcessSubType() : -1;
VTrackInformation * trackInfo= static_cast<VTrackInformation*>(track->GetUserInformation()); VTrackInformation * trackInfo= static_cast<VTrackInformation*>(track->GetUserInformation());
#ifdef HEPMC3 HepMC::GenParticlePtr genpart= trackInfo ? trackInfo->GetHepMCParticle() : nullptr;
HepMC::GenParticlePtr genpart=trackInfo ? std::const_pointer_cast<HepMC3::GenParticle>(trackInfo->GetHepMCParticle()):nullptr;
#else
HepMC::GenParticlePtr genpart= trackInfo ? const_cast<HepMC::GenParticlePtr>(trackInfo->GetHepMCParticle()):0;
#endif
HepMC::GenVertexPtr vtx = genpart ? genpart->production_vertex() : 0; HepMC::GenVertexPtr vtx = genpart ? genpart->production_vertex() : 0;
m_gen = genpart? 0 : -1; m_gen = genpart? 0 : -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment