OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
PartData.h
Go to the documentation of this file.
1 #ifndef MAD_PartData_HH
2 #define MAD_PartData_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: PartData.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 // Description:
12 //
13 // ------------------------------------------------------------------------
14 // Class category: Algorithms
15 // ------------------------------------------------------------------------
16 //
17 // $Date: 2000/03/27 09:32:33 $
18 // $Author: fci $
19 //
20 // ------------------------------------------------------------------------
21 
22 // Class PartData
23 // ------------------------------------------------------------------------
25 // This class encapsulates the reference data for a beam:
26 // [UL]
27 // [LI]charge per particle expressed in proton charges,
28 // [LI]mass per particle expressed in eV,
29 // [LI]reference momentum per particle expressed in eV.
30 // [/UL]
31 // The copy constructor, destructor, and assignment operator generated
32 // by the compiler perform the correct operation. For speed reasons
33 // they are not implemented.
34 
35 class PartData {
36 
37 public:
38 
40  // Inputs are:
41  // [DL]
42  // [DT]charge[DD]The charge per particle in proton charges.
43  // [DT]mass[DD]The particle mass in eV.
44  // [DT]momentum[DD]The reference momentum per particle in eV.
45  // [/DL]
46  PartData(double charge, double mass, double momentum);
47 
48  PartData();
49 
51  double getQ() const;
52 
54  double getM() const;
55 
57  double getP() const;
58 
60  double getE() const;
61 
63  double getBeta() const;
64 
66  double getGamma() const;
67 
69  // Input is the momentum in eV.
70  void setP(double p);
71 
73  // Input is the energy in eV.
74  void setE(double E);
75 
77  // Input is the relativistic beta = v/c.
78  void setBeta(double beta);
79 
81  // Input is the relativistic gamma = E/(m*c*c).
82  void setGamma(double gamma);
83 
84 
86  inline void setM(double m){mass = m;}
87 
89  inline void setQ(double q) {charge = q;}
90 
91 protected:
92 
93  // The reference information.
94  double charge; // Particle charge.
95  double mass; // Particle mass.
96  double beta; // particle velocity divided by c.
97  double gamma; // particle energy divided by particle mass
98 };
99 
100 
101 // Inline functions.
102 // ------------------------------------------------------------------------
103 
104 inline double PartData::getQ() const {
105  return charge;
106 }
107 
108 
109 inline double PartData::getM() const {
110  return mass;
111 }
112 
113 
114 inline double PartData::getP() const {
115  return beta * gamma * mass;
116 }
117 
118 
119 inline double PartData::getE() const {
120  return gamma * mass;
121 }
122 
123 
124 inline double PartData::getBeta() const {
125  return beta;
126 }
127 
128 
129 inline double PartData::getGamma() const {
130  return gamma;
131 }
132 
133 #endif // MAD_PartData_HH
Particle reference data.
Definition: PartData.h:35
double mass
Definition: PartData.h:95
double getQ() const
The constant charge per particle.
Definition: PartData.h:104
double getBeta() const
The relativistic beta per particle.
Definition: PartData.h:124
double getGamma() const
The relativistic gamma per particle.
Definition: PartData.h:129
void setM(double m)
Set reference mass expressed in eV/c^2.
Definition: PartData.h:86
void setGamma(double gamma)
Set gamma.
Definition: PartData.cpp:83
double charge
Definition: PartData.h:94
double getP() const
The constant reference momentum per particle.
Definition: PartData.h:114
double gamma
Definition: PartData.h:97
void setP(double p)
Set reference momentum.
Definition: PartData.cpp:44
void setE(double E)
Set reference energy.
Definition: PartData.cpp:61
double getM() const
The constant mass per particle.
Definition: PartData.h:109
PartData()
Definition: PartData.cpp:36
void setQ(double q)
Set reference charge expressed in proton charges,
Definition: PartData.h:89
double beta
Definition: PartData.h:96
void setBeta(double beta)
Set beta.
Definition: PartData.cpp:73
double getE() const
The constant reference Energy per particle.
Definition: PartData.h:119