2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 // this file contains all ITruthBinding inline methods
8 /** constructor setting all truth particle pointers to the given particle */
9 TruthBinding::TruthBinding(HepMC::GenParticlePtr allTruthP) :
10 m_truthParticle(allTruthP),
11 m_primaryGenParticle(allTruthP),
12 m_generationZeroGenParticle(allTruthP) { }
14 /** constructor setting all truth particle pointers individually */
15 TruthBinding::TruthBinding(HepMC::GenParticlePtr truthP, HepMC::GenParticlePtr primaryTruthP, HepMC::GenParticlePtr genZeroTruthP) :
16 m_truthParticle(truthP),
17 m_primaryGenParticle(primaryTruthP),
18 m_generationZeroGenParticle(genZeroTruthP) { }
21 TruthBinding::~TruthBinding() = default;
23 /** comparison operator */
24 bool TruthBinding::operator==(const TruthBinding& rhs) const {
29 bool TruthBinding::isEqual(const TruthBinding& rhs) const {
32 const auto rhsTruth = rhs.getCurrentGenParticle();
33 if (m_truthParticle && rhsTruth) {
35 pass &= (m_truthParticle == rhsTruth);
37 pass &= *m_truthParticle == *rhsTruth;
43 const auto rhsPrimary = rhs.getPrimaryGenParticle();
44 if (m_primaryGenParticle && rhsPrimary) {
46 pass &= (m_primaryGenParticle == rhsPrimary);
48 pass &= *m_primaryGenParticle == *rhsPrimary;
54 const auto rhsGenZero = rhs.getGenerationZeroGenParticle();
55 if (m_generationZeroGenParticle && rhsGenZero) {
57 pass &= (m_generationZeroGenParticle == rhsGenZero);
59 pass &= *m_generationZeroGenParticle == *rhsGenZero;
69 bool TruthBinding::isIdent(const TruthBinding& rhs) const {
71 pass &= m_truthParticle == rhs.getCurrentGenParticle();
72 pass &= m_primaryGenParticle == rhs.getPrimaryGenParticle();
73 pass &= m_generationZeroGenParticle == rhs.getGenerationZeroGenParticle();
77 /** pointer to the particle in the simulation truth */
78 HepMC::GenParticlePtr TruthBinding::getCurrentGenParticle() { return m_truthParticle; }
79 HepMC::ConstGenParticlePtr TruthBinding::getCurrentGenParticle() const { return m_truthParticle; }
80 void TruthBinding::setCurrentGenParticle(HepMC::GenParticlePtr p) { m_truthParticle = p; }
82 /** pointer to the primary particle in the simulation truth */
83 HepMC::GenParticlePtr TruthBinding::getPrimaryGenParticle() { return m_primaryGenParticle; }
84 HepMC::ConstGenParticlePtr TruthBinding::getPrimaryGenParticle() const { return m_primaryGenParticle; }
86 /** pointer to the simulation truth particle before any regeneration (eg. brem) */
87 HepMC::GenParticlePtr TruthBinding::getGenerationZeroGenParticle() { return m_generationZeroGenParticle; }
88 HepMC::ConstGenParticlePtr TruthBinding::getGenerationZeroGenParticle() const { return m_generationZeroGenParticle; }
89 void TruthBinding::setGenerationZeroGenParticle(HepMC::GenParticlePtr p) { m_generationZeroGenParticle = p; }
91 /** Create a TruthBinding for a child particle */
92 // Not const: otherwise it can trigger a thread-safety checker warning
93 // because the non-const m_primaryTruthParticle escapes.
94 TruthBinding* TruthBinding::childTruthBinding(HepMC::GenParticlePtr childP) {
95 return new TruthBinding(childP, m_primaryGenParticle, childP);
98 } // end ISF namespace