ATLAS Offline Software
Loading...
Searching...
No Matches
TruthBinding.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// this file contains all ITruthBinding inline methods
6
7namespace ISF {
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) { }
13
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) { }
19
20 /** destructor */
21 TruthBinding::~TruthBinding() = default;
22
23 /** comparison operator */
24 bool TruthBinding::operator==(const TruthBinding& rhs) const {
25 return isEqual(rhs);
26 }
27
28 /** check equality */
29 bool TruthBinding::isEqual(const TruthBinding& rhs) const {
30 bool pass = true;
31
32 const auto rhsTruth = rhs.getCurrentGenParticle();
33 if (m_truthParticle && rhsTruth) {
34 pass &= (m_truthParticle == rhsTruth);
35 } else {
36 return false;
37 }
38
39 const auto rhsPrimary = rhs.getPrimaryGenParticle();
40 if (m_primaryGenParticle && rhsPrimary) {
41 pass &= (m_primaryGenParticle == rhsPrimary);
42 } else {
43 return false;
44 }
45
46 const auto rhsGenZero = rhs.getGenerationZeroGenParticle();
47 if (m_generationZeroGenParticle && rhsGenZero) {
48 pass &= (m_generationZeroGenParticle == rhsGenZero);
49 } else {
50 return false;
51 }
52
53 return pass;
54 }
55
56 /** check identity */
57 bool TruthBinding::isIdent(const TruthBinding& rhs) const {
58 bool pass = true;
59 pass &= m_truthParticle == rhs.getCurrentGenParticle();
60 pass &= m_primaryGenParticle == rhs.getPrimaryGenParticle();
61 pass &= m_generationZeroGenParticle == rhs.getGenerationZeroGenParticle();
62 return pass;
63 }
64
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; }
69
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; }
73
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; }
78
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);
84 }
85
86} // end ISF namespace