ROOT   Reference Guide
Boost.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: W. Brown, M. Fischler, L. Moneta 2005
3
4 /**********************************************************************
5 * *
6 * Copyright (c) 2005 ROOT FNAL MathLib Team *
7 * *
8 * *
9 **********************************************************************/
10
12//
13// Created by: Mark Fischler Mon Nov 1 2005
14//
15// Last update: $Id$
16//
17#ifndef ROOT_Math_GenVector_Boost
18#define ROOT_Math_GenVector_Boost 1
19
24
28
29namespace ROOT {
30
31 namespace Math {
32
33//__________________________________________________________________________________________
34 /**
35 Lorentz boost class with the (4D) transformation represented internally
36 by a 4x4 orthosymplectic matrix.
38 specialized Lorentz boosts.
39 Also, the 3-D rotation classes can be considered to be special Lorentz
40 transformations which do not mix space and time components.
41
42 @ingroup GenVector
43
44 */
45
46class Boost {
47
48public:
49
50 typedef double Scalar;
51
53 kLXX = 0, kLXY = 1, kLXZ = 2, kLXT = 3
54 , kLYX = 4, kLYY = 5, kLYZ = 6, kLYT = 7
55 , kLZX = 8, kLZY = 9, kLZZ = 10, kLZT = 11
56 , kLTX = 12, kLTY = 13, kLTZ = 14, kLTT = 15
57 };
58
60 kXX = 0, kXY = 1, kXZ = 2, kXT = 3
61 , kYY = 4, kYZ = 5, kYT = 6
62 , kZZ = 7, kZT = 8
63 , kTT = 9
64 };
65
66 // ========== Constructors and Assignment =====================
67
68 /**
69 Default constructor (identity transformation)
70 */
72
73 /**
74 Construct given a three Scalars beta_x, beta_y, and beta_z
75 */
76 Boost(Scalar beta_x, Scalar beta_y, Scalar beta_z)
77 { SetComponents(beta_x, beta_y, beta_z); }
78
79 /**
80 Construct given a beta vector (which must have methods x(), y(), z())
81 */
82 template <class Avector>
83 explicit
84 Boost(const Avector & beta) { SetComponents(beta); }
85
86 /**
87 Construct given a pair of pointers or iterators defining the
88 beginning and end of an array of three Scalars to use as beta_x, _y, and _z
89 */
90 template<class IT>
91 Boost(IT begin, IT end) { SetComponents(begin,end); }
92
93 /**
94 copy constructor
95 */
96 Boost(Boost const & b) {
97 *this = b;
98 }
99
100 /**
101 Construct from an axial boost
102 */
103
104 explicit Boost( BoostX const & bx ) {SetComponents(bx.BetaVector());}
105 explicit Boost( BoostY const & by ) {SetComponents(by.BetaVector());}
106 explicit Boost( BoostZ const & bz ) {SetComponents(bz.BetaVector());}
107
108 // The compiler-generated copy ctor, copy assignment, and dtor are OK.
109
110 /**
111 Assignment operator
112 */
113 Boost &
114 operator=(Boost const & rhs ) {
115 for (unsigned int i=0; i < 10; ++i) {
116 fM[i] = rhs.fM[i];
117 }
118 return *this;
119 }
120
121 /**
122 Assign from an axial pure boost
123 */
124 Boost &
125 operator=( BoostX const & bx ) { return operator=(Boost(bx)); }
126 Boost &
127 operator=( BoostY const & by ) { return operator=(Boost(by)); }
128 Boost &
129 operator=( BoostZ const & bz ) { return operator=(Boost(bz)); }
130
131 /**
132 Re-adjust components to eliminate small deviations from a perfect
133 orthosyplectic matrix.
134 */
135 void Rectify();
136
137 // ======== Components ==============
138
139 /**
140 Set components from beta_x, beta_y, and beta_z
141 */
142 void
143 SetComponents (Scalar beta_x, Scalar beta_y, Scalar beta_z);
144
145 /**
146 Get components into beta_x, beta_y, and beta_z
147 */
148 void
149 GetComponents (Scalar& beta_x, Scalar& beta_y, Scalar& beta_z) const;
150
151 /**
152 Set components from a beta vector
153 */
154 template <class Avector>
155 void
156 SetComponents (const Avector & beta)
157 { SetComponents(beta.x(), beta.y(), beta.z()); }
158
159 /**
160 Set given a pair of pointers or iterators defining the beginning and end of
161 an array of three Scalars to use as beta_x,beta _y, and beta_z
162 */
163 template<class IT>
164 void SetComponents(IT begin, IT end) {
165 IT a = begin; IT b = ++begin; IT c = ++begin;
166 (void)end;
167 assert (++begin==end);
168 SetComponents (*a, *b, *c);
169 }
170
171 /**
172 Get given a pair of pointers or iterators defining the beginning and end of
173 an array of three Scalars into which to place beta_x, beta_y, and beta_z
174 */
175 template<class IT>
176 void GetComponents(IT begin, IT end) const {
177 IT a = begin; IT b = ++begin; IT c = ++begin;
178 (void)end;
179 assert (++begin==end);
180 GetComponents (*a, *b, *c);
181 }
182
183 /**
184 Get given a pointer or an iterator defining the beginning of
185 an array into which to place beta_x, beta_y, and beta_z
186 */
187 template<class IT>
188 void GetComponents(IT begin ) const {
189 double bx,by,bz = 0;
190 GetComponents (bx,by,bz);
191 *begin++ = bx;
192 *begin++ = by;
193 *begin = bz;
194 }
195
196 /**
197 The beta vector for this boost
198 */
200 XYZVector BetaVector() const;
201
202 /**
203 Get elements of internal 4x4 symmetric representation, into a data
204 array suitable for direct use as the components of a LorentzRotation
205 Note -- 16 Scalars will be written into the array; if the array is not
206 that large, then this will lead to undefined behavior.
207 */
208 void
209 GetLorentzRotation (Scalar r[]) const;
210
211 // =========== operations ==============
212
213 /**
214 Lorentz transformation operation on a Minkowski ('Cartesian')
215 LorentzVector
216 */
219
220 /**
221 Lorentz transformation operation on a LorentzVector in any
222 coordinate system
223 */
224 template <class CoordSystem>
229 return LorentzVector<CoordSystem> ( r_xyzt );
230 }
231
232 /**
233 Lorentz transformation operation on an arbitrary 4-vector v.
234 Preconditions: v must implement methods x(), y(), z(), and t()
235 and the arbitrary vector type must have a constructor taking (x,y,z,t)
236 */
237 template <class Foreign4Vector>
238 Foreign4Vector
239 operator() (const Foreign4Vector & v) const {
242 return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() );
243 }
244
245 /**
246 Overload operator * for boost on a vector
247 */
248 template <class A4Vector>
249 inline
250 A4Vector operator* (const A4Vector & v) const
251 {
252 return operator()(v);
253 }
254
255 /**
256 Invert a Boost in place
257 */
258 void Invert();
259
260 /**
261 Return inverse of a boost
262 */
263 Boost Inverse() const;
264
265 /**
266 Equality/inequality operators
267 */
268 bool operator == (const Boost & rhs) const {
269 for (unsigned int i=0; i < 10; ++i) {
270 if( fM[i] != rhs.fM[i] ) return false;
271 }
272 return true;
273 }
274 bool operator != (const Boost & rhs) const {
275 return ! operator==(rhs);
276 }
277
278protected:
279
280 void SetIdentity();
281
282private:
283
285
286}; // Boost
287
288// ============ Class Boost ends here ============
289
290/**
291 Stream Output and Input
292 */
293 // TODO - I/O should be put in the manipulator form
294
295std::ostream & operator<< (std::ostream & os, const Boost & b);
296
297
298} //namespace Math
299} //namespace ROOT
300
301
302
303
304
305
306
307#endif /* ROOT_Math_GenVector_Boost */
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
typedef void((*Func_t)())
Class representing a Lorentz Boost along the X axis, by beta.
Definition: BoostX.h:37
XYZVector BetaVector() const
Definition: BoostX.cxx:51
Class representing a Lorentz Boost along the Y axis, by beta.
Definition: BoostY.h:37
XYZVector BetaVector() const
Definition: BoostY.cxx:50
Class representing a Lorentz Boost along the Z axis, by beta.
Definition: BoostZ.h:37
XYZVector BetaVector() const
Definition: BoostZ.cxx:50
Lorentz boost class with the (4D) transformation represented internally by a 4x4 orthosymplectic matr...
Definition: Boost.h:46
void SetComponents(const Avector &beta)
Set components from a beta vector.
Definition: Boost.h:156
double Scalar
Definition: Boost.h:50
void GetLorentzRotation(Scalar r[]) const
Get elements of internal 4x4 symmetric representation, into a data array suitable for direct use as t...
Definition: Boost.cxx:115
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZVector
The beta vector for this boost.
Definition: Boost.h:199
void Invert()
Invert a Boost in place.
Definition: Boost.cxx:156
Scalar fM[10]
Definition: Boost.h:284
Boost(Scalar beta_x, Scalar beta_y, Scalar beta_z)
Construct given a three Scalars beta_x, beta_y, and beta_z.
Definition: Boost.h:76
bool operator!=(const Boost &rhs) const
Definition: Boost.h:274
Boost(BoostX const &bx)
Construct from an axial boost.
Definition: Boost.h:104
Boost(Boost const &b)
copy constructor
Definition: Boost.h:96
void SetComponents(IT begin, IT end)
Set given a pair of pointers or iterators defining the beginning and end of an array of three Scalars...
Definition: Boost.h:164
Boost()
Default constructor (identity transformation)
Definition: Boost.h:71
A4Vector operator*(const A4Vector &v) const
Overload operator * for boost on a vector.
Definition: Boost.h:250
Boost(BoostZ const &bz)
Definition: Boost.h:106
Boost & operator=(BoostY const &by)
Definition: Boost.h:127
Boost & operator=(BoostZ const &bz)
Definition: Boost.h:129
Boost(const Avector &beta)
Construct given a beta vector (which must have methods x(), y(), z())
Definition: Boost.h:84
void SetComponents(Scalar beta_x, Scalar beta_y, Scalar beta_z)
Set components from beta_x, beta_y, and beta_z.
Definition: Boost.cxx:76
ELorentzRotationMatrixIndex
Definition: Boost.h:52
bool operator==(const Boost &rhs) const
Equality/inequality operators.
Definition: Boost.h:268
void SetIdentity()
Definition: Boost.cxx:67
Boost Inverse() const
Return inverse of a boost.
Definition: Boost.cxx:163
LorentzVector< ROOT::Math::PxPyPzE4D< double > > operator()(const LorentzVector< ROOT::Math::PxPyPzE4D< double > > &v) const
Lorentz transformation operation on a Minkowski ('Cartesian') LorentzVector.
Definition: Boost.cxx:143
void Rectify()
Re-adjust components to eliminate small deviations from a perfect orthosyplectic matrix.
Definition: Boost.cxx:123
Boost & operator=(BoostX const &bx)
Assign from an axial pure boost.
Definition: Boost.h:125
void GetComponents(Scalar &beta_x, Scalar &beta_y, Scalar &beta_z) const
Get components into beta_x, beta_y, and beta_z.
Definition: Boost.cxx:99
Boost & operator=(Boost const &rhs)
Assignment operator.
Definition: Boost.h:114
void GetComponents(IT begin) const
Get given a pointer or an iterator defining the beginning of an array into which to place beta_x,...
Definition: Boost.h:188
void GetComponents(IT begin, IT end) const
Get given a pair of pointers or iterators defining the beginning and end of an array of three Scalars...
Definition: Boost.h:176
Boost(IT begin, IT end)
Construct given a pair of pointers or iterators defining the beginning and end of an array of three S...
Definition: Boost.h:91
XYZVector BetaVector() const
Definition: Boost.cxx:108
Boost(BoostY const &by)
Definition: Boost.h:105
DefaultCoordinateSystemTag Default tag for identifying any coordinate system.
Class describing a generic displacement vector in 3 dimensions.
Class describing a 4D cartesian coordinate system (x, y, z, t coordinates) or momentum-energy vectors...
Definition: PxPyPzE4D.h:42
double beta(double x, double y)
Calculates the beta function.
Namespace for new Math classes and functions.
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition: AxisAngle.cxx:91
Rotation3D::Scalar Scalar
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
auto * a
Definition: textangle.C:12