OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 OPALX_OpalParticle_HH
19#define OPALX_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,
33 double time, 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) { R_m[X] = val; }
118
119inline void OpalParticle::setY(double val) { R_m[Y] = val; }
120
121inline void OpalParticle::setZ(double val) { R_m[L] = val; }
122
123inline void OpalParticle::setPx(double val) { P_m[X] = val; }
124
125inline void OpalParticle::setPy(double val) { P_m[Y] = val; }
126
127inline void OpalParticle::setPz(double val) { P_m[L] = val; }
128
129inline void OpalParticle::setR(Vector_t<double, 3> const& R) { R_m = R; }
130
131inline void OpalParticle::setP(Vector_t<double, 3> const& P) { P_m = P; }
132
133inline void OpalParticle::setTime(double t) { time_m = t; }
134
135inline int64_t OpalParticle::getId() const { return id_m; }
136
137inline double OpalParticle::operator[](unsigned int i) const {
138 PAssert_LT(i, 6u);
139 return i % 2 == 0 ? R_m[i / 2] : P_m[i / 2];
140}
141
142inline double OpalParticle::getX() const { return R_m[X]; }
143
144inline double OpalParticle::getY() const { return R_m[Y]; }
145
146inline double OpalParticle::getZ() const { return R_m[L]; }
147
148inline double OpalParticle::getPx() const { return P_m[X]; }
149
150inline double OpalParticle::getPy() const { return P_m[Y]; }
151
152inline double OpalParticle::getPz() const { return P_m[L]; }
153
154inline const Vector_t<double, 3>& OpalParticle::getR() const { return R_m; }
155
156inline const Vector_t<double, 3>& OpalParticle::getP() const { return P_m; }
157
158inline double OpalParticle::getTime() const { return time_m; }
159
160inline double OpalParticle::getCharge() const { return charge_m; }
161
162inline double OpalParticle::getMass() const { return mass_m; }
163
164#endif // OPALX_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.