OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalParticle.h
Go to the documentation of this file.
1 #ifndef CLASSIC_OpalParticle_HH
2 #define CLASSIC_OpalParticle_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: OpalParticle.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: OpalParticle
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Algorithms
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:33 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
23 
24 // Class OpalParticle
25 // ------------------------------------------------------------------------
27 // This class represents the canonical coordinates of a particle.
28 // {P}
29 // NOTE. The order of phase space coordinates is,
30 // as opposed to the original CLASSIC definition:
31 // {CENTER}
32 // X = 0, PX = 1, Y = 2, PY = 3, T = 4, PT = 5.
33 // {/CENTER}
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 OpalParticle {
39 
40 public:
41 
42  // Particle coordinate numbers.
43  enum { X, PX, Y, PY, T, PT };
44 
46  // Construct particle with the given coordinates.
47  OpalParticle(double x, double px, double y, double py, double t, double pt);
48 
49  OpalParticle();
50 
52  // Access coordinate by index.
53  // Note above order of phase space coordinates!
54  double &operator[](int);
55 
57  double &x() ;
58 
60  double &px();
61 
63  double &y() ;
64 
66  double &py();
67 
69  double &t() ;
70 
72  double &pt();
73 
75  // Access coordinate by index for constant particle.
76  double operator[](int) const;
77 
79  double x() const;
80 
82  double px() const;
83 
85  double y() const;
86 
88  double py() const;
89 
91  double t() const;
92 
94  double pt() const;
95 
96 private:
97 
98  // The particle's phase space coordinates:
99  double phase[6];
100 };
101 
102 
103 // Inline member functions.
104 // ------------------------------------------------------------------------
105 
106 inline double &OpalParticle::operator[](int i) {
107  return phase[i];
108 }
109 
110 inline double &OpalParticle::x()
111 { return phase[X]; }
112 
113 inline double &OpalParticle::y()
114 { return phase[Y]; }
115 
116 inline double &OpalParticle::t()
117 { return phase[T]; }
118 
119 inline double &OpalParticle::px()
120 { return phase[PX]; }
121 
122 inline double &OpalParticle::py()
123 { return phase[PY]; }
124 
125 inline double &OpalParticle::pt() {
126  return phase[PT];
127 }
128 
129 
130 inline double OpalParticle::operator[](int i) const {
131  return phase[i];
132 }
133 
134 inline double OpalParticle::x() const
135 { return phase[X]; }
136 
137 inline double OpalParticle::y() const
138 { return phase[Y]; }
139 
140 inline double OpalParticle::t() const
141 { return phase[T]; }
142 
143 inline double OpalParticle::px() const
144 { return phase[PX]; }
145 
146 inline double OpalParticle::py() const
147 { return phase[PY]; }
148 
149 inline double OpalParticle::pt() const {
150  return phase[PT];
151 }
152 
153 #endif // CLASSIC_OpalParticle_HH
double & py()
Get reference to vertical momentum (no dimension).
Definition: OpalParticle.h:122
double & operator[](int)
Get coordinate.
Definition: OpalParticle.h:106
double & x()
Get reference to horizontal position in m.
Definition: OpalParticle.h:110
double phase[6]
Definition: OpalParticle.h:99
double & pt()
Get reference to relative momentum error (no dimension).
Definition: OpalParticle.h:125
double & y()
Get reference to vertical displacement in m.
Definition: OpalParticle.h:113
double & t()
Get reference to longitudinal displacement c*t in m.
Definition: OpalParticle.h:116
double & px()
Get reference to horizontal momentum (no dimension).
Definition: OpalParticle.h:119
OpalParticle position.
Definition: OpalParticle.h:38