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