ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_Core
ISF_Event
src
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
5
#include "
ISF_Event/ISFParticle.h
"
6
7
#include <cmath>
// fabs
8
9
ISF::ISFParticle::ISFParticle
(
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
),
25
m_charge
(
charge
),
26
m_pdgCode
(
pdgCode
),
27
m_status
(
status
),
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),
33
m_order
(
ISF
::
DefaultParticleOrder
),
34
m_userInfo
(nullptr),
35
m_partLink
(partLink)
36
{
37
38
}
39
40
ISF::ISFParticle::ISFParticle
(
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
),
56
m_charge
(
charge
),
57
m_pdgCode
(
pdgCode
),
58
m_status
(
status
),
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),
64
m_order
(
ISF
::
DefaultParticleOrder
),
65
m_userInfo
(nullptr),
66
m_partLink
(partLink)
67
{
68
69
}
70
71
ISF::ISFParticle::ISFParticle
(
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
),
87
m_charge
(
charge
),
88
m_pdgCode
(
pdgCode
),
89
m_status
(
status
),
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),
95
m_order
(
ISF
::
DefaultParticleOrder
),
96
m_userInfo
(nullptr),
97
m_partLink
(partLink)
98
{
99
100
}
101
102
ISF::ISFParticle::ISFParticle
(
const
ISFParticle
& isfp):
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),
114
m_order
(
ISF
::
DefaultParticleOrder
),
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
124
ISF::ISFParticle::ISFParticle
(
ISFParticle
&& isfp):
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
()),
137
m_userInfo
(isfp.
getUserInformation
()),
138
m_partLink
(isfp.
getParticleLink
())
139
{
140
}
141
142
ISF::ISFParticle::~ISFParticle
() {
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
149
ISF::ISFParticle
&
ISF::ISFParticle::operator=
(
const
ISF::ISFParticle
& rhs)
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
181
ISF::ISFParticle
&
ISF::ISFParticle::operator=
(
ISF::ISFParticle
&& rhs)
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
203
bool
ISF::ISFParticle::operator==
(
const
ISF::ISFParticle
& rhs)
const
204
{
205
return
isEqual
(rhs);
206
}
207
208
bool
ISF::ISFParticle::isEqual
(
const
ISF::ISFParticle
& rhs)
const
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
252
bool
ISF::ISFParticle::isIdent
(
const
ISF::ISFParticle
& rhs)
const
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
}
ISFParticle.h
y
#define y
x
#define x
z
#define z
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition
HepMcParticleLink.h:72
ISF::ISFParticle
The generic ISF particle definition,.
Definition
ISFParticle.h:42
ISF::ISFParticle::m_truth
TruthBinding * m_truth
< unique ID
Definition
ISFParticle.h:202
ISF::ISFParticle::getTruthBinding
const TruthBinding * getTruthBinding() const
pointer to the simulation truth - optional, can be 0
ISF::ISFParticle::m_momentum
Amg::Vector3D m_momentum
Definition
ISFParticle.h:193
ISF::ISFParticle::m_order
ParticleOrder m_order
particle simulation order
Definition
ISFParticle.h:203
ISF::ISFParticle::m_uid
int m_uid
Definition
ISFParticle.h:201
ISF::ISFParticle::barcode
int barcode() const
the barcode
ISF::ISFParticle::charge
double charge() const
charge of the particle
ISF::ISFParticle::getParticleLink
const HepMcParticleLink * getParticleLink() const
HepMcParticleLink accessors.
Definition
ISFParticle.h:172
ISF::ISFParticle::id
int id() const
unique ID
ISF::ISFParticle::~ISFParticle
~ISFParticle()
Destructor.
Definition
ISFParticle.cxx:142
ISF::ISFParticle::m_partLink
const HepMcParticleLink * m_partLink
Definition
ISFParticle.h:205
ISF::ISFParticle::getUserInformation
const ParticleUserInformation * getUserInformation() const
get/set ParticleUserInformation
ISF::ISFParticle::m_position
Amg::Vector3D m_position
Definition
ISFParticle.h:192
ISF::ISFParticle::operator=
ISFParticle & operator=(const ISFParticle &rhs)
Assignment operator.
Definition
ISFParticle.cxx:149
ISF::ISFParticle::m_barcode
int m_barcode
barcode TODO remove in favour of m_status + m_uid
Definition
ISFParticle.h:200
ISF::ISFParticle::ISFParticle
ISFParticle()=delete
disallow default constructor
ISF::ISFParticle::m_pdgCode
int m_pdgCode
Definition
ISFParticle.h:196
ISF::ISFParticle::getOrder
ParticleOrder getOrder() const
return the particle order (eg used to assure ID->Calo->MS simulation order)
ISF::ISFParticle::history
const ParticleHistory & history() const
the particle's full history
ISF::ISFParticle::m_status
int m_status
Definition
ISFParticle.h:197
ISF::ISFParticle::isEqual
bool isEqual(const ISFParticle &rhs) const
Definition
ISFParticle.cxx:208
ISF::ISFParticle::m_tstamp
double m_tstamp
Definition
ISFParticle.h:198
ISF::ISFParticle::m_history
ParticleHistory m_history
Definition
ISFParticle.h:199
ISF::ISFParticle::isIdent
bool isIdent(const ISFParticle &rhs) const
Definition
ISFParticle.cxx:252
ISF::ISFParticle::m_charge
double m_charge
Definition
ISFParticle.h:195
ISF::ISFParticle::momentum
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
ISF::ISFParticle::timeStamp
double timeStamp() const
Timestamp of the ISFParticle.
ISF::ISFParticle::m_userInfo
ParticleUserInformation * m_userInfo
user information stored with the ISFParticle
Definition
ISFParticle.h:204
ISF::ISFParticle::operator==
bool operator==(const ISFParticle &rhs) const
Comparisons.
Definition
ISFParticle.cxx:203
ISF::ISFParticle::position
const Amg::Vector3D & position() const
The current position of the ISFParticle.
ISF::ISFParticle::m_mass
double m_mass
Definition
ISFParticle.h:194
ISF::ISFParticle::pdgCode
int pdgCode() const
PDG value.
ISF::ISFParticle::mass
double mass() const
mass of the particle
ISF::ISFParticle::status
int status() const
Definition
ISFParticle.h:189
ISF::TruthBinding
Definition
TruthBinding.h:18
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
ISF
ISFParticleOrderedQueue.
Definition
PrimaryParticleInformation.h:13
ISF::DetRegionSvcIDPair
std::pair< AtlasDetDescr::AtlasRegion, ISF::SimSvcID > DetRegionSvcIDPair
the datatype to be used to store each individual particle hop
Definition
ISFParticle.h:30
ISF::DefaultParticleOrder
const ParticleOrder DefaultParticleOrder
Definition
ParticleOrder.h:17
Generated on
for ATLAS Offline Software by
1.17.0