ATLAS Offline Software
Loading...
Searching...
No Matches
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
22
23{
24 public:
25
44
54 double energyEM,
55 double energyNonEM,
56 double energyInvisible,
57 double energyEscaped,
58 int barcode,
59 int uniqueID = HepMC::INVALID_PARTICLE_ID):
60 m_ID(id),
66 m_uniqueID(uniqueID)
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
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
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{
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
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
211private:
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
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