OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
PartData.h
Go to the documentation of this file.
1 //
2 // Class PartData
3 // PartData represents a set of reference values for use in algorithms.
4 //
5 // Copyright (c) 200x - 2023, 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 MAD_PartData_HH
19 #define MAD_PartData_HH
20 
38 class PartData {
39 
40 public:
42  // Inputs are:
43  // [DL]
44  // [DT]charge[DD]The charge per particle in proton charges.
45  // [DT]mass[DD]The particle mass in eV.
46  // [DT]momentum[DD]The reference momentum per particle in eV.
47  // [/DL]
48  PartData(double charge, double mass, double momentum);
49 
50  PartData();
51 
53  double getQ() const;
54 
56  double getM() const;
57 
59  double getP() const;
60 
62  double getE() const;
63 
65  double getBeta() const;
66 
68  double getGamma() const;
69 
71  double getMomentumTolerance() const;
72 
74  void setQ(double q);
75 
77  void setM(double m);
78 
80  // Input is the momentum in eV.
81  void setP(double p);
82 
84  // Input is the energy in eV.
85  void setE(double E);
86 
88  // Input is the relativistic beta = v/c.
89  void setBeta(double beta);
90 
92  // Input is the relativistic gamma = E/(m*c*c).
93  void setGamma(double gamma);
94 
96  void setMomentumTolerance(double tolerance);
97 
98 protected:
99  // The reference information.
100  double charge_m; // Particle charge.
101  double mass_m; // Particle mass.
102  double beta_m; // Particle velocity divided by c.
103  double gamma_m; // Particle energy divided by particle mass.
104  double momentumTolerance_m = 1e-2; // Tolerance to momentum deviations.
105 };
106 
107 
108 // Inline functions.
109 // ------------------------------------------------------------------------
110 inline void PartData::setM(double m) {
111  mass_m = m;
112 }
113 
114 inline void PartData::setQ(double q) {
115  charge_m = q;
116 }
117 
118 inline double PartData::getQ() const {
119  return charge_m;
120 }
121 
122 inline double PartData::getM() const {
123  return mass_m;
124 }
125 
126 inline double PartData::getP() const {
127  return beta_m * gamma_m * mass_m;
128 }
129 
130 inline double PartData::getE() const {
131  return gamma_m * mass_m;
132 }
133 
134 inline double PartData::getBeta() const {
135  return beta_m;
136 }
137 
138 inline double PartData::getGamma() const {
139  return gamma_m;
140 }
141 
142 inline double PartData::getMomentumTolerance() const {
143  return momentumTolerance_m;
144 }
145 
146 #endif // MAD_PartData_HH
void setMomentumTolerance(double tolerance)
Set the momentum tolerance.
Definition: PartData.cpp:88
double beta_m
Definition: PartData.h:102
double getQ() const
The constant charge per particle.
Definition: PartData.h:118
void setQ(double q)
Set reference charge expressed in proton charges.
Definition: PartData.h:114
void setBeta(double beta)
Set beta.
Definition: PartData.cpp:69
void setP(double p)
Set reference momentum.
Definition: PartData.cpp:40
double mass_m
Definition: PartData.h:101
double getBeta() const
The relativistic beta per particle.
Definition: PartData.h:134
double getM() const
The constant mass per particle.
Definition: PartData.h:122
PartData()
Definition: PartData.cpp:32
double gamma_m
Definition: PartData.h:103
void setE(double E)
Set reference energy.
Definition: PartData.cpp:57
double getE() const
The constant reference Energy per particle.
Definition: PartData.h:130
double getMomentumTolerance() const
Get the momentum tolerance.
Definition: PartData.h:142
double momentumTolerance_m
Definition: PartData.h:104
constexpr double e
The value of .
Definition: Physics.h:39
double getP() const
The constant reference momentum per particle.
Definition: PartData.h:126
void setM(double m)
Set reference mass expressed in eV/c^2.
Definition: PartData.h:110
void setGamma(double gamma)
Set gamma.
Definition: PartData.cpp:79
double charge_m
Definition: PartData.h:100
double getGamma() const
The relativistic gamma per particle.
Definition: PartData.h:138