OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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 LogicalError;
23 
24 
25 // Class PartData
26 // ------------------------------------------------------------------------
28 // This class encapsulates the reference data for a beam:
29 // [UL]
30 // [LI]charge per particle expressed in proton charges,
31 // [LI]mass per particle expressed in eV,
32 // [LI]reference momentum per particle expressed in eV.
33 // [/UL]
34 // The copy constructor, destructor, and assignment operator generated
35 // by the compiler perform the correct operation. For speed reasons
36 // they are not implemented.
37 
38 class PartData {
39 
40 public:
41 
43  // Inputs are:
44  // [DL]
45  // [DT]charge[DD]The charge per particle in proton charges.
46  // [DT]mass[DD]The particle mass in eV.
47  // [DT]momentum[DD]The reference momentum per particle in eV.
48  // [/DL]
49  PartData(double charge, double mass, double momentum);
50 
51  PartData();
52 
54  double getQ() const;
55 
57  double getM() const;
58 
60  double getP() const;
61 
63  double getE() const;
64 
66  double getBeta() const;
67 
69  double getGamma() const;
70 
72  // Input is the momentum in eV.
73  void setP(double p);
74 
76  // Input is the energy in eV.
77  void setE(double E);
78 
80  // Input is the relativistic beta = v/c.
81  void setBeta(double beta);
82 
84  // Input is the relativistic gamma = E/(m*c*c).
85  void setGamma(double gamma);
86 
87 
89  inline void setM(double m){mass = m;}
90 
92  inline void setQ(double q) {charge = q;}
93 
94 protected:
95 
96  // The reference information.
97  double charge; // Particle charge.
98  double mass; // Particle mass.
99  double beta; // particle velocity divided by c.
100  double gamma; // particle energy divided by particle mass
101 };
102 
103 
104 // Inline functions.
105 // ------------------------------------------------------------------------
106 
107 inline double PartData::getQ() const {
108  return charge;
109 }
110 
111 
112 inline double PartData::getM() const {
113  return mass;
114 }
115 
116 
117 inline double PartData::getP() const {
118  return beta * gamma * mass;
119 }
120 
121 
122 inline double PartData::getE() const {
123  return gamma * mass;
124 }
125 
126 
127 inline double PartData::getBeta() const {
128  return beta;
129 }
130 
131 
132 inline double PartData::getGamma() const {
133  return gamma;
134 }
135 
136 #endif // MAD_PartData_HH
void setBeta(double beta)
Set beta.
Definition: PartData.cpp:73
double getE() const
The constant reference Energy per particle.
Definition: PartData.h:122
double charge
Definition: PartData.h:97
Particle reference data.
Definition: PartData.h:38
double getBeta() const
The relativistic beta per particle.
Definition: PartData.h:127
void setP(double p)
Set reference momentum.
Definition: PartData.cpp:44
double getQ() const
The constant charge per particle.
Definition: PartData.h:107
void setQ(double q)
Set reference charge expressed in proton charges,.
Definition: PartData.h:92
PartData()
Definition: PartData.cpp:36
void setE(double E)
Set reference energy.
Definition: PartData.cpp:61
double beta
Definition: PartData.h:99
double getP() const
The constant reference momentum per particle.
Definition: PartData.h:117
double getGamma() const
The relativistic gamma per particle.
Definition: PartData.h:132
double mass
Definition: PartData.h:98
void setM(double m)
Set reference mass expressed in eV/c^2.
Definition: PartData.h:89
double getM() const
The constant mass per particle.
Definition: PartData.h:112
void setGamma(double gamma)
Set gamma.
Definition: PartData.cpp:83
Logical error exception.
Definition: LogicalError.h:33
double gamma
Definition: PartData.h:100