ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCalibrationHit.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
15#include "Identifier/Identifier.h"
17
23
24{
25 public:
44
59 double energyInvisible, double energyEscaped, int barcode,
60 int uniqueID = HepMC::INVALID_PARTICLE_ID)
61 : m_ID(id),
67 m_uniqueID(uniqueID) {
70 } // No link to a truth particle
73 m_partLink = std::make_unique<HepMcParticleLink>(
75 HepMcParticleLink::IS_BARCODE); // FIXME is barcode-based
76 }
77 }
78
82
85 : m_ID(cchSource.m_ID),
86 m_energy0(cchSource.m_energy0),
87 m_energy1(cchSource.m_energy1),
88 m_energy2(cchSource.m_energy2),
89 m_energy3(cchSource.m_energy3),
90 m_barcode(cchSource.m_barcode),
91 m_uniqueID(cchSource.m_uniqueID) {
94 } // No link to a truth particle
98 cchSource.particleUID(); // Try a look-up via HepMcParticleLink
99 }
100 }
101
104 if (this == &cchSource)
105 return *this;
106 m_ID = cchSource.m_ID;
107 m_energy0 = cchSource.m_energy0;
108 m_energy1 = cchSource.m_energy1;
109 m_energy2 = cchSource.m_energy2;
110 m_energy3 = cchSource.m_energy3;
111 m_barcode = cchSource.m_barcode;
112 m_uniqueID = cchSource.m_uniqueID;
115 } // No link to a truth particle
118 m_uniqueID =
119 cchSource.particleUID(); // Try a look-up via HepMcParticleLink
120 }
121 return *this;
122 }
123
126
128 Identifier cellID() const { return m_ID; }
129
131 double energyEM() const { return m_energy0; }
132
134 double energyNonEM() const { return m_energy1; }
135
137 double energyInvisible() const { return m_energy2; }
138
140 double energyEscaped() const { return m_energy3; }
141
143 double energyTotal() const {
145 }
146
148 double energy(unsigned int i) const {
149 switch (i) {
150 case 0:
151 return m_energy0;
152 case 1:
153 return m_energy1;
154 case 2:
155 return m_energy2;
156 case 3:
157 return m_energy3;
158 default:
159 return 0.;
160 }
161 }
162
164 int particleID() const { return m_barcode; }
165
168 int barcode() const { return particleID(); }
169
171 int particleUID() const {
173 return m_partLink->id();
174 } else {
175 return m_uniqueID;
176 }
177 }
178
180 double operator()(unsigned int i) const { return energy(i); }
181
183 bool Less(const CaloCalibrationHit* h) const {
184 if (m_ID != h->m_ID) {
185 return m_ID < h->m_ID;
186 } else {
188 h->particleUID() == HepMC::INVALID_PARTICLE_ID) {
189 return m_barcode < h->m_barcode;
190 } else {
191 return particleUID() < h->particleUID();
192 }
193 }
194 }
195
197 bool Equals(const CaloCalibrationHit& h) const {
198 bool equal = (m_ID == h.m_ID);
199 const bool validBarcode(particleID() != HepMC::INVALID_PARTICLE_ID &&
200 h.particleID() != HepMC::INVALID_PARTICLE_ID);
201 const bool validUID(particleUID() != HepMC::INVALID_PARTICLE_ID &&
202 h.particleUID() != HepMC::INVALID_PARTICLE_ID);
203 equal &= (validBarcode || validUID);
204 if (validBarcode) {
205 equal &= (m_barcode == h.m_barcode);
206 }
207 // Corrected bug: was comparing m_barcode instead of m_uniqueID
208 if (validUID) {
209 equal &= (particleUID() == h.particleUID());
210 }
211 return equal;
212 };
213
215 bool Equals(const CaloCalibrationHit* h) const { return Equals(*h); }
216
218 void Add(const CaloCalibrationHit* h) {
219 m_energy0 += h->m_energy0;
220 m_energy1 += h->m_energy1;
221 m_energy2 += h->m_energy2;
222 m_energy3 += h->m_energy3;
223 }
224
225 private:
228
235 double m_energy0{0.};
236 double m_energy1{0.};
237 double m_energy2{0.};
238 double m_energy3{0.};
239
244 std::unique_ptr<HepMcParticleLink>
245 m_partLink{}; // nullptr unless object was produced by reading
246 // TrackRecord_p1.
247};
248
249#endif // CaloSimEvent_CaloCalibrationHit_h
Header file for AthHistogramAlgorithm.
int m_uniqueID
identifier of Primary Particle which caused this hit
double m_energy0
energies (in MeV) deposited in this hit.
double energyNonEM() const
bool Less(const CaloCalibrationHit *h) const
Calibration hits are ordered by values of their identifiers.
double energy(unsigned int i) const
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.
virtual ~CaloCalibrationHit()
Destructor.
CaloCalibrationHit(const CaloCalibrationHit &cchSource)
Copy constructor.
void Add(const CaloCalibrationHit *h)
Method used for energy accumulation.
Identifier cellID() const
double energyEscaped() const
double energyInvisible() const
CaloCalibrationHit(Identifier id, double energyEM, double energyNonEM, double energyInvisible, double energyEscaped)
Standard constructor using identifer and energy by type.
CaloCalibrationHit()
Default constructor; should never be used, but provided for some persistency services.
Identifier m_ID
identifier of the cell in which this hit occured.
double operator()(unsigned int i) const
CaloCalibrationHit & operator=(const CaloCalibrationHit &cchSource)
Assignment operator.
double energyTotal() const
bool Equals(const CaloCalibrationHit &h) const
Calibration hits are ordered by values of their identifiers.
bool Equals(const CaloCalibrationHit *h) const
Calibration hits are ordered by values of their identifiers.
std::unique_ptr< HepMcParticleLink > m_partLink
int m_barcode
legacy barcode of Primary Particle which caused this hit
constexpr int INVALID_PARTICLE_ID
constexpr int UNDEFINED_ID