OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 
23 class OpalParticle {
24 
25 public:
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 
43  OpalParticle();
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 
112 private:
113  int64_t id_m;
116  double time_m;
117  double charge_m;
118  double mass_m;
119 };
120 
121 inline
122 void OpalParticle::setX(double val)
123 {
124  R_m[X] = val;
125 }
126 
127 inline
128 void OpalParticle::setY(double val)
129 {
130  R_m[Y] = val;
131 }
132 
133 inline
134 void OpalParticle::setZ(double val)
135 {
136  R_m[L] = val;
137 }
138 
139 inline
140 void OpalParticle::setPx(double val)
141 {
142  P_m[X] = val;
143 }
144 
145 inline
146 void OpalParticle::setPy(double val)
147 {
148  P_m[Y] = val;
149 }
150 
151 inline
152 void OpalParticle::setPz(double val)
153 {
154  P_m[L] = val;
155 }
156 
157 inline
159 {
160  R_m = R;
161 }
162 
163 inline
165 {
166  P_m = P;
167 }
168 
169 inline
170 void OpalParticle::setTime(double t)
171 {
172  time_m = t;
173 }
174 
175 inline
176 int64_t OpalParticle::getId() const
177 {
178  return id_m;
179 }
180 
181 inline
182 double 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 
188 inline
189 double OpalParticle::getX() const
190 {
191  return R_m[X];
192 }
193 
194 inline
195 double OpalParticle::getY() const
196 {
197  return R_m[Y];
198 }
199 
200 inline
201 double OpalParticle::getZ() const
202 {
203  return R_m[L];
204 }
205 
206 inline
207 double OpalParticle::getPx() const
208 {
209  return P_m[X];
210 }
211 
212 inline
213 double OpalParticle::getPy() const
214 {
215  return P_m[Y];
216 }
217 
218 inline
219 double OpalParticle::getPz() const
220 {
221  return P_m[L];
222 }
223 
224 inline
226 {
227  return R_m;
228 }
229 
230 inline
232 {
233  return P_m;
234 }
235 
236 inline
237 double OpalParticle::getTime() const
238 {
239  return time_m;
240 }
241 
242 inline
244 {
245  return charge_m;
246 }
247 
248 inline
249 double OpalParticle::getMass() const
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