OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Algorithms/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 <cstddef>
22#include "OPALTypes.h"
23
24class OpalParticle {
25public:
26 // Particle coordinate numbers.
27 enum { X, Y, L, INVALID };
28
30 // Construct particle with the given coordinates.
32 std::size_t id, double x, double px, double y, double py, double z, double pz, double time,
33 double q, double m);
34
36 std::size_t id, Vector_t<double, 3> const& R, Vector_t<double, 3> const& P, double time,
37 double q, double m);
38
40
42 void setX(double);
43
45 void setPx(double);
46
48 void setY(double);
49
51 void setPy(double);
52
54 void setZ(double);
55
57 void setPz(double);
58
61
64
66 void setTime(double t);
67
69 int64_t getId() const;
70
72 // Access coordinate by index for constant particle.
73 double operator[](unsigned int) const;
74
76 double getX() const;
77
79 double getPx() const;
80
82 double getY() const;
83
85 double getPy() const;
86
88 double getZ() const;
89
91 double getPz() const;
92
94 const Vector_t<double, 3>& getR() const;
95
97 const Vector_t<double, 3>& getP() const;
98
100 double getTime() const;
101
103 double getCharge() const;
104
106 double getMass() const;
107
108private:
109 int64_t id_m;
112 double time_m;
113 double charge_m;
114 double mass_m;
115};
116
117inline void OpalParticle::setX(double val) {
118 R_m[X] = val;
119}
120
121inline void OpalParticle::setY(double val) {
122 R_m[Y] = val;
123}
124
125inline void OpalParticle::setZ(double val) {
126 R_m[L] = val;
127}
128
129inline void OpalParticle::setPx(double val) {
130 P_m[X] = val;
131}
132
133inline void OpalParticle::setPy(double val) {
134 P_m[Y] = val;
135}
136
137inline void OpalParticle::setPz(double val) {
138 P_m[L] = val;
139}
140
141inline void OpalParticle::setR(Vector_t<double, 3> const& R) {
142 R_m = R;
143}
144
145inline void OpalParticle::setP(Vector_t<double, 3> const& P) {
146 P_m = P;
147}
148
149inline void OpalParticle::setTime(double t) {
150 time_m = t;
151}
152
153inline int64_t OpalParticle::getId() const {
154 return id_m;
155}
156
157inline double OpalParticle::operator[](unsigned int i) const {
158 PAssert_LT(i, 6u);
159 return i % 2 == 0 ? R_m[i / 2] : P_m[i / 2];
160}
161
162inline double OpalParticle::getX() const {
163 return R_m[X];
164}
165
166inline double OpalParticle::getY() const {
167 return R_m[Y];
168}
169
170inline double OpalParticle::getZ() const {
171 return R_m[L];
172}
173
174inline double OpalParticle::getPx() const {
175 return P_m[X];
176}
177
178inline double OpalParticle::getPy() const {
179 return P_m[Y];
180}
181
182inline double OpalParticle::getPz() const {
183 return P_m[L];
184}
185
186inline const Vector_t<double, 3>& OpalParticle::getR() const {
187 return R_m;
188}
189
190inline const Vector_t<double, 3>& OpalParticle::getP() const {
191 return P_m;
192}
193
194inline double OpalParticle::getTime() const {
195 return time_m;
196}
197
198inline double OpalParticle::getCharge() const {
199 return charge_m;
200}
201
202inline double OpalParticle::getMass() const {
203 return mass_m;
204}
205
206#endif // CLASSIC_OpalParticle_HH
ippl::Vector< T, Dim > Vector_t
void setPy(double)
Set the vertical momentum.
double getPy() const
Get vertical momentum (no dimension).
Vector_t< double, 3 > R_m
double getPz() const
Get relative momentum error (no dimension).
Vector_t< double, 3 > P_m
const Vector_t< double, 3 > & getP() const
Get momentum.
void setPx(double)
Set the horizontal momentum.
void setPz(double)
Set the longitudinal momentum.
void setZ(double)
Set longitudinal position in m.
void setY(double)
Set the vertical displacement in m.
double getY() const
Get vertical displacement in m.
void setP(Vector_t< double, 3 > const &)
Set momentum.
double getCharge() const
Get charge in Coulomb.
double getZ() const
Get longitudinal displacement c*t in m.
double operator[](unsigned int) const
Get coordinate.
double getMass() const
Get mass in GeV/c^2.
double getTime() const
Get time.
void setTime(double t)
Set the time.
int64_t getId() const
Get the id of the particle.
double getPx() const
Get horizontal momentum (no dimension).
double getX() const
Get horizontal position in m.
void setR(Vector_t< double, 3 > const &)
Set position in m.
void setX(double)
Set the horizontal position in m.
const Vector_t< double, 3 > & getR() const
Get position in m.