CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

LorentzRotationC.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // ---------------------------------------------------------------------------
3 //
4 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
5 //
6 // This is the implementation of that part of the HepLorentzRotation class
7 // which is concerned with setting or constructing the transformation based
8 // on 4 supplied columns or rows.
9 
10 #ifdef GNUPRAGMA
11 #pragma implementation
12 #endif
13 
14 #include "CLHEP/Vector/defs.h"
15 #include "CLHEP/Vector/LorentzRotation.h"
16 #include "CLHEP/Vector/LorentzVector.h"
17 #include "CLHEP/Vector/ZMxpv.h"
18 
19 #include <cmath>
20 
21 namespace CLHEP {
22 
23 // ---------- Constructors and Assignment:
24 
26  const HepLorentzVector & ccol2,
27  const HepLorentzVector & ccol3,
28  const HepLorentzVector & ccol4) {
29  // First, test that the four cols do represent something close to a
30  // true LT:
31 
33 
34  if ( ccol4.getT() < 0 ) {
35  ZMthrowC (ZMxpvImproperTransformation(
36  "column 4 supplied to define transformation has negative T component"));
37  *this = HepLorentzRotation();
38  return *this;
39  }
40 
41  double u1u1 = ccol1.dot(ccol1);
42  double f11 = std::fabs(u1u1 + 1.0);
44  ZMthrowC (ZMxpvNotSymplectic(
45  "column 1 supplied for HepLorentzRotation has w*w != -1"));
46  }
47  double u2u2 = ccol2.dot(ccol2);
48  double f22 = std::fabs(u2u2 + 1.0);
50  ZMthrowC (ZMxpvNotSymplectic(
51  "column 2 supplied for HepLorentzRotation has w*w != -1"));
52  }
53  double u3u3 = ccol3.dot(ccol3);
54  double f33 = std::fabs(u3u3 + 1.0);
56  ZMthrowC (ZMxpvNotSymplectic(
57  "column 3 supplied for HepLorentzRotation has w*w != -1"));
58  }
59  double u4u4 = ccol4.dot(ccol4);
60  double f44 = std::fabs(u4u4 - 1.0);
62  ZMthrowC (ZMxpvNotSymplectic(
63  "column 4 supplied for HepLorentzRotation has w*w != +1"));
64  }
65 
66  double u1u2 = ccol1.dot(ccol2);
67  double f12 = std::fabs(u1u2);
69  ZMthrowC (ZMxpvNotOrthogonal(
70  "columns 1 and 2 supplied for HepLorentzRotation have non-zero dot"));
71  }
72  double u1u3 = ccol1.dot(ccol3);
73  double f13 = std::fabs(u1u3);
74 
76  ZMthrowC (ZMxpvNotOrthogonal(
77  "columns 1 and 3 supplied for HepLorentzRotation have non-zero dot"));
78  }
79  double u1u4 = ccol1.dot(ccol4);
80  double f14 = std::fabs(u1u4);
82  ZMthrowC (ZMxpvNotOrthogonal(
83  "columns 1 and 4 supplied for HepLorentzRotation have non-zero dot"));
84  }
85  double u2u3 = ccol2.dot(ccol3);
86  double f23 = std::fabs(u2u3);
88  ZMthrowC (ZMxpvNotOrthogonal(
89  "columns 2 and 3 supplied for HepLorentzRotation have non-zero dot"));
90  }
91  double u2u4 = ccol2.dot(ccol4);
92  double f24 = std::fabs(u2u4);
94  ZMthrowC (ZMxpvNotOrthogonal(
95  "columns 2 and 4 supplied for HepLorentzRotation have non-zero dot"));
96  }
97  double u3u4 = ccol3.dot(ccol4);
98  double f34 = std::fabs(u3u4);
100  ZMthrowC (ZMxpvNotOrthogonal(
101  "columns 3 and 4 supplied for HepLorentzRotation have non-zero dot"));
102  }
103 
104  // Our strategy will be to order the cols, then do gram-schmidt on them
105  // (that is, remove the components of col d that make it non-orthogonal to
106  // col c, normalize that, then remove the components of b that make it
107  // non-orthogonal to d and to c, normalize that, etc.
108 
109  // Because col4, the time col, is most likely to be computed directly, we
110  // will start from there and work left-ward.
111 
112  HepLorentzVector a, b, c, d;
113  bool isLorentzTransformation = true;
114  double norm;
115 
116  d = ccol4;
117  norm = d.dot(d);
118  if (norm <= 0.0) {
119  isLorentzTransformation = false;
120  if (norm == 0.0) {
121  d = T_HAT4; // Moot, but let's keep going...
122 
123  norm = 1.0;
124  }
125  }
126  d /= norm;
127 
128  c = ccol3 - ccol3.dot(d) * d;
129  norm = -c.dot(c);
130  if (norm <= 0.0) {
131  isLorentzTransformation = false;
132  if (norm == 0.0) {
133  c = Z_HAT4; // Moot
134  norm = 1.0;
135  }
136  }
137  c /= norm;
138 
139  b = ccol2 + ccol2.dot(c) * c - ccol2.dot(d) * d;
140  norm = -b.dot(b);
141  if (norm <= 0.0) {
142  isLorentzTransformation = false;
143  if (norm == 0.0) {
144  b = Y_HAT4; // Moot
145  norm = 1.0;
146  }
147  }
148  b /= norm;
149 
150  a = ccol1 + ccol1.dot(b) * b + ccol1.dot(c) * c - ccol1.dot(d) * d;
151  norm = -a.dot(a);
152  if (norm <= 0.0) {
153  isLorentzTransformation = false;
154  if (norm == 0.0) {
155  a = X_HAT4; // Moot
156  norm = 1.0;
157  }
158  }
159  a /= norm;
160 
161  if ( !isLorentzTransformation ) {
162  ZMthrowC (ZMxpvImproperTransformation(
163  "cols 1-4 supplied to define transformation form either \n"
164  " a boosted reflection or a tachyonic transformation -- \n"
165  " transformation will be set to Identity "));
166 
167 
168  *this = HepLorentzRotation();
169  }
170 
171  if ( isLorentzTransformation ) {
172  mxx = a.x(); myx = a.y(); mzx = a.z(); mtx = a.t();
173  mxy = b.x(); myy = b.y(); mzy = b.z(); mty = b.t();
174  mxz = c.x(); myz = c.y(); mzz = c.z(); mtz = c.t();
175  mxt = d.x(); myt = d.y(); mzt = d.z(); mtt = d.t();
176  }
177 
178  HepLorentzVector::setMetric (savedMetric);
179  return *this;
180 
181 } // set ( col1, col2, col3, col4 )
182 
184  (const HepLorentzVector & rrow1,
185  const HepLorentzVector & rrow2,
186  const HepLorentzVector & rrow3,
187  const HepLorentzVector & rrow4) {
188  // Set based on using those rows as columns:
189  set (rrow1, rrow2, rrow3, rrow4);
190  // Now transpose in place:
191  register double q1, q2, q3;
192  q1 = mxy; q2 = mxz; q3 = mxt;
193  mxy = myx; mxz = mzx; mxt = mtx;
194  myx = q1; mzx = q2; mtx = q3;
195  q1 = myz; q2 = myt; q3 = mzt;
196  myz = mzy; myt = mty; mzt = mtz;
197  mzy = q1; mty = q2; mtz = q3;
198  return *this;
199 } // LorentzTransformation::setRows(row1 ... row4)
200 
202  const HepLorentzVector & ccol2,
203  const HepLorentzVector & ccol3,
204  const HepLorentzVector & ccol4 )
205 {
206  set ( ccol1, ccol2, ccol3, ccol4 );
207 }
208 
209 } // namespace CLHEP
210 
CLHEP::ZMpvMetric_t
ZMpvMetric_t
Definition: Geometry/CLHEP/Vector/LorentzVector.h:65
a
@ a
Definition: testCategories.cc:125
CLHEP::HepLorentzRotation::mtt
double mtt
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:343
CLHEP::HepLorentzVector::y
double y() const
CLHEP::HepLorentzRotation::mtx
double mtx
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:343
CLHEP::HepLorentzVector::z
double z() const
b
@ b
Definition: testCategories.cc:125
CLHEP::HepLorentzVector::x
double x() const
CLHEP::HepLorentzRotation::mxt
double mxt
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:340
CLHEP::HepLorentzVector::dot
double dot(const HepLorentzVector &) const
CLHEP::HepLorentzVector::getT
double getT() const
CLHEP::Hep4RotationInterface::tolerance
static double tolerance
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:118
CLHEP::HepLorentzRotation::HepLorentzRotation
HepLorentzRotation()
CLHEP::TimePositive
@ TimePositive
Definition: Geometry/CLHEP/Vector/LorentzVector.h:65
CLHEP::HepLorentzRotation::mtz
double mtz
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:343
CLHEP::HepLorentzRotation::myx
double myx
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:341
CLHEP::HepLorentzRotation::mxz
double mxz
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:340
CLHEP::HepLorentzRotation
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:54
CLHEP::HepLorentzVector::t
double t() const
CLHEP::HepLorentzRotation::myy
double myy
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:341
CLHEP::HepLorentzRotation::mxx
double mxx
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:340
CLHEP::HepLorentzRotation::mzz
double mzz
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:342
CLHEP
Definition: ClhepVersion.h:13
CLHEP::HepLorentzRotation::myt
double myt
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:341
CLHEP::HepLorentzRotation::myz
double myz
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:341
CLHEP::HepLorentzRotation::mzx
double mzx
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:342
ZMthrowC
#define ZMthrowC(A)
Definition: Geometry/CLHEP/Vector/ZMxpv.h:132
CLHEP::HepLorentzRotation::mzt
double mzt
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:342
set
set(pkginclude_HEADERS itos.h) INSTALL(FILES $
Definition: Cast/Cast/CMakeLists.txt:2
CLHEP::HepLorentzRotation::mxy
double mxy
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:340
CLHEP::HepLorentzVector
Definition: Geometry/CLHEP/Vector/LorentzVector.h:72
CLHEP::HepLorentzRotation::mzy
double mzy
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:342
CLHEP::HepLorentzRotation::setRows
HepLorentzRotation & setRows(const HepLorentzVector &row1, const HepLorentzVector &row2, const HepLorentzVector &row3, const HepLorentzVector &row4)
Definition: LorentzRotationC.cc:184
CLHEP::HepLorentzVector::setMetric
static ZMpvMetric_t setMetric(ZMpvMetric_t a1)
Definition: LorentzVectorK.cc:27
CLHEP::HepLorentzRotation::mty
double mty
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:343
CLHEP::norm
double norm(const HepGenMatrix &m)
Definition: GenMatrix.cc:57
CLHEP::HepLorentzRotation::set
HepLorentzRotation & set(double bx, double by, double bz)
Definition: LorentzRotation.cc:29