ATLAS Offline Software
Loading...
Searching...
No Matches
ISFParticle.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cmath> // fabs
8
10 const Amg::Vector3D& pos,
11 const Amg::Vector3D& mom,
12 double mass,
13 double charge,
14 int pdgCode,
15 int status,
16 double time,
17 const ISFParticle &parent,
18 int id,
19 int barcode,
20 TruthBinding* truth,
21 const HepMcParticleLink* partLink):
22 m_position(pos),
23 m_momentum(mom),
24 m_mass(mass),
28 m_tstamp(time),
29 m_history(parent.history()),
30 m_barcode(barcode), // TODO drop this soon
31 m_uid(id),
32 m_truth(truth),
34 m_userInfo(nullptr),
35 m_partLink(partLink)
36{
37
38}
39
41 const HepGeom::Point3D<double>& pos,
42 const HepGeom::Vector3D<double>& mom,
43 double mass,
44 double charge,
45 int pdgCode,
46 int status,
47 double time,
48 const ISFParticle &parent,
49 int id,
50 int barcode,
51 TruthBinding* truth,
52 const HepMcParticleLink* partLink):
53 m_position( pos.x(), pos.y(), pos.z()),
54 m_momentum( mom.x(), mom.y(), mom.z()),
55 m_mass(mass),
59 m_tstamp(time),
60 m_history(parent.history()),
61 m_barcode(barcode), // TODO drop this soon
62 m_uid(id),
63 m_truth(truth),
65 m_userInfo(nullptr),
66 m_partLink(partLink)
67{
68
69}
70
72 const Amg::Vector3D& pos,
73 const Amg::Vector3D& mom,
74 double mass,
75 double charge,
76 int pdgCode,
77 int status,
78 double time,
79 const DetRegionSvcIDPair &origin,
80 int id,
81 int barcode,
82 TruthBinding* truth,
83 const HepMcParticleLink* partLink):
84 m_position(pos),
85 m_momentum(mom),
86 m_mass(mass),
90 m_tstamp(time),
91 m_history(1, origin),
92 m_barcode(barcode), // TODO drop this soon
93 m_uid(id),
94 m_truth(truth),
96 m_userInfo(nullptr),
97 m_partLink(partLink)
98{
99
100}
101
103 m_position(isfp.position()),
104 m_momentum(isfp.momentum()),
105 m_mass(isfp.mass()),
106 m_charge(isfp.charge()),
107 m_pdgCode(isfp.pdgCode()),
108 m_status(isfp.status()),
109 m_tstamp(isfp.timeStamp()),
110 m_history(isfp.history()),
111 m_barcode(isfp.barcode()), // TODO drop this soon
112 m_uid(isfp.id()),
113 m_truth(nullptr),
115 m_userInfo(nullptr)
116{
117 const TruthBinding *truth = isfp.getTruthBinding();
118 if (truth) {
119 m_truth = new TruthBinding(*truth);
120 }
121 m_partLink = ((isfp.getParticleLink()) ? new HepMcParticleLink(*isfp.getParticleLink()) : nullptr);
122}
123
125 m_position(isfp.position()),
126 m_momentum(isfp.momentum()),
127 m_mass(isfp.mass()),
128 m_charge(isfp.charge()),
129 m_pdgCode(isfp.pdgCode()),
130 m_status(isfp.status()),
131 m_tstamp(isfp.timeStamp()),
132 m_history(isfp.history()),
133 m_barcode(isfp.barcode()), // TODO drop this soon
134 m_uid(isfp.id()),
135 m_truth(isfp.getTruthBinding()),
136 m_order(isfp.getOrder()),
139{
140}
141
143 delete m_truth;
144 delete m_userInfo;
145 if (m_partLink) delete m_partLink;
146}
147
148// cppcheck-suppress operatorEqVarError; m_order not copied
150{
151
152 if (this != &rhs) {
153 m_position = rhs.position();
154 m_momentum = rhs.momentum();
155 m_mass = rhs.mass();
156 m_charge = rhs.charge();
157 m_pdgCode = rhs.pdgCode();
158 m_status = rhs.status();
159 m_tstamp = rhs.timeStamp();
160 m_history = rhs.history();
161 m_barcode = rhs.barcode(); // TODO drop this soon
162 m_uid = rhs.id();
163
164 delete m_truth;
165 m_truth = nullptr;
166
167 const TruthBinding *rhsTruth = rhs.getTruthBinding();
168 if (rhsTruth) {
169 m_truth = new TruthBinding(*rhsTruth);
170 }
171 m_partLink = ((rhs.getParticleLink()) ? new HepMcParticleLink(*rhs.getParticleLink()): nullptr);
172
173 delete m_userInfo;
174 m_userInfo = nullptr;
175 }
176
177 return *this;
178}
179
180// cppcheck-suppress operatorEqVarError; m_order not copied
182{
183 m_position = rhs.position();
184 m_momentum = rhs.momentum();
185 m_mass = rhs.mass();
186 m_charge = rhs.charge();
187 m_pdgCode = rhs.pdgCode();
188 m_status = rhs.status();
189 m_tstamp = rhs.timeStamp();
190 m_history = rhs.history();
191 m_barcode = rhs.barcode(); // TODO drop this soon
192 m_uid = rhs.id();
193 delete m_truth;
194 m_truth = rhs.getTruthBinding();
195 delete m_userInfo;
196 m_userInfo = rhs.getUserInformation();
197 if (m_partLink) delete m_partLink;
198 m_partLink = rhs.getParticleLink();
199
200 return *this;
201}
202
204{
205 return isEqual(rhs);
206}
207
209{
210 double epsilon = 1e-6;
211
212 bool pass = true;
213 pass &= m_position == rhs.position();
214 pass &= m_momentum == rhs.momentum();
215 pass &= std::fabs(m_mass-rhs.mass()) < epsilon;
216 pass &= std::fabs(m_charge-rhs.charge()) < epsilon;
217 pass &= m_pdgCode == rhs.pdgCode();
218 pass &= m_status == rhs.status();
219 pass &= std::fabs(m_tstamp-rhs.timeStamp()) < epsilon;
220 pass &= m_history == rhs.history();
221 pass &= m_barcode == rhs.barcode(); // TODO drop this soon
222 pass &= m_uid == rhs.id();
223 {
224 const auto rhsTruthPtr = rhs.getTruthBinding();
225 if (m_truth && rhsTruthPtr) {
226 pass &= *m_truth == *rhsTruthPtr;
227 } else {
228 pass &= m_truth == rhsTruthPtr; // must be both nullptr to pass
229 }
230 }
231
232 {
233 const auto rhsUserInfoPtr = rhs.getUserInformation();
234 if (m_userInfo && rhsUserInfoPtr) {
235 pass &= *m_userInfo == *rhsUserInfoPtr;
236 } else {
237 pass &= m_userInfo == rhsUserInfoPtr; // must be both nullptr to pass
238 }
239 }
240
241 {
242 const auto rhsPartLinkPtr = rhs.getParticleLink();
243 if(m_partLink && rhsPartLinkPtr) {
244 pass &= *m_partLink == *rhsPartLinkPtr;
245 } else {
246 pass &= m_partLink == rhsPartLinkPtr; // must be both nullptr to pass
247 }
248 }
249 return pass;
250}
251
253{
254 bool pass = true;
255 pass &= m_position == rhs.position();
256 pass &= m_momentum == rhs.momentum();
257 pass &= m_mass == rhs.mass();
258 pass &= m_charge == rhs.charge();
259 pass &= m_pdgCode == rhs.pdgCode();
260 pass &= m_status == rhs.status();
261 pass &= m_tstamp == rhs.timeStamp();
262 pass &= m_history == rhs.history();
263 pass &= m_barcode == rhs.barcode(); // TODO drop this soon
264 pass &= m_uid == rhs.id();
265 pass &= m_truth && rhs.getTruthBinding();
266 pass &= m_userInfo == rhs.getUserInformation();
267 pass &= m_partLink == rhs.getParticleLink();
268 return pass;
269}
#define y
#define x
#define z
The generic ISF particle definition,.
Definition ISFParticle.h:42
TruthBinding * m_truth
< unique ID
const TruthBinding * getTruthBinding() const
pointer to the simulation truth - optional, can be 0
Amg::Vector3D m_momentum
ParticleOrder m_order
particle simulation order
int barcode() const
the barcode
double charge() const
charge of the particle
const HepMcParticleLink * getParticleLink() const
HepMcParticleLink accessors.
int id() const
unique ID
~ISFParticle()
Destructor.
const HepMcParticleLink * m_partLink
const ParticleUserInformation * getUserInformation() const
get/set ParticleUserInformation
Amg::Vector3D m_position
ISFParticle & operator=(const ISFParticle &rhs)
Assignment operator.
int m_barcode
barcode TODO remove in favour of m_status + m_uid
ISFParticle()=delete
disallow default constructor
ParticleOrder getOrder() const
return the particle order (eg used to assure ID->Calo->MS simulation order)
const ParticleHistory & history() const
the particle's full history
bool isEqual(const ISFParticle &rhs) const
ParticleHistory m_history
bool isIdent(const ISFParticle &rhs) const
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
double timeStamp() const
Timestamp of the ISFParticle.
ParticleUserInformation * m_userInfo
user information stored with the ISFParticle
bool operator==(const ISFParticle &rhs) const
Comparisons.
const Amg::Vector3D & position() const
The current position of the ISFParticle.
int pdgCode() const
PDG value.
double mass() const
mass of the particle
int status() const
Eigen::Matrix< double, 3, 1 > Vector3D
ISFParticleOrderedQueue.
std::pair< AtlasDetDescr::AtlasRegion, ISF::SimSvcID > DetRegionSvcIDPair
the datatype to be used to store each individual particle hop
Definition ISFParticle.h:30
const ParticleOrder DefaultParticleOrder