ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Particle.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Particle.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2018-2020 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#pragma once
10
11
#include <cmath>
12
#include <iosfwd>
13
#include <limits>
14
15
#include "
Acts/Utilities/Definitions.hpp
"
16
#include "
Acts/Utilities/PdgParticle.hpp
"
17
#include "
ActsFatras/EventData/Barcode.hpp
"
18
#include "
ActsFatras/EventData/ProcessType.hpp
"
19
20
namespace
ActsFatras {
21
23
class
Particle
{
24
public
:
25
using
Scalar
= double;
26
using
Vector3
=
Acts::ActsVector<Scalar, 3>
;
27
using
Vector4
=
Acts::ActsVector<Scalar, 4>
;
28
30
Particle
() =
default
;
40
Particle
(
Barcode
particleId
,
Acts::PdgParticle
pdg
,
Scalar
charge
,
41
Scalar
mass
)
42
:
m_particleId
(particleId),
m_pdg
(pdg),
m_charge
(charge),
m_mass
(mass) {}
49
Particle
(
Barcode
particleId
,
Acts::PdgParticle
pdg
);
50
Particle
(
const
Particle
&) =
default
;
51
Particle
(
Particle
&&) =
default
;
52
Particle
&
operator=
(
const
Particle
&) =
default
;
53
Particle
&
operator=
(
Particle
&&) =
default
;
54
60
Particle
withParticleId
(
Barcode
particleId
)
const
{
61
Particle
p
= *
this
;
62
p.
m_particleId
=
particleId
;
63
return
p
;
64
}
65
67
Particle
&
setProcess
(
ProcessType
proc) {
return
m_process
= proc, *
this
; }
71
Particle
&
setPosition4
(
const
Vector4
&pos4) {
72
m_position4
= pos4;
73
return
*
this
;
74
}
76
Particle
&
setPosition4
(
const
Vector3
&
position
,
Scalar
time
) {
77
m_position4
.head<3>() = position;
78
m_position4
[3] =
time
;
79
return
*
this
;
80
}
82
Particle
&
setPosition4
(
Scalar
x
,
Scalar
y
,
Scalar
z
,
Scalar
time
) {
83
m_position4
[0] =
x
;
84
m_position4
[1] =
y
;
85
m_position4
[2] =
z
;
86
m_position4
[3] =
time
;
87
return
*
this
;
88
}
90
Particle
&
setDirection
(
const
Vector3
&direction) {
91
m_unitDirection
= direction;
92
m_unitDirection
.normalize();
93
return
*
this
;
94
}
96
Particle
&
setDirection
(
Scalar
dx
,
Scalar
dy
,
Scalar
dz
) {
97
m_unitDirection
[0] =
dx
;
98
m_unitDirection
[1] =
dy
;
99
m_unitDirection
[2] =
dz
;
100
m_unitDirection
.normalize();
101
return
*
this
;
102
}
104
Particle
&
setAbsMomentum
(
Scalar
absMomentum
) {
105
m_absMomentum
=
absMomentum
;
106
return
*
this
;
107
}
113
Particle
&
correctEnergy
(
Scalar
delta
) {
114
const
auto
newEnergy = std::hypot(
m_mass
,
m_absMomentum
) +
delta
;
115
if
(newEnergy <=
m_mass
) {
116
m_absMomentum
=
Scalar
(0);
117
}
else
{
118
m_absMomentum
= std::sqrt(newEnergy * newEnergy -
m_mass
*
m_mass
);
119
}
120
return
*
this
;
121
}
122
124
constexpr
Barcode
particleId
()
const
{
return
m_particleId
; }
126
constexpr
ProcessType
process
()
const
{
return
m_process
; }
128
constexpr
Acts::PdgParticle
pdg
()
const
{
return
m_pdg
; }
130
constexpr
Scalar
charge
()
const
{
return
m_charge
; }
132
constexpr
Scalar
mass
()
const
{
return
m_mass
; }
133
137
constexpr
const
Vector4
&
position4
()
const
{
return
m_position4
; }
139
auto
position
()
const
{
return
m_position4
.head<3>(); }
141
Scalar
time
()
const
{
return
m_position4
[3]; }
145
Vector4
momentum4
()
const
{
146
Vector4
mom4;
147
// stored direction is always normalized
148
mom4[0] =
m_absMomentum
*
m_unitDirection
[0];
149
mom4[1] =
m_absMomentum
* m_unitDirection[1];
150
mom4[2] =
m_absMomentum
* m_unitDirection[2];
151
mom4[3] =
energy
();
152
return
mom4;
153
}
155
const
Vector3
&
unitDirection
()
const
{
return
m_unitDirection
; }
157
Scalar
transverseMomentum
()
const
{
158
return
m_absMomentum
*
m_unitDirection
.head<2>().
norm
();
159
}
161
constexpr
Scalar
absMomentum
()
const
{
return
m_absMomentum
; }
163
Scalar
energy
()
const
{
return
std::hypot(
m_mass
,
m_absMomentum
); }
164
166
constexpr
operator
bool()
const
{
return
Scalar
(0) <
m_absMomentum
; }
168
constexpr
bool
operator!
()
const
{
return
m_absMomentum
<=
Scalar
(0); }
169
174
constexpr
Particle
&
setMaterialPassed
(
Scalar
pathX0,
Scalar
pathL0) {
175
m_pathX0
= pathX0;
176
m_pathL0
= pathL0;
177
return
*
this
;
178
}
183
constexpr
Particle
&
setMaterialLimits
(
Scalar
limitX0,
Scalar
limitL0) {
184
m_limitX0
= limitX0;
185
m_limitL0
= limitL0;
186
return
*
this
;
187
}
189
constexpr
Scalar
pathInX0
()
const
{
return
m_pathX0
; }
191
constexpr
Scalar
pathInL0
()
const
{
return
m_pathL0
; }
193
constexpr
Scalar
pathLimitX0
()
const
{
return
m_limitX0
; }
195
constexpr
Scalar
pathLimitL0
()
const
{
return
m_limitL0
; }
196
197
private
:
198
// identity, i.e. things that do not change over the particle lifetime.
200
Barcode
m_particleId
;
202
ProcessType
m_process
=
ProcessType::eUndefined
;
204
Acts::PdgParticle
m_pdg
=
Acts::PdgParticle::eInvalid
;
205
// Particle charge and mass.
206
Scalar
m_charge
=
Scalar
(0);
207
Scalar
m_mass
=
Scalar
(0);
208
// kinematics, i.e. things that change over the particle lifetime.
209
Vector3
m_unitDirection
= Vector3::UnitZ();
210
Scalar
m_absMomentum
=
Scalar
(0);
211
Vector4
m_position4
= Vector4::Zero();
212
// simulation-specific X0/L0 information and limits
213
// these values are here to simplify the simulation of (nuclear) interactions.
214
// instead of checking at every surface whether an interaction should occur we
215
// can draw an overall limit once. the relevant interaction only needs to
216
// be executed once the limit is reached.
217
// this information is not really particle-specific and should probably be
218
// handled separately. for now, storing it directly here is the simplest
219
// solution.
220
Scalar
m_pathX0
=
Scalar
(0);
221
Scalar
m_pathL0
=
Scalar
(0);
222
Scalar
m_limitX0
=
std::numeric_limits<Scalar>::max
();
223
Scalar
m_limitL0
=
std::numeric_limits<Scalar>::max
();
224
};
225
226
std::ostream &
operator<<
(std::ostream &os,
const
Particle
&
particle
);
227
228
}
// namespace ActsFatras
acts
blob
master
Fatras
include
ActsFatras
EventData
Particle.hpp
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:24
using
1.8.2 with
ECCE GitHub integration