Logo ROOT   6.10/09
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 
11 // Header file for Boost
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 
25 #include "Math/GenVector/BoostX.h"
26 #include "Math/GenVector/BoostY.h"
27 #include "Math/GenVector/BoostZ.h"
28 
29 namespace ROOT {
30 
31  namespace Math {
32 
33 //__________________________________________________________________________________________
34  /**
35  Lorentz boost class with the (4D) transformation represented internally
36  by a 4x4 orthosymplectic matrix.
37  See also BoostX, BoostY and BoostZ for classes representing
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 
46 class Boost {
47 
48 public:
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  */
71  Boost() { SetIdentity(); }
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 #ifndef NDEBUG
165  void SetComponents(IT begin, IT end) {
166 #else
167  void SetComponents(IT begin, IT ) {
168 #endif
169  IT a = begin; IT b = ++begin; IT c = ++begin;
170  assert (++begin==end);
171  SetComponents (*a, *b, *c);
172  }
173 
174  /**
175  Get given a pair of pointers or iterators defining the beginning and end of
176  an array of three Scalars into which to place beta_x, beta_y, and beta_z
177  */
178  template<class IT>
179 #ifndef NDEBUG
180  void GetComponents(IT begin, IT end) const {
181 #else
182  void GetComponents(IT begin, IT ) const {
183 #endif
184  IT a = begin; IT b = ++begin; IT c = ++begin;
185  assert (++begin==end);
186  GetComponents (*a, *b, *c);
187  }
188 
189  /**
190  Get given a pointer or an iterator defining the beginning of
191  an array into which to place beta_x, beta_y, and beta_z
192  */
193  template<class IT>
194  void GetComponents(IT begin ) const {
195  double bx,by,bz = 0;
196  GetComponents (bx,by,bz);
197  *begin++ = bx;
198  *begin++ = by;
199  *begin = bz;
200  }
201 
202  /**
203  The beta vector for this boost
204  */
206  XYZVector BetaVector() const;
207 
208  /**
209  Get elements of internal 4x4 symmetric representation, into a data
210  array suitable for direct use as the components of a LorentzRotation
211  Note -- 16 Scalars will be written into the array; if the array is not
212  that large, then this will lead to undefined behavior.
213  */
214  void
215  GetLorentzRotation (Scalar r[]) const;
216 
217  // =========== operations ==============
218 
219  /**
220  Lorentz transformation operation on a Minkowski ('Cartesian')
221  LorentzVector
222  */
225 
226  /**
227  Lorentz transformation operation on a LorentzVector in any
228  coordinate system
229  */
230  template <class CoordSystem>
235  return LorentzVector<CoordSystem> ( r_xyzt );
236  }
237 
238  /**
239  Lorentz transformation operation on an arbitrary 4-vector v.
240  Preconditions: v must implement methods x(), y(), z(), and t()
241  and the arbitrary vector type must have a constructor taking (x,y,z,t)
242  */
243  template <class Foreign4Vector>
244  Foreign4Vector
245  operator() (const Foreign4Vector & v) const {
248  return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() );
249  }
250 
251  /**
252  Overload operator * for boost on a vector
253  */
254  template <class A4Vector>
255  inline
256  A4Vector operator* (const A4Vector & v) const
257  {
258  return operator()(v);
259  }
260 
261  /**
262  Invert a Boost in place
263  */
264  void Invert();
265 
266  /**
267  Return inverse of a boost
268  */
269  Boost Inverse() const;
270 
271  /**
272  Equality/inequality operators
273  */
274  bool operator == (const Boost & rhs) const {
275  for (unsigned int i=0; i < 10; ++i) {
276  if( fM[i] != rhs.fM[i] ) return false;
277  }
278  return true;
279  }
280  bool operator != (const Boost & rhs) const {
281  return ! operator==(rhs);
282  }
283 
284 protected:
285 
286  void SetIdentity();
287 
288 private:
289 
290  Scalar fM[10];
291 
292 }; // Boost
293 
294 // ============ Class Boost ends here ============
295 
296 /**
297  Stream Output and Input
298  */
299  // TODO - I/O should be put in the manipulator form
300 
301 std::ostream & operator<< (std::ostream & os, const Boost & b);
302 
303 
304 } //namespace Math
305 } //namespace ROOT
306 
307 
308 
309 
310 
311 
312 
313 #endif /* ROOT_Math_GenVector_Boost */
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Definition: LorentzVector.h:48
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZVector
The beta vector for this boost.
Definition: Boost.h:205
XYZVector BetaVector() const
Definition: BoostX.cxx:51
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
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:180
void SetComponents(const Avector &beta)
Set components from a beta vector.
Definition: Boost.h:156
void Rectify()
Re-adjust components to eliminate small deviations from a perfect orthosyplectic matrix.
Definition: Boost.cxx:123
Boost & operator=(Boost const &rhs)
Assignment operator.
Definition: Boost.h:114
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
void SetIdentity()
Definition: Boost.cxx:67
TArc * a
Definition: textangle.C:12
bool operator!=(const Boost &rhs) const
Definition: Boost.h:280
Class representing a Lorentz Boost along the X axis, by beta.
Definition: BoostX.h:37
double beta(double x, double y)
Calculates the beta function.
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition: AxisAngle.cxx:91
Lorentz boost class with the (4D) transformation represented internally by a 4x4 orthosymplectic matr...
Definition: Boost.h:46
ELorentzRotationMatrixIndex
Definition: Boost.h:52
Boost(BoostY const &by)
Definition: Boost.h:105
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
Boost & operator=(BoostX const &bx)
Assign from an axial pure boost.
Definition: Boost.h:125
XYZVector BetaVector() const
Definition: Boost.cxx:108
Boost & operator=(BoostY const &by)
Definition: Boost.h:127
Boost(const Avector &beta)
Construct given a beta vector (which must have methods x(), y(), z())
Definition: Boost.h:84
A4Vector operator*(const A4Vector &v) const
Overload operator * for boost on a vector.
Definition: Boost.h:256
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
Class representing a Lorentz Boost along the Y axis, by beta.
Definition: BoostY.h:37
Class describing a generic displacement vector in 3 dimensions.
Scalar fM[10]
Definition: Boost.h:290
TRandom2 r(17)
bool operator==(const Boost &rhs) const
Equality/inequality operators.
Definition: Boost.h:274
SVector< double, 2 > v
Definition: Dict.h:5
Boost(BoostX const &bx)
Construct from an axial boost.
Definition: Boost.h:104
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
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
Namespace for new Math classes and functions.
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
Boost & operator=(BoostZ const &bz)
Definition: Boost.h:129
Boost Inverse() const
Return inverse of a boost.
Definition: Boost.cxx:163
void Invert()
Invert a Boost in place.
Definition: Boost.cxx:156
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
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:165
DefaultCoordinateSystemTag Default tag for identifying any coordinate system.
Boost()
Default constructor (identity transformation)
Definition: Boost.h:71
LorentzVector< ROOT::Math::PxPyPzE4D< double > > operator()(const LorentzVector< ROOT::Math::PxPyPzE4D< double > > &v) const
Lorentz transformation operation on a Minkowski (&#39;Cartesian&#39;) LorentzVector.
Definition: Boost.cxx:143
double Scalar
Definition: Boost.h:50
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:194
Boost(Boost const &b)
copy constructor
Definition: Boost.h:96
Boost(BoostZ const &bz)
Definition: Boost.h:106