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) {
34 pass &= (m_truthParticle == rhsTruth);
39 const auto rhsPrimary = rhs.getPrimaryGenParticle();
40 if (m_primaryGenParticle && rhsPrimary) {
41 pass &= (m_primaryGenParticle == rhsPrimary);
46 const auto rhsGenZero = rhs.getGenerationZeroGenParticle();
47 if (m_generationZeroGenParticle && rhsGenZero) {
48 pass &= (m_generationZeroGenParticle == rhsGenZero);
57 bool TruthBinding::isIdent(const TruthBinding& rhs) const {
59 pass &= m_truthParticle == rhs.getCurrentGenParticle();
60 pass &= m_primaryGenParticle == rhs.getPrimaryGenParticle();
61 pass &= m_generationZeroGenParticle == rhs.getGenerationZeroGenParticle();
65 /** pointer to the particle in the simulation truth */
66 HepMC::GenParticlePtr TruthBinding::getCurrentGenParticle() { return m_truthParticle; }
67 HepMC::ConstGenParticlePtr TruthBinding::getCurrentGenParticle() const { return m_truthParticle; }
68 void TruthBinding::setCurrentGenParticle(HepMC::GenParticlePtr p) { m_truthParticle = p; }
70 /** pointer to the primary particle in the simulation truth */
71 HepMC::GenParticlePtr TruthBinding::getPrimaryGenParticle() { return m_primaryGenParticle; }
72 HepMC::ConstGenParticlePtr TruthBinding::getPrimaryGenParticle() const { return m_primaryGenParticle; }
74 /** pointer to the simulation truth particle before any regeneration (eg. brem) */
75 HepMC::GenParticlePtr TruthBinding::getGenerationZeroGenParticle() { return m_generationZeroGenParticle; }
76 HepMC::ConstGenParticlePtr TruthBinding::getGenerationZeroGenParticle() const { return m_generationZeroGenParticle; }
77 void TruthBinding::setGenerationZeroGenParticle(HepMC::GenParticlePtr p) { m_generationZeroGenParticle = p; }
79 /** Create a TruthBinding for a child particle */
80 // Not const: otherwise it can trigger a thread-safety checker warning
81 // because the non-const m_primaryTruthParticle escapes.
82 TruthBinding* TruthBinding::childTruthBinding(HepMC::GenParticlePtr childP) {
83 return new TruthBinding(childP, m_primaryGenParticle, childP);