ATLAS Offline Software
CaloCalibrationHit.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // CaloCalibrationHit
6 // 26-Jan-2004 William Seligman
7 
8 // This class defines a "calibration" hit associated with the Calo
9 // simulation.
10 
11 #ifndef CaloSimEvent_CaloCalibrationHit_h
12 #define CaloSimEvent_CaloCalibrationHit_h
13 
14 #include "Identifier/Identifier.h"
17 
23 {
24  public:
25 
34  double energyEM,
35  double energyNonEM,
36  double energyInvisible,
37  double energyEscaped):
38  m_ID(id),
43  {}
44 
54  double energyEM,
55  double energyNonEM,
56  double energyInvisible,
57  double energyEscaped,
58  int barcode,
60  m_ID(id),
67  {
68  if (m_barcode == HepMC::UNDEFINED_ID) { m_uniqueID = HepMC::UNDEFINED_ID; } // No link to a truth particle
70  m_partLink = std::make_unique<HepMcParticleLink>(m_barcode, 0, HepMcParticleLink::IS_POSITION, HepMcParticleLink::IS_BARCODE); // FIXME is barcode-based
71  }
72  }
73 
77  m_ID(Identifier())
78  {}
79 
82  : m_ID (cchSource.m_ID),
83  m_energy0 (cchSource.m_energy0),
84  m_energy1 (cchSource.m_energy1),
85  m_energy2 (cchSource.m_energy2),
86  m_energy3 (cchSource.m_energy3),
87  m_barcode (cchSource.m_barcode),
88  m_uniqueID(cchSource.m_uniqueID)
89  {
90  if (m_barcode == HepMC::UNDEFINED_ID) { m_uniqueID = HepMC::UNDEFINED_ID; } // No link to a truth particle
92  m_uniqueID = cchSource.particleUID(); // Try a look-up via HepMcParticleLink
93  }
94  }
95 
98  {
99  if (this == &cchSource) return *this;
100  m_ID = cchSource.m_ID;
101  m_energy0 = cchSource.m_energy0;
102  m_energy1 = cchSource.m_energy1;
103  m_energy2 = cchSource.m_energy2;
104  m_energy3 = cchSource.m_energy3;
105  m_barcode = cchSource.m_barcode;
106  m_uniqueID = cchSource.m_uniqueID;
107  if (m_barcode == HepMC::UNDEFINED_ID) { m_uniqueID = HepMC::UNDEFINED_ID; } // No link to a truth particle
109  m_uniqueID = cchSource.particleUID(); // Try a look-up via HepMcParticleLink
110  }
111  return *this;
112  }
113 
115  virtual ~CaloCalibrationHit() {}
116 
118  Identifier cellID() const { return m_ID; }
119 
121  double energyEM() const { return m_energy0; }
122 
124  double energyNonEM() const { return m_energy1; }
125 
127  double energyInvisible() const { return m_energy2; }
128 
130  double energyEscaped() const { return m_energy3; }
131 
133  double energyTotal() const
134  {
135  return
136  m_energy0 +
137  m_energy1 +
138  m_energy2 +
139  m_energy3;
140  }
141 
143  double energy( unsigned int i ) const
144  {
145  switch (i)
146  {
147  case 0: return m_energy0;
148  case 1: return m_energy1;
149  case 2: return m_energy2;
150  case 3: return m_energy3;
151  default: return 0.;
152  }
153  }
154 
156  int particleID() const { return m_barcode; }
157 
159  int barcode() const { return particleID(); }
160 
162  int particleUID() const { if (m_uniqueID == HepMC::INVALID_PARTICLE_ID && m_partLink) { return m_partLink->id(); } else { return m_uniqueID;} }
163 
165  double operator() (unsigned int i) const { return energy(i); }
166 
168  bool Less(const CaloCalibrationHit* h) const
169  {
170  if(m_ID != h->m_ID){
171  return m_ID < h->m_ID;
172  }else{
173  if (particleID() == HepMC::INVALID_PARTICLE_ID || h->particleUID() == HepMC::INVALID_PARTICLE_ID) {
174  return m_barcode < h->m_barcode;
175  }
176  else {
177  return particleUID() < h->particleUID();
178  }
179  }
180  }
181 
183  bool Equals(const CaloCalibrationHit& h) const {
184  bool equal = (m_ID == h.m_ID);
185  const bool validBarcode(particleID() != HepMC::INVALID_PARTICLE_ID && h.particleID() != HepMC::INVALID_PARTICLE_ID);
186  const bool validUID(particleUID() != HepMC::INVALID_PARTICLE_ID && h.particleUID() != HepMC::INVALID_PARTICLE_ID);
187  equal &= (validBarcode || validUID);
188  if ( validBarcode ) {
189  equal &= (m_barcode == h.m_barcode);
190  }
191  if ( validBarcode ) {
192  equal &= (particleUID() == h.particleUID());
193  }
194  return equal;
195  };
196 
198  bool Equals(const CaloCalibrationHit* h) const {
199  return Equals (*h);
200  }
201 
203  void Add(const CaloCalibrationHit* h)
204  {
205  m_energy0 += h->m_energy0;
206  m_energy1 += h->m_energy1;
207  m_energy2 += h->m_energy2;
208  m_energy3 += h->m_energy3;
209  }
210 
211 private:
212 
215 
222  double m_energy0{0.};
223  double m_energy1{0.};
224  double m_energy2{0.};
225  double m_energy3{0.};
226 
231  std::unique_ptr<HepMcParticleLink> m_partLink{}; // nullptr unless object was produced by reading TrackRecord_p1.
232 
233 };
234 
235 #endif // CaloSimEvent_CaloCalibrationHit_h
236 
CaloCalibrationHit::m_ID
Identifier m_ID
identifier of the cell in which this hit occured.
Definition: CaloCalibrationHit.h:214
CaloCalibrationHit::Equals
bool Equals(const CaloCalibrationHit &h) const
Calibration hits are ordered by values of their identifiers.
Definition: CaloCalibrationHit.h:183
CaloCalibrationHit::m_energy2
double m_energy2
Definition: CaloCalibrationHit.h:224
CaloCalibrationHit::energyNonEM
double energyNonEM() const
Definition: CaloCalibrationHit.h:124
CaloCalibrationHit::operator()
double operator()(unsigned int i) const
Definition: CaloCalibrationHit.h:165
CaloCalibrationHit::Add
void Add(const CaloCalibrationHit *h)
Method used for energy accumulation.
Definition: CaloCalibrationHit.h:203
HepMC::INVALID_PARTICLE_ID
constexpr int INVALID_PARTICLE_ID
Definition: MagicNumbers.h:57
CaloCalibrationHit::~CaloCalibrationHit
virtual ~CaloCalibrationHit()
Destructor.
Definition: CaloCalibrationHit.h:115
CaloCalibrationHit::m_partLink
std::unique_ptr< HepMcParticleLink > m_partLink
Definition: CaloCalibrationHit.h:231
CaloCalibrationHit::CaloCalibrationHit
CaloCalibrationHit(Identifier id, double energyEM, double energyNonEM, double energyInvisible, double energyEscaped)
Standard constructor using identifer and energy by type.
Definition: CaloCalibrationHit.h:33
CaloCalibrationHit::energyEM
double energyEM() const
Definition: CaloCalibrationHit.h:121
CaloCalibrationHit::energyTotal
double energyTotal() const
Definition: CaloCalibrationHit.h:133
CxxUtils::fpcompare::equal
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:114
CaloCalibrationHit::m_energy3
double m_energy3
Definition: CaloCalibrationHit.h:225
CaloCalibrationHit::m_barcode
int m_barcode
legacy barcode of Primary Particle which caused this hit
Definition: CaloCalibrationHit.h:228
CaloCalibrationHit::Equals
bool Equals(const CaloCalibrationHit *h) const
Calibration hits are ordered by values of their identifiers.
Definition: CaloCalibrationHit.h:198
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCalibrationHit::operator=
CaloCalibrationHit & operator=(const CaloCalibrationHit &cchSource)
Assignment operator.
Definition: CaloCalibrationHit.h:97
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
CaloCalibrationHit::CaloCalibrationHit
CaloCalibrationHit(const CaloCalibrationHit &cchSource)
Copy constructor.
Definition: CaloCalibrationHit.h:81
CaloCalibrationHit::energyInvisible
double energyInvisible() const
Definition: CaloCalibrationHit.h:127
CaloCalibrationHit::cellID
Identifier cellID() const
Definition: CaloCalibrationHit.h:118
CaloCalibrationHit::Less
bool Less(const CaloCalibrationHit *h) const
Calibration hits are ordered by values of their identifiers.
Definition: CaloCalibrationHit.h:168
HepMC::UNDEFINED_ID
constexpr int UNDEFINED_ID
Definition: MagicNumbers.h:56
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition: CaloCalibrationHit.h:23
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
MagicNumbers.h
CaloCalibrationHit::m_energy1
double m_energy1
Definition: CaloCalibrationHit.h:223
CaloCalibrationHit::CaloCalibrationHit
CaloCalibrationHit(Identifier id, double energyEM, double energyNonEM, double energyInvisible, double energyEscaped, int barcode, int uniqueID=HepMC::INVALID_PARTICLE_ID)
Standard constructor using identifer, energy by type and primary particle ID.
Definition: CaloCalibrationHit.h:53
CaloCalibrationHit::particleUID
int particleUID() const
Definition: CaloCalibrationHit.h:162
h
CaloCalibrationHit::energy
double energy(unsigned int i) const
Definition: CaloCalibrationHit.h:143
CaloCalibrationHit::m_uniqueID
int m_uniqueID
identifier of Primary Particle which caused this hit
Definition: CaloCalibrationHit.h:230
CaloCalibrationHit::m_energy0
double m_energy0
energies (in MeV) deposited in this hit.
Definition: CaloCalibrationHit.h:222
CaloCalibrationHit::CaloCalibrationHit
CaloCalibrationHit()
Default constructor; should never be used, but provided for some persistency services.
Definition: CaloCalibrationHit.h:76
CaloCalibrationHit::barcode
int barcode() const
Definition: CaloCalibrationHit.h:159
CaloCalibrationHit::energyEscaped
double energyEscaped() const
Definition: CaloCalibrationHit.h:130
CaloCalibrationHit::particleID
int particleID() const
Definition: CaloCalibrationHit.h:156
Identifier
Definition: IdentifierFieldParser.cxx:14