17 #ifndef ROOT_Math_GenVector_LorentzRotation
18 #define ROOT_Math_GenVector_LorentzRotation 1
54 class LorentzRotation {
58 typedef double Scalar;
60 enum ELorentzRotationMatrixIndex {
61 kXX = 0, kXY = 1, kXZ = 2, kXT = 3
62 , kYX = 4, kYY = 5, kYZ = 6, kYT = 7
63 , kZX = 8, kZY = 9, kZZ = 10, kZT = 11
64 , kTX = 12, kTY = 13, kTZ = 14, kTT = 15
79 LorentzRotation(IT begin, IT end) { SetComponents(begin,end); }
87 LorentzRotation( LorentzRotation
const & r ) {
94 explicit LorentzRotation( Boost
const & b ) { b.GetLorentzRotation( fM+0 ); }
95 explicit LorentzRotation( BoostX
const & bx ) { bx.GetLorentzRotation( fM+0 ); }
96 explicit LorentzRotation( BoostY
const & by ) { by.GetLorentzRotation( fM+0 ); }
97 explicit LorentzRotation( BoostZ
const & bz ) { bz.GetLorentzRotation( fM+0 ); }
102 explicit LorentzRotation( Rotation3D
const & r );
103 explicit LorentzRotation( AxisAngle
const & a );
104 explicit LorentzRotation( EulerAngles
const & e );
105 explicit LorentzRotation( Quaternion
const & q );
106 explicit LorentzRotation( RotationX
const & r );
107 explicit LorentzRotation( RotationY
const & r );
108 explicit LorentzRotation( RotationZ
const & r );
117 template<
class ForeignMatrix>
118 explicit LorentzRotation(
const ForeignMatrix & m) { SetComponents(m); }
127 template<
class Foreign4Vector>
128 LorentzRotation(
const Foreign4Vector& v1,
129 const Foreign4Vector& v2,
130 const Foreign4Vector& v3,
131 const Foreign4Vector& v4 ) { SetComponents(v1, v2, v3, v4); }
137 LorentzRotation(Scalar xx, Scalar xy, Scalar xz, Scalar xt,
138 Scalar yx, Scalar yy, Scalar yz, Scalar yt,
139 Scalar zx, Scalar zy, Scalar zz, Scalar zt,
140 Scalar tx, Scalar ty, Scalar tz, Scalar tt)
142 SetComponents (xx, xy, xz, xt,
152 operator=( LorentzRotation
const & rhs ) {
153 SetComponents( rhs.fM[0], rhs.fM[1], rhs.fM[2], rhs.fM[3],
154 rhs.fM[4], rhs.fM[5], rhs.fM[6], rhs.fM[7],
155 rhs.fM[8], rhs.fM[9], rhs.fM[10], rhs.fM[11],
156 rhs.fM[12], rhs.fM[13], rhs.fM[14], rhs.fM[15] );
164 operator=( Boost
const & b ) {
return operator=(LorentzRotation(b)); }
166 operator=( BoostX
const & b ) {
return operator=(LorentzRotation(b)); }
168 operator=( BoostY
const & b ) {
return operator=(LorentzRotation(b)); }
170 operator=( BoostZ
const & b ) {
return operator=(LorentzRotation(b)); }
176 operator=( Rotation3D
const & r ) {
return operator=(LorentzRotation(r)); }
178 operator=( AxisAngle
const & a ) {
return operator=(LorentzRotation(a)); }
180 operator=( EulerAngles
const & e ) {
return operator=(LorentzRotation(e)); }
182 operator=( Quaternion
const & q ) {
return operator=(LorentzRotation(q)); }
184 operator=( RotationZ
const & r ) {
return operator=(LorentzRotation(r)); }
186 operator=( RotationY
const & r ) {
return operator=(LorentzRotation(r)); }
188 operator=( RotationX
const & r ) {
return operator=(LorentzRotation(r)); }
196 template<
class ForeignMatrix>
198 operator=(
const ForeignMatrix & m) {
199 SetComponents( m(0,0), m(0,1), m(0,2), m(0,3),
200 m(1,0), m(1,1), m(1,2), m(1,3),
201 m(2,0), m(2,1), m(2,2), m(2,3),
202 m(3,0), m(3,1), m(3,2), m(3,3) );
220 template<
class Foreign4Vector>
222 SetComponents (
const Foreign4Vector& v1,
223 const Foreign4Vector& v2,
224 const Foreign4Vector& v3,
225 const Foreign4Vector& v4 ) {
226 fM[kXX]=v1.x(); fM[kXY]=v2.x(); fM[kXZ]=v3.x(); fM[kXT]=v4.x();
227 fM[kYX]=v1.y(); fM[kYY]=v2.y(); fM[kYZ]=v3.y(); fM[kYT]=v4.y();
228 fM[kZX]=v1.z(); fM[kZY]=v2.z(); fM[kZZ]=v3.z(); fM[kZT]=v4.z();
229 fM[kTX]=v1.t(); fM[kTY]=v2.t(); fM[kTZ]=v3.t(); fM[kTT]=v4.t();
238 template<
class Foreign4Vector>
240 GetComponents ( Foreign4Vector& v1,
243 Foreign4Vector& v4 )
const {
244 v1 = Foreign4Vector ( fM[kXX], fM[kYX], fM[kZX], fM[kTX] );
245 v2 = Foreign4Vector ( fM[kXY], fM[kYY], fM[kZY], fM[kTY] );
246 v3 = Foreign4Vector ( fM[kXZ], fM[kYZ], fM[kZZ], fM[kTZ] );
247 v4 = Foreign4Vector ( fM[kXT], fM[kYT], fM[kZT], fM[kTT] );
256 void SetComponents(IT begin, IT end) {
258 void SetComponents(IT begin, IT ) {
260 for (
int i = 0; i <16; ++i) {
273 void GetComponents(IT begin, IT end)
const {
275 void GetComponents(IT begin, IT )
const {
277 for (
int i = 0; i <16; ++i) {
288 void GetComponents(IT begin)
const {
289 std::copy ( fM+0, fM+16, begin );
298 template<
class ForeignMatrix>
300 SetRotationMatrix (
const ForeignMatrix & m) {
301 fM[kXX]=m(0,0); fM[kXY]=m(0,1); fM[kXZ]=m(0,2); fM[kXT]=m(0,3);
302 fM[kYX]=m(1,0); fM[kYY]=m(1,1); fM[kYZ]=m(1,2); fM[kYT]=m(1,3);
303 fM[kZX]=m(2,0); fM[kZY]=m(2,1); fM[kZZ]=m(2,2); fM[kZT]=m(2,3);
304 fM[kTX]=m(3,0); fM[kTY]=m(3,1); fM[kTZ]=m(3,2); fM[kTT]=m(3,3);
312 template<
class ForeignMatrix>
314 GetRotationMatrix (ForeignMatrix & m)
const {
315 m(0,0)=fM[kXX]; m(0,1)=fM[kXY]; m(0,2)=fM[kXZ]; m(0,3)=fM[kXT];
316 m(1,0)=fM[kYX]; m(1,1)=fM[kYY]; m(1,2)=fM[kYZ]; m(1,3)=fM[kYT];
317 m(2,0)=fM[kZX]; m(2,1)=fM[kZY]; m(2,2)=fM[kZZ]; m(2,3)=fM[kZT];
318 m(3,0)=fM[kTX]; m(3,1)=fM[kTY]; m(3,2)=fM[kTZ]; m(3,3)=fM[kTT];
325 SetComponents (Scalar xx, Scalar xy, Scalar xz, Scalar xt,
326 Scalar yx, Scalar yy, Scalar yz, Scalar yt,
327 Scalar zx, Scalar zy, Scalar zz, Scalar zt,
328 Scalar tx, Scalar ty, Scalar tz, Scalar tt) {
329 fM[kXX]=xx; fM[kXY]=xy; fM[kXZ]=xz; fM[kXT]=xt;
330 fM[kYX]=yx; fM[kYY]=yy; fM[kYZ]=yz; fM[kYT]=yt;
331 fM[kZX]=zx; fM[kZY]=zy; fM[kZZ]=zz; fM[kZT]=zt;
332 fM[kTX]=tx; fM[kTY]=ty; fM[kTZ]=tz; fM[kTT]=tt;
339 GetComponents (Scalar &xx, Scalar &xy, Scalar &xz, Scalar &xt,
340 Scalar &yx, Scalar &yy, Scalar &yz, Scalar &yt,
341 Scalar &zx, Scalar &zy, Scalar &zz, Scalar &zt,
342 Scalar &tx, Scalar &ty, Scalar &tz, Scalar &tt)
const {
343 xx=fM[kXX]; xy=fM[kXY]; xz=fM[kXZ]; xt=fM[kXT];
344 yx=fM[kYX]; yy=fM[kYY]; yz=fM[kYZ]; yt=fM[kYT];
345 zx=fM[kZX]; zy=fM[kZY]; zz=fM[kZZ]; zt=fM[kZT];
346 tx=fM[kTX]; ty=fM[kTY]; tz=fM[kTZ]; tt=fM[kTT];
355 LorentzVector< ROOT::Math::PxPyPzE4D<double> >
356 operator() (
const LorentzVector< ROOT::Math::PxPyPzE4D<double> > & v)
const {
361 return LorentzVector< PxPyPzE4D<double> >
362 ( fM[kXX]*x + fM[kXY]*y + fM[kXZ]*z + fM[kXT]*t
363 , fM[kYX]*x + fM[kYY]*y + fM[kYZ]*z + fM[kYT]*t
364 , fM[kZX]*x + fM[kZY]*y + fM[kZZ]*z + fM[kZT]*t
365 , fM[kTX]*x + fM[kTY]*y + fM[kTZ]*z + fM[kTT]*t );
372 template <
class CoordSystem>
373 LorentzVector<CoordSystem>
374 operator() (
const LorentzVector<CoordSystem> & v)
const {
375 LorentzVector< PxPyPzE4D<double> > xyzt(v);
376 LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt);
377 return LorentzVector<CoordSystem> ( r_xyzt );
385 template <
class Foreign4Vector>
387 operator() (
const Foreign4Vector & v)
const {
388 LorentzVector< PxPyPzE4D<double> > xyzt(v);
389 LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt);
390 return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() );
396 template <
class A4Vector>
398 A4Vector operator* (
const A4Vector & v)
const
400 return operator()(v);
411 LorentzRotation Inverse()
const;
418 LorentzRotation operator * (
const LorentzRotation & r)
const;
426 LorentzRotation operator * (
const Boost & b)
const { LorentzRotation tmp(b);
return (*
this)*tmp; }
427 LorentzRotation operator * (
const BoostX & b)
const { LorentzRotation tmp(b);
return (*
this)*tmp; }
428 LorentzRotation operator * (
const BoostY & b)
const { LorentzRotation tmp(b);
return (*
this)*tmp; }
429 LorentzRotation operator * (
const BoostZ & b)
const { LorentzRotation tmp(b);
return (*
this)*tmp; }
434 LorentzRotation operator * (
const Rotation3D & r)
const { LorentzRotation tmp(r);
return (*
this)*tmp; }
435 LorentzRotation operator * (
const AxisAngle & a)
const { LorentzRotation tmp(a);
return (*
this)*tmp; }
436 LorentzRotation operator * (
const EulerAngles & e)
const { LorentzRotation tmp(e);
return (*
this)*tmp; }
437 LorentzRotation operator * (
const Quaternion & q)
const { LorentzRotation tmp(q);
return (*
this)*tmp; }
438 LorentzRotation operator * (
const RotationX & rx)
const { LorentzRotation tmp(rx);
return (*
this)*tmp; }
439 LorentzRotation operator * (
const RotationY & ry)
const { LorentzRotation tmp(ry);
return (*
this)*tmp; }
440 LorentzRotation operator * (
const RotationZ & rz)
const { LorentzRotation tmp(rz);
return (*
this)*tmp; }
448 LorentzRotation & operator *= (
const R & r) {
return *
this = (*this)*r; }
453 bool operator == (
const LorentzRotation & rhs)
const {
454 for (
unsigned int i=0; i < 16; ++i) {
455 if( fM[i] != rhs.fM[i] )
return false;
459 bool operator != (
const LorentzRotation & rhs)
const {
460 return ! operator==(rhs);
477 std::ostream & operator<< (std::ostream & os,
const LorentzRotation & r);
487 typename Rotation3D::Scalar
488 Distance (
const Rotation3D& r1,
const R & r2) {
return gv_detail::dist(r1,r2);}