OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalParticle.h
Go to the documentation of this file.
1//
2// Class OpalParticle
3// This class represents the canonical coordinates of a particle.
4//
5// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#ifndef CLASSIC_OpalParticle_HH
19#define CLASSIC_OpalParticle_HH
20
21#include "Vektor.h"
22
24
25public:
26
27 // Particle coordinate numbers.
28 enum { X, Y, L, INVALID };
29
31 // Construct particle with the given coordinates.
32 OpalParticle(int64_t id,
33 double x, double px,
34 double y, double py,
35 double z, double pz,
36 double time,
37 double q, double m);
38
39 OpalParticle(int64_t id,
40 Vector_t const& R, Vector_t const& P,
41 double time, double q, double m);
42
44
46 void setX(double) ;
47
49 void setPx(double);
50
52 void setY(double) ;
53
55 void setPy(double);
56
58 void setZ(double) ;
59
61 void setPz(double);
62
64 void setR(Vector_t const&);
65
67 void setP(Vector_t const&);
68
70 void setTime(double t);
71
73 int64_t getId() const;
74
76 // Access coordinate by index for constant particle.
77 double operator[](unsigned int) const;
78
80 double getX() const;
81
83 double getPx() const;
84
86 double getY() const;
87
89 double getPy() const;
90
92 double getZ() const;
93
95 double getPz() const;
96
98 const Vector_t& getR() const;
99
101 const Vector_t& getP() const;
102
104 double getTime() const;
105
107 double getCharge() const;
108
110 double getMass() const;
111
112private:
113 int64_t id_m;
116 double time_m;
117 double charge_m;
118 double mass_m;
119};
120
121inline
122void OpalParticle::setX(double val)
123{
124 R_m[X] = val;
125}
126
127inline
128void OpalParticle::setY(double val)
129{
130 R_m[Y] = val;
131}
132
133inline
134void OpalParticle::setZ(double val)
135{
136 R_m[L] = val;
137}
138
139inline
140void OpalParticle::setPx(double val)
141{
142 P_m[X] = val;
143}
144
145inline
146void OpalParticle::setPy(double val)
147{
148 P_m[Y] = val;
149}
150
151inline
152void OpalParticle::setPz(double val)
153{
154 P_m[L] = val;
155}
156
157inline
159{
160 R_m = R;
161}
162
163inline
165{
166 P_m = P;
167}
168
169inline
171{
172 time_m = t;
173}
174
175inline
176int64_t OpalParticle::getId() const
177{
178 return id_m;
179}
180
181inline
182double OpalParticle::operator[](unsigned int i) const
183{
184 PAssert_LT(i, 6u);
185 return i % 2 == 0? R_m[i / 2]: P_m[i / 2];
186}
187
188inline
189double OpalParticle::getX() const
190{
191 return R_m[X];
192}
193
194inline
195double OpalParticle::getY() const
196{
197 return R_m[Y];
198}
199
200inline
201double OpalParticle::getZ() const
202{
203 return R_m[L];
204}
205
206inline
208{
209 return P_m[X];
210}
211
212inline
214{
215 return P_m[Y];
216}
217
218inline
220{
221 return P_m[L];
222}
223
224inline
226{
227 return R_m;
228}
229
230inline
232{
233 return P_m;
234}
235
236inline
238{
239 return time_m;
240}
241
242inline
244{
245 return charge_m;
246}
247
248inline
250{
251 return mass_m;
252}
253
254#endif // CLASSIC_OpalParticle_HH
#define PAssert_LT(a, b)
Definition: PAssert.h:106
void setPy(double)
Set the vertical momentum.
Definition: OpalParticle.h:146
double getPy() const
Get vertical momentum (no dimension).
Definition: OpalParticle.h:213
const Vector_t & getR() const
Get position in m.
Definition: OpalParticle.h:225
const Vector_t & getP() const
Get momentum.
Definition: OpalParticle.h:231
double getPz() const
Get relative momentum error (no dimension).
Definition: OpalParticle.h:219
int64_t id_m
Definition: OpalParticle.h:113
void setPx(double)
Set the horizontal momentum.
Definition: OpalParticle.h:140
void setPz(double)
Set the longitudinal momentum.
Definition: OpalParticle.h:152
void setZ(double)
Set longitudinal position in m.
Definition: OpalParticle.h:134
void setY(double)
Set the vertical displacement in m.
Definition: OpalParticle.h:128
double getY() const
Get vertical displacement in m.
Definition: OpalParticle.h:195
Vector_t P_m
Definition: OpalParticle.h:115
Vector_t R_m
Definition: OpalParticle.h:114
double getCharge() const
Get charge in Coulomb.
Definition: OpalParticle.h:243
double getZ() const
Get longitudinal displacement c*t in m.
Definition: OpalParticle.h:201
double operator[](unsigned int) const
Get coordinate.
Definition: OpalParticle.h:182
double getMass() const
Get mass in GeV/c^2.
Definition: OpalParticle.h:249
void setP(Vector_t const &)
Set momentum.
Definition: OpalParticle.h:164
double getTime() const
Get time.
Definition: OpalParticle.h:237
void setTime(double t)
Set the time.
Definition: OpalParticle.h:170
int64_t getId() const
Get the id of the particle.
Definition: OpalParticle.h:176
double getPx() const
Get horizontal momentum (no dimension).
Definition: OpalParticle.h:207
double getX() const
Get horizontal position in m.
Definition: OpalParticle.h:189
void setX(double)
Set the horizontal position in m.
Definition: OpalParticle.h:122
void setR(Vector_t const &)
Set position in m.
Definition: OpalParticle.h:158
double charge_m
Definition: OpalParticle.h:117