ATLAS Offline Software
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),
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 
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 
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 
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 
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 
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 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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::ISFParticle::isEqual
bool isEqual(const ISFParticle &rhs) const
Definition: ISFParticle.cxx:208
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
ISF::TruthBinding
Definition: TruthBinding.h:18
ISF::ISFParticle::m_partLink
const HepMcParticleLink * m_partLink
Definition: ISFParticle.h:205
ISF::ISFParticle
Definition: ISFParticle.h:42
ISF::ISFParticle::pdgCode
int pdgCode() const
PDG value.
x
#define x
ISF::ISFParticle::operator==
bool operator==(const ISFParticle &rhs) const
Comparisons.
Definition: ISFParticle.cxx:203
ISF::ISFParticle::id
int id() const
unique ID
ISF::ISFParticle::barcode
int barcode() const
the barcode
ISF::ISFParticle::position
const Amg::Vector3D & position() const
The current position of the ISFParticle.
ISF::ISFParticle::m_truth
TruthBinding * m_truth
< unique ID
Definition: ISFParticle.h:202
ISFParticle.h
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
z
#define z
ISF::ISFParticle::operator=
ISFParticle & operator=(const ISFParticle &rhs)
Assignment operator.
Definition: ISFParticle.cxx:149
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
Athena_test::isEqual
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition: FLOATassert.h:26
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ISF::ISFParticle::ISFParticle
ISFParticle()=delete
disallow default constructor
ISF::ISFParticle::timeStamp
double timeStamp() const
Timestamp of the ISFParticle.
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
ISF::ISFParticle::momentum
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ISF::ISFParticle::charge
double charge() const
charge of the particle
ISF::ISFParticle::history
const ParticleHistory & history() const
the particle's full history
ISF::ISFParticle::isIdent
bool isIdent(const ISFParticle &rhs) const
Definition: ISFParticle.cxx:252
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
ISF::ISFParticle::getParticleLink
const HepMcParticleLink * getParticleLink() const
HepMcParticleLink accessors.
Definition: ISFParticle.h:172
ISF::DefaultParticleOrder
const ParticleOrder DefaultParticleOrder
Definition: ParticleOrder.h:17
ISF::ISFParticle::~ISFParticle
~ISFParticle()
Destructor.
Definition: ISFParticle.cxx:142
y
#define y
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ISF
ISFParticleOrderedQueue.
Definition: PrimaryParticleInformation.h:13
ISF::ISFParticle::status
int status() const
Definition: ISFParticle.h:189
merge.status
status
Definition: merge.py:17
ISF::ISFParticle::getUserInformation
const ParticleUserInformation * getUserInformation() const
get/set ParticleUserInformation
ISF::ISFParticle::getTruthBinding
const TruthBinding * getTruthBinding() const
pointer to the simulation truth - optional, can be 0
ISF::ISFParticle::mass
double mass() const
mass of the particle