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

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#ifdef GNUPRAGMA
13#pragma implementation
14#endif
15
16#include "CLHEP/Vector/defs.h"
17#include "CLHEP/Vector/LorentzRotation.h"
18#include "CLHEP/Vector/ZMxpv.h"
19
20#include <iostream>
21#include <iomanip>
22
23namespace CLHEP {
24
25// ---------- Constructors and Assignment:
26
27
29 (double bx, double by, double bz) {
30 double bp2 = bx*bx + by*by + bz*bz;
31 if (bp2 >= 1) {
32 ZMthrowA (ZMxpvTachyonic(
33 "Boost Vector supplied to set HepLorentzRotation represents speed >= c."));
34 }
35 double gamma = 1.0 / std::sqrt(1.0 - bp2);
36 double bgamma = gamma * gamma / (1.0 + gamma);
37 mxx = 1.0 + bgamma * bx * bx;
38 myy = 1.0 + bgamma * by * by;
39 mzz = 1.0 + bgamma * bz * bz;
40 mxy = myx = bgamma * bx * by;
41 mxz = mzx = bgamma * bx * bz;
42 myz = mzy = bgamma * by * bz;
43 mxt = mtx = gamma * bx;
44 myt = mty = gamma * by;
45 mzt = mtz = gamma * bz;
46 mtt = gamma;
47 return *this;
48}
49
51 (const HepBoost & B, const HepRotation & R) {
52 set (B.rep4x4());
53 *this = matrixMultiplication ( R.rep4x4() );
54 return *this;
55}
56
58 (const HepRotation & R, const HepBoost & B) {
59 set (R.rep4x4());
60 *this = matrixMultiplication ( B.rep4x4() );
61 return *this;
62}
63
64// ---------- Accessors:
65
66// ------------ Subscripting:
67
68double HepLorentzRotation::operator () (int i, int j) const {
69 if (i == 0) {
70 if (j == 0) { return xx(); }
71 if (j == 1) { return xy(); }
72 if (j == 2) { return xz(); }
73 if (j == 3) { return xt(); }
74 } else if (i == 1) {
75 if (j == 0) { return yx(); }
76 if (j == 1) { return yy(); }
77 if (j == 2) { return yz(); }
78 if (j == 3) { return yt(); }
79 } else if (i == 2) {
80 if (j == 0) { return zx(); }
81 if (j == 1) { return zy(); }
82 if (j == 2) { return zz(); }
83 if (j == 3) { return zt(); }
84 } else if (i == 3) {
85 if (j == 0) { return tx(); }
86 if (j == 1) { return ty(); }
87 if (j == 2) { return tz(); }
88 if (j == 3) { return tt(); }
89 }
90 std::cerr << "HepLorentzRotation subscripting: bad indeces "
91 << "(" << i << "," << j << ")\n";
92 return 0.0;
93}
94
95// ---------- Application:
96
97
98// ---------- Comparison:
99
101 if (mtt<m1.mtt) return -1; else if (mtt>m1.mtt) return 1;
102 else if (mtz<m1.mtz) return -1; else if (mtz>m1.mtz) return 1;
103 else if (mty<m1.mty) return -1; else if (mty>m1.mty) return 1;
104 else if (mtx<m1.mtx) return -1; else if (mtx>m1.mtx) return 1;
105
106 else if (mzt<m1.mzt) return -1; else if (mzt>m1.mzt) return 1;
107 else if (mzz<m1.mzz) return -1; else if (mzz>m1.mzz) return 1;
108 else if (mzy<m1.mzy) return -1; else if (mzy>m1.mzy) return 1;
109 else if (mzx<m1.mzx) return -1; else if (mzx>m1.mzx) return 1;
110
111 else if (myt<m1.myt) return -1; else if (myt>m1.myt) return 1;
112 else if (myz<m1.myz) return -1; else if (myz>m1.myz) return 1;
113 else if (myy<m1.myy) return -1; else if (myy>m1.myy) return 1;
114 else if (myx<m1.myx) return -1; else if (myx>m1.myx) return 1;
115
116 else if (mxt<m1.mxt) return -1; else if (mxt>m1.mxt) return 1;
117 else if (mxz<m1.mxz) return -1; else if (mxz>m1.mxz) return 1;
118 else if (mxy<m1.mxy) return -1; else if (mxy>m1.mxy) return 1;
119 else if (mxx<m1.mxx) return -1; else if (mxx>m1.mxx) return 1;
120
121 else return 0;
122}
123
124
125// ---------- Operations in the group of 4-Rotations
126
129 return HepLorentzRotation(
130 mxx*m1.xx_ + mxy*m1.yx_ + mxz*m1.zx_ + mxt*m1.tx_,
131 mxx*m1.xy_ + mxy*m1.yy_ + mxz*m1.zy_ + mxt*m1.ty_,
132 mxx*m1.xz_ + mxy*m1.yz_ + mxz*m1.zz_ + mxt*m1.tz_,
133 mxx*m1.xt_ + mxy*m1.yt_ + mxz*m1.zt_ + mxt*m1.tt_,
134
135 myx*m1.xx_ + myy*m1.yx_ + myz*m1.zx_ + myt*m1.tx_,
136 myx*m1.xy_ + myy*m1.yy_ + myz*m1.zy_ + myt*m1.ty_,
137 myx*m1.xz_ + myy*m1.yz_ + myz*m1.zz_ + myt*m1.tz_,
138 myx*m1.xt_ + myy*m1.yt_ + myz*m1.zt_ + myt*m1.tt_,
139
140 mzx*m1.xx_ + mzy*m1.yx_ + mzz*m1.zx_ + mzt*m1.tx_,
141 mzx*m1.xy_ + mzy*m1.yy_ + mzz*m1.zy_ + mzt*m1.ty_,
142 mzx*m1.xz_ + mzy*m1.yz_ + mzz*m1.zz_ + mzt*m1.tz_,
143 mzx*m1.xt_ + mzy*m1.yt_ + mzz*m1.zt_ + mzt*m1.tt_,
144
145 mtx*m1.xx_ + mty*m1.yx_ + mtz*m1.zx_ + mtt*m1.tx_,
146 mtx*m1.xy_ + mty*m1.yy_ + mtz*m1.zy_ + mtt*m1.ty_,
147 mtx*m1.xz_ + mty*m1.yz_ + mtz*m1.zz_ + mtt*m1.tz_,
148 mtx*m1.xt_ + mty*m1.yt_ + mtz*m1.zt_ + mtt*m1.tt_ );
149}
150
152 double c1 = std::cos (delta);
153 double s1 = std::sin (delta);
154 HepLorentzVector rowy = row2();
155 HepLorentzVector rowz = row3();
156 HepLorentzVector r2 = c1 * rowy - s1 * rowz;
157 HepLorentzVector r3 = s1 * rowy + c1 * rowz;
158 myx = r2.x(); myy = r2.y(); myz = r2.z(); myt = r2.t();
159 mzx = r3.x(); mzy = r3.y(); mzz = r3.z(); mzt = r3.t();
160 return *this;
161}
162
164 double c1 = std::cos (delta);
165 double s1 = std::sin (delta);
166 HepLorentzVector rowx = row1();
167 HepLorentzVector rowz = row3();
168 HepLorentzVector r1 = c1 * rowx + s1 * rowz;
169 HepLorentzVector r3 = -s1 * rowx + c1 * rowz;
170 mxx = r1.x(); mxy = r1.y(); mxz = r1.z(); mxt = r1.t();
171 mzx = r3.x(); mzy = r3.y(); mzz = r3.z(); mzt = r3.t();
172 return *this;
173}
174
176 double c1 = std::cos (delta);
177 double s1 = std::sin (delta);
178 HepLorentzVector rowx = row1();
179 HepLorentzVector rowy = row2();
180 HepLorentzVector r1 = c1 * rowx - s1 * rowy;
181 HepLorentzVector r2 = s1 * rowx + c1 * rowy;
182 mxx = r1.x(); mxy = r1.y(); mxz = r1.z(); mxt = r1.t();
183 myx = r2.x(); myy = r2.y(); myz = r2.z(); myt = r2.t();
184 return *this;
185}
186
188 double b2 = beta*beta;
189 if (b2 >= 1) {
190 ZMthrowA (ZMxpvTachyonic(
191 "Beta supplied to HepLorentzRotation::boostX represents speed >= c."));
192 }
193 double g1 = 1.0/std::sqrt(1.0-b2);
194 double bg = beta*g1;
195 HepLorentzVector rowx = row1();
196 HepLorentzVector rowt = row4();
197 HepLorentzVector r1 = g1 * rowx + bg * rowt;
198 HepLorentzVector r4 = bg * rowx + g1 * rowt;
199 mxx = r1.x(); mxy = r1.y(); mxz = r1.z(); mxt = r1.t();
200 mtx = r4.x(); mty = r4.y(); mtz = r4.z(); mtt = r4.t();
201 return *this;
202}
203
205 double b2 = beta*beta;
206 if (b2 >= 1) {
207 ZMthrowA (ZMxpvTachyonic(
208 "Beta supplied to HepLorentzRotation::boostY represents speed >= c."));
209 }
210 double g1 = 1.0/std::sqrt(1.0-b2);
211 double bg = beta*g1;
212 HepLorentzVector rowy = row2();
213 HepLorentzVector rowt = row4();
214 HepLorentzVector r2 = g1 * rowy + bg * rowt;
215 HepLorentzVector r4 = bg * rowy + g1 * rowt;
216 myx = r2.x(); myy = r2.y(); myz = r2.z(); myt = r2.t();
217 mtx = r4.x(); mty = r4.y(); mtz = r4.z(); mtt = r4.t();
218 return *this;
219}
220
222 double b2 = beta*beta;
223 if (b2 >= 1) {
224 ZMthrowA (ZMxpvTachyonic(
225 "Beta supplied to HepLorentzRotation::boostZ represents speed >= c."));
226 }
227 double g1 = 1.0/std::sqrt(1.0-b2);
228 double bg = beta*g1;
229 HepLorentzVector rowz = row3();
230 HepLorentzVector rowt = row4();
231 HepLorentzVector r3 = g1 * rowz + bg * rowt;
232 HepLorentzVector r4 = bg * rowz + g1 * rowt;
233 mtx = r4.x(); mty = r4.y(); mtz = r4.z(); mtt = r4.t();
234 mzx = r3.x(); mzy = r3.y(); mzz = r3.z(); mzt = r3.t();
235 return *this;
236}
237
238std::ostream & HepLorentzRotation::print( std::ostream & os ) const {
239 os << "\n [ ( " <<
240 std::setw(11) << std::setprecision(6) << xx() << " " <<
241 std::setw(11) << std::setprecision(6) << xy() << " " <<
242 std::setw(11) << std::setprecision(6) << xz() << " " <<
243 std::setw(11) << std::setprecision(6) << xt() << ")\n"
244 << " ( " <<
245 std::setw(11) << std::setprecision(6) << yx() << " " <<
246 std::setw(11) << std::setprecision(6) << yy() << " " <<
247 std::setw(11) << std::setprecision(6) << yz() << " " <<
248 std::setw(11) << std::setprecision(6) << yt() << ")\n"
249 << " ( " <<
250 std::setw(11) << std::setprecision(6) << zx() << " " <<
251 std::setw(11) << std::setprecision(6) << zy() << " " <<
252 std::setw(11) << std::setprecision(6) << zz() << " " <<
253 std::setw(11) << std::setprecision(6) << zt() << ")\n"
254 << " ( " <<
255 std::setw(11) << std::setprecision(6) << tx() << " " <<
256 std::setw(11) << std::setprecision(6) << ty() << " " <<
257 std::setw(11) << std::setprecision(6) << tz() << " " <<
258 std::setw(11) << std::setprecision(6) << tt() << ") ]\n";
259 return os;
260}
261
263 const HepLorentzRotation & lt) {
264 r.rep4x4();
265 lt.rep4x4();
267 r.xx()*lt.xx() + r.xy()*lt.yx() + r.xz()*lt.zx() + r.xt()*lt.tx(),
268 r.xx()*lt.xy() + r.xy()*lt.yy() + r.xz()*lt.zy() + r.xt()*lt.ty(),
269 r.xx()*lt.xz() + r.xy()*lt.yz() + r.xz()*lt.zz() + r.xt()*lt.tz(),
270 r.xx()*lt.xt() + r.xy()*lt.yt() + r.xz()*lt.zt() + r.xt()*lt.tt(),
271
272 r.yx()*lt.xx() + r.yy()*lt.yx() + r.yz()*lt.zx() + r.yt()*lt.tx(),
273 r.yx()*lt.xy() + r.yy()*lt.yy() + r.yz()*lt.zy() + r.yt()*lt.ty(),
274 r.yx()*lt.xz() + r.yy()*lt.yz() + r.yz()*lt.zz() + r.yt()*lt.tz(),
275 r.yx()*lt.xt() + r.yy()*lt.yt() + r.yz()*lt.zt() + r.yt()*lt.tt(),
276
277 r.zx()*lt.xx() + r.zy()*lt.yx() + r.zz()*lt.zx() + r.zt()*lt.tx(),
278 r.zx()*lt.xy() + r.zy()*lt.yy() + r.zz()*lt.zy() + r.zt()*lt.ty(),
279 r.zx()*lt.xz() + r.zy()*lt.yz() + r.zz()*lt.zz() + r.zt()*lt.tz(),
280 r.zx()*lt.xt() + r.zy()*lt.yt() + r.zz()*lt.zt() + r.zt()*lt.tt(),
281
282 r.tx()*lt.xx() + r.ty()*lt.yx() + r.tz()*lt.zx() + r.tt()*lt.tx(),
283 r.tx()*lt.xy() + r.ty()*lt.yy() + r.tz()*lt.zy() + r.tt()*lt.ty(),
284 r.tx()*lt.xz() + r.ty()*lt.yz() + r.tz()*lt.zz() + r.tt()*lt.tz(),
285 r.tx()*lt.xt() + r.ty()*lt.yt() + r.tz()*lt.zt() + r.tt()*lt.tt() ) );
286}
287
288
289const HepLorentzRotation HepLorentzRotation::IDENTITY;
290
291} // namespace CLHEP
#define ZMthrowA(A)
double operator()(int, int) const
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
HepLorentzRotation operator*(const HepRotation &r, const HepLorentzRotation &lt)