Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Boost.cxx
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: M. Fischler 2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 , LCG ROOT FNAL MathLib Team *
7 * *
8 * *
9 **********************************************************************/
10
11// Header file for class Boost, a 4x4 symmetric matrix representation of
12// an axial Lorentz transformation
13//
14// Created by: Mark Fischler Mon Nov 1 2005
15//
22
23#include <cmath>
24#include <algorithm>
25
26// #ifdef TEX
27/**
28
29 A variable names bgamma appears in several places in this file. A few
30 words of elaboration are needed to make its meaning clear. On page 69
31 of Misner, Thorne and Wheeler, (Exercise 2.7) the elements of the matrix
32 for a general Lorentz boost are given as
33
34 \f[ \Lambda^{j'}_k = \Lambda^{k'}_j
35 = (\gamma - 1) n^j n^k + \delta^{jk} \f]
36
37 where the n^i are unit vectors in the direction of the three spatial
38 axes. Using the definitions, \f$ n^i = \beta_i/\beta \f$ , then, for example,
39
40 \f[ \Lambda_{xy} = (\gamma - 1) n_x n_y
41 = (\gamma - 1) \beta_x \beta_y/\beta^2 \f]
42
43 By definition, \f[ \gamma^2 = 1/(1 - \beta^2) \f]
44
45 so that \f[ \gamma^2 \beta^2 = \gamma^2 - 1 \f]
46
47 or \f[ \beta^2 = (\gamma^2 - 1)/\gamma^2 \f]
48
49 If we insert this into the expression for \f$ \Lambda_{xy} \f$, we get
50
51 \f[ \Lambda_{xy} = (\gamma - 1) \gamma^2/(\gamma^2 - 1) \beta_x \beta_y \f]
52
53 or, finally
54
55 \f[ \Lambda_{xy} = \gamma^2/(\gamma+1) \beta_x \beta_y \f]
56
57 The expression \f$ \gamma^2/(\gamma+1) \f$ is what we call <em>bgamma</em> in the code below.
58
59 \class ROOT::Math::Boost
60*/
61// #endif
62
64
66
67namespace ROOT {
68
69namespace ROOT_MATH_ARCH {
70
72{
73 // set identity boost
74 fM[kXX] = 1.0;
75 fM[kXY] = 0.0;
76 fM[kXZ] = 0.0;
77 fM[kXT] = 0.0;
78 fM[kYY] = 1.0;
79 fM[kYZ] = 0.0;
80 fM[kYT] = 0.0;
81 fM[kZZ] = 1.0;
82 fM[kZT] = 0.0;
83 fM[kTT] = 1.0;
84}
85
87{
88 // set the boost beta as 3 components
89 Scalar bp2 = bx * bx + by * by + bz * bz;
90 if (bp2 >= 1) {
91#if !defined(ROOT_MATH_SYCL) && !defined(ROOT_MATH_CUDA)
92 GenVector_Throw("Beta Vector supplied to set Boost represents speed >= c");
93#endif
94 // SetIdentity();
95 return;
96 }
97 Scalar gamma = 1.0 / math_sqrt(1.0 - bp2);
98 Scalar bgamma = gamma * gamma / (1.0 + gamma);
99 fM[kXX] = 1.0 + bgamma * bx * bx;
100 fM[kYY] = 1.0 + bgamma * by * by;
101 fM[kZZ] = 1.0 + bgamma * bz * bz;
102 fM[kXY] = bgamma * bx * by;
103 fM[kXZ] = bgamma * bx * bz;
104 fM[kYZ] = bgamma * by * bz;
105 fM[kXT] = gamma * bx;
106 fM[kYT] = gamma * by;
107 fM[kZT] = gamma * bz;
108 fM[kTT] = gamma;
109}
110
112{
113 // get beta of the boots as 3 components
114 Scalar gaminv = 1.0 / fM[kTT];
115 bx = fM[kXT] * gaminv;
116 by = fM[kYT] * gaminv;
117 bz = fM[kZT] * gaminv;
118}
119
126
128{
129 // get Lorentz rotation corresponding to this boost as an array of 16 values
130 r[kLXX] = fM[kXX];
131 r[kLXY] = fM[kXY];
132 r[kLXZ] = fM[kXZ];
133 r[kLXT] = fM[kXT];
134 r[kLYX] = fM[kXY];
135 r[kLYY] = fM[kYY];
136 r[kLYZ] = fM[kYZ];
137 r[kLYT] = fM[kYT];
138 r[kLZX] = fM[kXZ];
139 r[kLZY] = fM[kYZ];
140 r[kLZZ] = fM[kZZ];
141 r[kLZT] = fM[kZT];
142 r[kLTX] = fM[kXT];
143 r[kLTY] = fM[kYT];
144 r[kLTZ] = fM[kZT];
145 r[kLTT] = fM[kTT];
146}
147
149{
150 // Assuming the representation of this is close to a true Lorentz Rotation,
151 // but may have drifted due to round-off error from many operations,
152 // this forms an "exact" orthosymplectic matrix for the Lorentz Rotation
153 // again.
154
155 if (fM[kTT] <= 0) {
156#if !defined(ROOT_MATH_SYCL) && !defined(ROOT_MATH_CUDA)
157 GenVector_Throw("Attempt to rectify a boost with non-positive gamma");
158#endif
159 return;
160 }
162 beta /= fM[kTT];
163 if (beta.mag2() >= 1) {
164 beta /= (beta.R() * (1.0 + 1.0e-16));
165 }
166 SetComponents(beta);
167}
168
170{
171 // apply bosost to a PxPyPzE LorentzVector
172 Scalar x = v.Px();
173 Scalar y = v.Py();
174 Scalar z = v.Pz();
175 Scalar t = v.E();
177 fM[kXX] * x + fM[kXY] * y + fM[kXZ] * z + fM[kXT] * t, fM[kXY] * x + fM[kYY] * y + fM[kYZ] * z + fM[kYT] * t,
178 fM[kXZ] * x + fM[kYZ] * y + fM[kZZ] * z + fM[kZT] * t, fM[kXT] * x + fM[kYT] * y + fM[kZT] * z + fM[kTT] * t);
179}
180
182{
183 // invert in place boost (modifying the object)
184 fM[kXT] = -fM[kXT];
185 fM[kYT] = -fM[kYT];
186 fM[kZT] = -fM[kZT];
187}
188
190{
191 // return inverse of boost
192 Boost tmp(*this);
193 tmp.Invert();
194 return tmp;
195}
196
197#if !defined(ROOT_MATH_SYCL) && !defined(ROOT_MATH_CUDA)
198// ========== I/O =====================
199
200std::ostream &operator<<(std::ostream &os, const Boost &b)
201{
202 // TODO - this will need changing for machine-readable issues
203 // and even the human readable form needs formatting improvements
204 double m[16];
205 b.GetLorentzRotation(m);
206 os << "\n" << m[0] << " " << m[1] << " " << m[2] << " " << m[3];
207 os << "\n"
208 << "\t" << " " << m[5] << " " << m[6] << " " << m[7];
209 os << "\n"
210 << "\t" << " " << "\t" << " " << m[10] << " " << m[11];
211 os << "\n"
212 << "\t" << " " << "\t" << " " << "\t" << " " << m[15] << "\n";
213 return os;
214}
215#endif
216
217} // namespace ROOT_MATH_ARCH
218} // namespace ROOT
#define b(i)
Definition RSha256.hxx:100
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
Lorentz boost class with the (4D) transformation represented internally by a 4x4 orthosymplectic matr...
Definition Boost.h:51
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 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
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
void Invert()
Invert a Boost in place.
Definition Boost.cxx:181
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
void GenVector_Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
Scalar math_sqrt(Scalar x)
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition AxisAngle.cxx:98
TMarker m
Definition textangle.C:8