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