CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
LorentzRotation.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: LorentzRotation.cc,v 1.2 2003/08/13 20:00:14 garren Exp $
3// ---------------------------------------------------------------------------
4//
5// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6//
7// This is the implementation basic parts of the HepLorentzRotation class.
8//
9// Some ZOOM methods involving construction from columns and decomposition
10// into boost*rotation are split off into LorentzRotationC and LorentzRotationD
11
12#include "CLHEP/Vector/defs.h"
13#include "CLHEP/Vector/LorentzRotation.h"
14#include "CLHEP/Vector/ZMxpv.h"
15
16#include <cmath>
17#include <iomanip>
18#include <iostream>
19
20namespace CLHEP {
21
22// ---------- Constructors and Assignment:
23
24
26 (double bx, double by, double bz) {
27 double bp2 = bx*bx + by*by + bz*bz;
28 if (bp2 >= 1) {
29 ZMthrowA (ZMxpvTachyonic(
30 "Boost Vector supplied to set HepLorentzRotation represents speed >= c."));
31 }
32 double gamma = 1.0 / std::sqrt(1.0 - bp2);
33 double bgamma = gamma * gamma / (1.0 + gamma);
34 mxx = 1.0 + bgamma * bx * bx;
35 myy = 1.0 + bgamma * by * by;
36 mzz = 1.0 + bgamma * bz * bz;
37 mxy = myx = bgamma * bx * by;
38 mxz = mzx = bgamma * bx * bz;
39 myz = mzy = bgamma * by * bz;
40 mxt = mtx = gamma * bx;
41 myt = mty = gamma * by;
42 mzt = mtz = gamma * bz;
43 mtt = gamma;
44 return *this;
45}
46
48 (const HepBoost & B, const HepRotation & R) {
49 set (B.rep4x4());
50 *this = matrixMultiplication ( R.rep4x4() );
51 return *this;
52}
53
55 (const HepRotation & R, const HepBoost & B) {
56 set (R.rep4x4());
57 *this = matrixMultiplication ( B.rep4x4() );
58 return *this;
59}
60
61// ---------- Accessors:
62
63// ------------ Subscripting:
64
65double HepLorentzRotation::operator () (int i, int j) const {
66 if (i == 0) {
67 if (j == 0) { return xx(); }
68 if (j == 1) { return xy(); }
69 if (j == 2) { return xz(); }
70 if (j == 3) { return xt(); }
71 } else if (i == 1) {
72 if (j == 0) { return yx(); }
73 if (j == 1) { return yy(); }
74 if (j == 2) { return yz(); }
75 if (j == 3) { return yt(); }
76 } else if (i == 2) {
77 if (j == 0) { return zx(); }
78 if (j == 1) { return zy(); }
79 if (j == 2) { return zz(); }
80 if (j == 3) { return zt(); }
81 } else if (i == 3) {
82 if (j == 0) { return tx(); }
83 if (j == 1) { return ty(); }
84 if (j == 2) { return tz(); }
85 if (j == 3) { return tt(); }
86 }
87 std::cerr << "HepLorentzRotation subscripting: bad indeces "
88 << "(" << i << "," << j << ")\n";
89 return 0.0;
90}
91
92// ---------- Application:
93
94
95// ---------- Comparison:
96
98 if (mtt<m1.mtt) return -1; else if (mtt>m1.mtt) return 1;
99 else if (mtz<m1.mtz) return -1; else if (mtz>m1.mtz) return 1;
100 else if (mty<m1.mty) return -1; else if (mty>m1.mty) return 1;
101 else if (mtx<m1.mtx) return -1; else if (mtx>m1.mtx) return 1;
102
103 else if (mzt<m1.mzt) return -1; else if (mzt>m1.mzt) return 1;
104 else if (mzz<m1.mzz) return -1; else if (mzz>m1.mzz) return 1;
105 else if (mzy<m1.mzy) return -1; else if (mzy>m1.mzy) return 1;
106 else if (mzx<m1.mzx) return -1; else if (mzx>m1.mzx) return 1;
107
108 else if (myt<m1.myt) return -1; else if (myt>m1.myt) return 1;
109 else if (myz<m1.myz) return -1; else if (myz>m1.myz) return 1;
110 else if (myy<m1.myy) return -1; else if (myy>m1.myy) return 1;
111 else if (myx<m1.myx) return -1; else if (myx>m1.myx) return 1;
112
113 else if (mxt<m1.mxt) return -1; else if (mxt>m1.mxt) return 1;
114 else if (mxz<m1.mxz) return -1; else if (mxz>m1.mxz) return 1;
115 else if (mxy<m1.mxy) return -1; else if (mxy>m1.mxy) return 1;
116 else if (mxx<m1.mxx) return -1; else if (mxx>m1.mxx) return 1;
117
118 else return 0;
119}
120
121
122// ---------- Operations in the group of 4-Rotations
123
126 return HepLorentzRotation(
127 mxx*m1.xx_ + mxy*m1.yx_ + mxz*m1.zx_ + mxt*m1.tx_,
128 mxx*m1.xy_ + mxy*m1.yy_ + mxz*m1.zy_ + mxt*m1.ty_,
129 mxx*m1.xz_ + mxy*m1.yz_ + mxz*m1.zz_ + mxt*m1.tz_,
130 mxx*m1.xt_ + mxy*m1.yt_ + mxz*m1.zt_ + mxt*m1.tt_,
131
132 myx*m1.xx_ + myy*m1.yx_ + myz*m1.zx_ + myt*m1.tx_,
133 myx*m1.xy_ + myy*m1.yy_ + myz*m1.zy_ + myt*m1.ty_,
134 myx*m1.xz_ + myy*m1.yz_ + myz*m1.zz_ + myt*m1.tz_,
135 myx*m1.xt_ + myy*m1.yt_ + myz*m1.zt_ + myt*m1.tt_,
136
137 mzx*m1.xx_ + mzy*m1.yx_ + mzz*m1.zx_ + mzt*m1.tx_,
138 mzx*m1.xy_ + mzy*m1.yy_ + mzz*m1.zy_ + mzt*m1.ty_,
139 mzx*m1.xz_ + mzy*m1.yz_ + mzz*m1.zz_ + mzt*m1.tz_,
140 mzx*m1.xt_ + mzy*m1.yt_ + mzz*m1.zt_ + mzt*m1.tt_,
141
142 mtx*m1.xx_ + mty*m1.yx_ + mtz*m1.zx_ + mtt*m1.tx_,
143 mtx*m1.xy_ + mty*m1.yy_ + mtz*m1.zy_ + mtt*m1.ty_,
144 mtx*m1.xz_ + mty*m1.yz_ + mtz*m1.zz_ + mtt*m1.tz_,
145 mtx*m1.xt_ + mty*m1.yt_ + mtz*m1.zt_ + mtt*m1.tt_ );
146}
147
149 double c1 = std::cos (delta);
150 double s1 = std::sin (delta);
151 HepLorentzVector rowy = row2();
152 HepLorentzVector rowz = row3();
153 HepLorentzVector r2 = c1 * rowy - s1 * rowz;
154 HepLorentzVector r3 = s1 * rowy + c1 * rowz;
155 myx = r2.x(); myy = r2.y(); myz = r2.z(); myt = r2.t();
156 mzx = r3.x(); mzy = r3.y(); mzz = r3.z(); mzt = r3.t();
157 return *this;
158}
159
161 double c1 = std::cos (delta);
162 double s1 = std::sin (delta);
163 HepLorentzVector rowx = row1();
164 HepLorentzVector rowz = row3();
165 HepLorentzVector r1 = c1 * rowx + s1 * rowz;
166 HepLorentzVector r3 = -s1 * rowx + c1 * rowz;
167 mxx = r1.x(); mxy = r1.y(); mxz = r1.z(); mxt = r1.t();
168 mzx = r3.x(); mzy = r3.y(); mzz = r3.z(); mzt = r3.t();
169 return *this;
170}
171
173 double c1 = std::cos (delta);
174 double s1 = std::sin (delta);
175 HepLorentzVector rowx = row1();
176 HepLorentzVector rowy = row2();
177 HepLorentzVector r1 = c1 * rowx - s1 * rowy;
178 HepLorentzVector r2 = s1 * rowx + c1 * rowy;
179 mxx = r1.x(); mxy = r1.y(); mxz = r1.z(); mxt = r1.t();
180 myx = r2.x(); myy = r2.y(); myz = r2.z(); myt = r2.t();
181 return *this;
182}
183
185 double b2 = beta*beta;
186 if (b2 >= 1) {
187 ZMthrowA (ZMxpvTachyonic(
188 "Beta supplied to HepLorentzRotation::boostX represents speed >= c."));
189 }
190 double g1 = 1.0/std::sqrt(1.0-b2);
191 double bg = beta*g1;
192 HepLorentzVector rowx = row1();
193 HepLorentzVector rowt = row4();
194 HepLorentzVector r1 = g1 * rowx + bg * rowt;
195 HepLorentzVector r4 = bg * rowx + g1 * rowt;
196 mxx = r1.x(); mxy = r1.y(); mxz = r1.z(); mxt = r1.t();
197 mtx = r4.x(); mty = r4.y(); mtz = r4.z(); mtt = r4.t();
198 return *this;
199}
200
202 double b2 = beta*beta;
203 if (b2 >= 1) {
204 ZMthrowA (ZMxpvTachyonic(
205 "Beta supplied to HepLorentzRotation::boostY represents speed >= c."));
206 }
207 double g1 = 1.0/std::sqrt(1.0-b2);
208 double bg = beta*g1;
209 HepLorentzVector rowy = row2();
210 HepLorentzVector rowt = row4();
211 HepLorentzVector r2 = g1 * rowy + bg * rowt;
212 HepLorentzVector r4 = bg * rowy + g1 * rowt;
213 myx = r2.x(); myy = r2.y(); myz = r2.z(); myt = r2.t();
214 mtx = r4.x(); mty = r4.y(); mtz = r4.z(); mtt = r4.t();
215 return *this;
216}
217
219 double b2 = beta*beta;
220 if (b2 >= 1) {
221 ZMthrowA (ZMxpvTachyonic(
222 "Beta supplied to HepLorentzRotation::boostZ represents speed >= c."));
223 }
224 double g1 = 1.0/std::sqrt(1.0-b2);
225 double bg = beta*g1;
226 HepLorentzVector rowz = row3();
227 HepLorentzVector rowt = row4();
228 HepLorentzVector r3 = g1 * rowz + bg * rowt;
229 HepLorentzVector r4 = bg * rowz + g1 * rowt;
230 mtx = r4.x(); mty = r4.y(); mtz = r4.z(); mtt = r4.t();
231 mzx = r3.x(); mzy = r3.y(); mzz = r3.z(); mzt = r3.t();
232 return *this;
233}
234
235std::ostream & HepLorentzRotation::print( std::ostream & os ) const {
236 os << "\n [ ( " <<
237 std::setw(11) << std::setprecision(6) << xx() << " " <<
238 std::setw(11) << std::setprecision(6) << xy() << " " <<
239 std::setw(11) << std::setprecision(6) << xz() << " " <<
240 std::setw(11) << std::setprecision(6) << xt() << ")\n"
241 << " ( " <<
242 std::setw(11) << std::setprecision(6) << yx() << " " <<
243 std::setw(11) << std::setprecision(6) << yy() << " " <<
244 std::setw(11) << std::setprecision(6) << yz() << " " <<
245 std::setw(11) << std::setprecision(6) << yt() << ")\n"
246 << " ( " <<
247 std::setw(11) << std::setprecision(6) << zx() << " " <<
248 std::setw(11) << std::setprecision(6) << zy() << " " <<
249 std::setw(11) << std::setprecision(6) << zz() << " " <<
250 std::setw(11) << std::setprecision(6) << zt() << ")\n"
251 << " ( " <<
252 std::setw(11) << std::setprecision(6) << tx() << " " <<
253 std::setw(11) << std::setprecision(6) << ty() << " " <<
254 std::setw(11) << std::setprecision(6) << tz() << " " <<
255 std::setw(11) << std::setprecision(6) << tt() << ") ]\n";
256 return os;
257}
258
260 const HepLorentzRotation & lt) {
261 r.rep4x4();
262 lt.rep4x4();
264 r.xx()*lt.xx() + r.xy()*lt.yx() + r.xz()*lt.zx() + r.xt()*lt.tx(),
265 r.xx()*lt.xy() + r.xy()*lt.yy() + r.xz()*lt.zy() + r.xt()*lt.ty(),
266 r.xx()*lt.xz() + r.xy()*lt.yz() + r.xz()*lt.zz() + r.xt()*lt.tz(),
267 r.xx()*lt.xt() + r.xy()*lt.yt() + r.xz()*lt.zt() + r.xt()*lt.tt(),
268
269 r.yx()*lt.xx() + r.yy()*lt.yx() + r.yz()*lt.zx() + r.yt()*lt.tx(),
270 r.yx()*lt.xy() + r.yy()*lt.yy() + r.yz()*lt.zy() + r.yt()*lt.ty(),
271 r.yx()*lt.xz() + r.yy()*lt.yz() + r.yz()*lt.zz() + r.yt()*lt.tz(),
272 r.yx()*lt.xt() + r.yy()*lt.yt() + r.yz()*lt.zt() + r.yt()*lt.tt(),
273
274 r.zx()*lt.xx() + r.zy()*lt.yx() + r.zz()*lt.zx() + r.zt()*lt.tx(),
275 r.zx()*lt.xy() + r.zy()*lt.yy() + r.zz()*lt.zy() + r.zt()*lt.ty(),
276 r.zx()*lt.xz() + r.zy()*lt.yz() + r.zz()*lt.zz() + r.zt()*lt.tz(),
277 r.zx()*lt.xt() + r.zy()*lt.yt() + r.zz()*lt.zt() + r.zt()*lt.tt(),
278
279 r.tx()*lt.xx() + r.ty()*lt.yx() + r.tz()*lt.zx() + r.tt()*lt.tx(),
280 r.tx()*lt.xy() + r.ty()*lt.yy() + r.tz()*lt.zy() + r.tt()*lt.ty(),
281 r.tx()*lt.xz() + r.ty()*lt.yz() + r.tz()*lt.zz() + r.tt()*lt.tz(),
282 r.tx()*lt.xt() + r.ty()*lt.yt() + r.tz()*lt.zt() + r.tt()*lt.tt() ) );
283}
284
285
286const HepLorentzRotation HepLorentzRotation::IDENTITY;
287
288} // namespace CLHEP
#define ZMthrowA(A)
Definition: ZMxpv.h:128
double operator()(int, int) const
static const HepLorentzRotation IDENTITY
int compare(const HepLorentzRotation &m) const
HepRep4x4 rep4x4() const
HepLorentzRotation & boostZ(double beta)
HepLorentzVector row3() const
HepLorentzRotation & rotateY(double delta)
HepLorentzRotation matrixMultiplication(const HepRep4x4 &m) const
HepLorentzVector row1() const
HepLorentzRotation & boostY(double beta)
HepLorentzRotation & boostX(double beta)
HepLorentzRotation & rotateZ(double delta)
HepLorentzVector row2() const
std::ostream & print(std::ostream &os) const
HepLorentzVector row4() const
HepLorentzRotation & rotateX(double delta)
HepLorentzRotation & set(double bx, double by, double bz)
double zz() const
double yz() const
double zx() const
double tz() const
double ty() const
double tx() const
double yx() const
double zy() const
HepRep4x4 rep4x4() const
double zt() const
double xx() const
double tt() const
double yy() const
double xz() const
double yt() const
double xy() const
double xt() const
HepMatrix operator*(const HepMatrix &hm1, const HepDiagMatrix &hm2)
Definition: DiagMatrix.cc:372
Definition: excDblThrow.cc:8