ROOT logo
// @(#)root/physics:$Id: TLorentzRotation.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Peter Malzacher   19/06/99

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TLorentzRotation
#define ROOT_TLorentzRotation


#ifndef ROOT_TRotation
#include "TRotation.h"
#endif
#ifndef ROOT_TLorentzVector
#include "TLorentzVector.h"
#endif


class TLorentzRotation : public TObject {


public:

class TLorentzRotationRow {
public:
   inline TLorentzRotationRow(const TLorentzRotation &, int);
   inline Double_t operator [] (int) const;
private:
   const TLorentzRotation * fRR;
   int fII;
};
   // Helper class for implemention of C-style subscripting r[i][j]

   TLorentzRotation();
   // Default constructor. Gives a unit matrix.

   TLorentzRotation(const TRotation &);
   // Constructor for 3d rotations.

   TLorentzRotation(const TLorentzRotation &);
   // Copy constructor.

   TLorentzRotation(Double_t, Double_t, Double_t);
   TLorentzRotation(const TVector3 &);
   // Constructors giving a Lorenz-boost.

   inline Double_t XX() const;
   inline Double_t XY() const;
   inline Double_t XZ() const;
   inline Double_t XT() const;
   inline Double_t YX() const;
   inline Double_t YY() const;
   inline Double_t YZ() const;
   inline Double_t YT() const;
   inline Double_t ZX() const;
   inline Double_t ZY() const;
   inline Double_t ZZ() const;
   inline Double_t ZT() const;
   inline Double_t TX() const;
   inline Double_t TY() const;
   inline Double_t TZ() const;
   inline Double_t TT() const;
   // Elements of the matrix.

   inline TLorentzRotationRow operator [] (int) const;
   // Returns object of the helper class for C-style subscripting r[i][j]


   Double_t operator () (int, int) const;
   // Fortran-style subscriptimg: returns (i,j) element of the matrix.


   inline TLorentzRotation & operator = (const TLorentzRotation &);
   inline TLorentzRotation & operator = (const TRotation &);
   // Assignment.

   inline Bool_t operator == (const TLorentzRotation &) const;
   inline Bool_t operator != (const TLorentzRotation &) const;
   // Comparisons.

   inline Bool_t IsIdentity() const;
   // Returns true if the Identity matrix.

   inline TLorentzVector VectorMultiplication(const TLorentzVector&) const;
   inline TLorentzVector operator * (const TLorentzVector &) const;
   // Multiplication with a Lorentz vector.

   TLorentzRotation MatrixMultiplication(const TLorentzRotation &) const;
   inline TLorentzRotation operator * (const TLorentzRotation &) const;
   inline TLorentzRotation & operator *= (const TLorentzRotation &);
   inline TLorentzRotation & Transform(const TLorentzRotation &);
   inline TLorentzRotation & Transform(const TRotation &);
   // Matrix multiplication.
   // Note: a *= b; <=> a = a * b; while a.Transform(b); <=> a = b * a;

   inline TLorentzRotation Inverse() const;
   // Return the inverse.

   inline TLorentzRotation & Invert();
   // Inverts the LorentzRotation matrix.

   inline TLorentzRotation & Boost(Double_t, Double_t, Double_t);
   inline TLorentzRotation & Boost(const TVector3 &);
   // Lorenz boost.

   inline TLorentzRotation & RotateX(Double_t);
   // Rotation around x-axis.

   inline TLorentzRotation & RotateY(Double_t);
   // Rotation around y-axis.

   inline TLorentzRotation & RotateZ(Double_t);
   // Rotation around z-axis.

   inline TLorentzRotation & Rotate(Double_t, const TVector3 &);
   inline TLorentzRotation & Rotate(Double_t, const TVector3 *);
   // Rotation around specified vector.

protected:

   Double_t fxx, fxy, fxz, fxt,
            fyx, fyy, fyz, fyt,
            fzx, fzy, fzz, fzt,
            ftx, fty, ftz, ftt;
   // The matrix elements.

   void SetBoost(Double_t, Double_t, Double_t);
   // Set elements according to a boost vector.

   TLorentzRotation(Double_t, Double_t, Double_t, Double_t,
                    Double_t, Double_t, Double_t, Double_t,
                    Double_t, Double_t, Double_t, Double_t,
                    Double_t, Double_t, Double_t, Double_t);
   // Protected constructor.

   ClassDef(TLorentzRotation,1) // Lorentz transformations including boosts and rotations

};



inline Double_t TLorentzRotation::XX() const { return fxx; }
inline Double_t TLorentzRotation::XY() const { return fxy; }
inline Double_t TLorentzRotation::XZ() const { return fxz; }
inline Double_t TLorentzRotation::XT() const { return fxt; }
inline Double_t TLorentzRotation::YX() const { return fyx; }
inline Double_t TLorentzRotation::YY() const { return fyy; }
inline Double_t TLorentzRotation::YZ() const { return fyz; }
inline Double_t TLorentzRotation::YT() const { return fyt; }
inline Double_t TLorentzRotation::ZX() const { return fzx; }
inline Double_t TLorentzRotation::ZY() const { return fzy; }
inline Double_t TLorentzRotation::ZZ() const { return fzz; }
inline Double_t TLorentzRotation::ZT() const { return fzt; }
inline Double_t TLorentzRotation::TX() const { return ftx; }
inline Double_t TLorentzRotation::TY() const { return fty; }
inline Double_t TLorentzRotation::TZ() const { return ftz; }
inline Double_t TLorentzRotation::TT() const { return ftt; }

inline TLorentzRotation::TLorentzRotationRow::TLorentzRotationRow
(const TLorentzRotation & r, int i) : fRR(&r), fII(i) {}

inline Double_t TLorentzRotation::TLorentzRotationRow::operator [] (int jj) const {
   return fRR->operator()(fII,jj);
}

inline TLorentzRotation::TLorentzRotationRow TLorentzRotation::operator [] (int i) const {
   return TLorentzRotationRow(*this, i);
}

inline TLorentzRotation & TLorentzRotation::operator = (const TLorentzRotation & r) {
   fxx = r.fxx; fxy = r.fxy; fxz = r.fxz; fxt = r.fxt;
   fyx = r.fyx; fyy = r.fyy; fyz = r.fyz; fyt = r.fyt;
   fzx = r.fzx; fzy = r.fzy; fzz = r.fzz; fzt = r.fzt;
   ftx = r.ftx; fty = r.fty; ftz = r.ftz; ftt = r.ftt;
   return *this;
}

//inline TLorentzRotation &
//TLorentzRotation::operator = (const TRotation & r) {
//  mxx = r.xx(); mxy = r.xy(); mxz = r.xz(); mxt = 0.0;
//  myx = r.yx(); myy = r.yy(); myz = r.yz(); myt = 0.0;
//  mzx = r.zx(); mzy = r.zy(); mzz = r.zz(); mzt = 0.0;
//  mtx = 0.0;    mty = 0.0;    mtz = 0.0;    mtt = 1.0;
//  return *this;
//}

inline TLorentzRotation & TLorentzRotation::operator = (const TRotation & r) {
   fxx = r.XX(); fxy = r.XY(); fxz = r.XZ(); fxt = 0.0;
   fyx = r.YX(); fyy = r.YY(); fyz = r.YZ(); fyt = 0.0;
   fzx = r.ZX(); fzy = r.ZY(); fzz = r.ZZ(); fzt = 0.0;
   ftx = 0.0;    fty = 0.0;    ftz = 0.0;    ftt = 1.0;
   return *this;
}


//inline Bool_t
//TLorentzRotation::operator == (const TLorentzRotation & r) const {
//  return (mxx == r.xx() && mxy == r.xy() && mxz == r.xz() && mxt == r.xt() &&
//          myx == r.yx() && myy == r.yy() && myz == r.yz() && myt == r.yt() &&
//          mzx == r.zx() && mzy == r.zy() && mzz == r.zz() && mzt == r.zt() &&
//          mtx == r.tx() && mty == r.ty() && mtz == r.tz() && mtt == r.tt())
//  ? kTRUE : kFALSE;
//}

inline Bool_t TLorentzRotation::operator == (const TLorentzRotation & r) const {
   return (fxx == r.fxx && fxy == r.fxy && fxz == r.fxz && fxt == r.fxt &&
           fyx == r.fyx && fyy == r.fyy && fyz == r.fyz && fyt == r.fyt &&
           fzx == r.fzx && fzy == r.fzy && fzz == r.fzz && fzt == r.fzt &&
           ftx == r.ftx && fty == r.fty && ftz == r.ftz && ftt == r.ftt)
   ? kTRUE : kFALSE;
}

//inline Bool_t
//TLorentzRotation::operator != (const TLorentzRotation & r) const {
//  return (mxx != r.xx() || mxy != r.xy() || mxz != r.xz() || mxt != r.xt() ||
//          myx != r.yx() || myy != r.yy() || myz != r.yz() || myt != r.yt() ||
//          mzx != r.zx() || mzy != r.zy() || mzz != r.zz() || mzt != r.zt() ||
//          mtx != r.tx() || mty != r.ty() || mtz != r.tz() || mtt != r.tt())
//  ? kTRUE : kFALSE;
//}

inline Bool_t TLorentzRotation::operator != (const TLorentzRotation & r) const {
   return (fxx != r.fxx || fxy != r.fxy || fxz != r.fxz || fxt != r.fxt ||
           fyx != r.fyx || fyy != r.fyy || fyz != r.fyz || fyt != r.fyt ||
           fzx != r.fzx || fzy != r.fzy || fzz != r.fzz || fzt != r.fzt ||
           ftx != r.ftx || fty != r.fty || ftz != r.ftz || ftt != r.ftt)
   ? kTRUE : kFALSE;
}

inline Bool_t TLorentzRotation::IsIdentity() const {
   return (fxx == 1.0 && fxy == 0.0 && fxz == 0.0 && fxt == 0.0 &&
           fyx == 0.0 && fyy == 1.0 && fyz == 0.0 && fyt == 0.0 &&
           fzx == 0.0 && fzy == 0.0 && fzz == 1.0 && fzt == 0.0 &&
           ftx == 0.0 && fty == 0.0 && ftz == 0.0 && ftt == 1.0)
   ? kTRUE : kFALSE;
}


inline TLorentzVector TLorentzRotation::VectorMultiplication(const TLorentzVector & p) const {
   return TLorentzVector(fxx*p.X()+fxy*p.Y()+fxz*p.Z()+fxt*p.T(),
                         fyx*p.X()+fyy*p.Y()+fyz*p.Z()+fyt*p.T(),
                         fzx*p.X()+fzy*p.Y()+fzz*p.Z()+fzt*p.T(),
                         ftx*p.X()+fty*p.Y()+ftz*p.Z()+ftt*p.T());
}

inline TLorentzVector TLorentzRotation::operator * (const TLorentzVector & p) const {
   return VectorMultiplication(p);
}

inline TLorentzRotation TLorentzRotation::operator * (const TLorentzRotation & m) const {
   return MatrixMultiplication(m);
}

inline TLorentzRotation & TLorentzRotation::operator *= (const TLorentzRotation & m) {
   return *this = MatrixMultiplication(m);
}

inline TLorentzRotation & TLorentzRotation::Transform(const TLorentzRotation & m) {
   return *this = m.MatrixMultiplication(*this);
}

inline TLorentzRotation & TLorentzRotation::Transform(const TRotation & m){
   return Transform(TLorentzRotation(m));
}

inline TLorentzRotation TLorentzRotation::Inverse() const {
   return TLorentzRotation( fxx,  fyx,  fzx, -ftx,
                            fxy,  fyy,  fzy, -fty,
                            fxz,  fyz,  fzz, -ftz,
                           -fxt, -fyt, -fzt,  ftt);
}

inline TLorentzRotation & TLorentzRotation::Invert() {
   return *this = Inverse();
}

inline TLorentzRotation & TLorentzRotation::Boost(Double_t bx, Double_t by, Double_t bz) {
   return Transform(TLorentzRotation(bx, by, bz));
}

inline TLorentzRotation & TLorentzRotation::Boost(const TVector3 & b) {
   return Transform(TLorentzRotation(b));
}

inline TLorentzRotation & TLorentzRotation::RotateX(Double_t angle) {
   return Transform(TRotation().RotateX(angle));
}

inline TLorentzRotation & TLorentzRotation::RotateY(Double_t angle) {
   return Transform(TRotation().RotateY(angle));
}

inline TLorentzRotation & TLorentzRotation::RotateZ(Double_t angle) {
   return Transform(TRotation().RotateZ(angle));
}

inline TLorentzRotation & TLorentzRotation::Rotate(Double_t angle, const TVector3 & axis) {
   return Transform(TRotation().Rotate(angle, axis));
}

inline TLorentzRotation & TLorentzRotation::Rotate(Double_t angle, const TVector3 * axis) {
   return Transform(TRotation().Rotate(angle, axis));
}

#endif
 TLorentzRotation.h:1
 TLorentzRotation.h:2
 TLorentzRotation.h:3
 TLorentzRotation.h:4
 TLorentzRotation.h:5
 TLorentzRotation.h:6
 TLorentzRotation.h:7
 TLorentzRotation.h:8
 TLorentzRotation.h:9
 TLorentzRotation.h:10
 TLorentzRotation.h:11
 TLorentzRotation.h:12
 TLorentzRotation.h:13
 TLorentzRotation.h:14
 TLorentzRotation.h:15
 TLorentzRotation.h:16
 TLorentzRotation.h:17
 TLorentzRotation.h:18
 TLorentzRotation.h:19
 TLorentzRotation.h:20
 TLorentzRotation.h:21
 TLorentzRotation.h:22
 TLorentzRotation.h:23
 TLorentzRotation.h:24
 TLorentzRotation.h:25
 TLorentzRotation.h:26
 TLorentzRotation.h:27
 TLorentzRotation.h:28
 TLorentzRotation.h:29
 TLorentzRotation.h:30
 TLorentzRotation.h:31
 TLorentzRotation.h:32
 TLorentzRotation.h:33
 TLorentzRotation.h:34
 TLorentzRotation.h:35
 TLorentzRotation.h:36
 TLorentzRotation.h:37
 TLorentzRotation.h:38
 TLorentzRotation.h:39
 TLorentzRotation.h:40
 TLorentzRotation.h:41
 TLorentzRotation.h:42
 TLorentzRotation.h:43
 TLorentzRotation.h:44
 TLorentzRotation.h:45
 TLorentzRotation.h:46
 TLorentzRotation.h:47
 TLorentzRotation.h:48
 TLorentzRotation.h:49
 TLorentzRotation.h:50
 TLorentzRotation.h:51
 TLorentzRotation.h:52
 TLorentzRotation.h:53
 TLorentzRotation.h:54
 TLorentzRotation.h:55
 TLorentzRotation.h:56
 TLorentzRotation.h:57
 TLorentzRotation.h:58
 TLorentzRotation.h:59
 TLorentzRotation.h:60
 TLorentzRotation.h:61
 TLorentzRotation.h:62
 TLorentzRotation.h:63
 TLorentzRotation.h:64
 TLorentzRotation.h:65
 TLorentzRotation.h:66
 TLorentzRotation.h:67
 TLorentzRotation.h:68
 TLorentzRotation.h:69
 TLorentzRotation.h:70
 TLorentzRotation.h:71
 TLorentzRotation.h:72
 TLorentzRotation.h:73
 TLorentzRotation.h:74
 TLorentzRotation.h:75
 TLorentzRotation.h:76
 TLorentzRotation.h:77
 TLorentzRotation.h:78
 TLorentzRotation.h:79
 TLorentzRotation.h:80
 TLorentzRotation.h:81
 TLorentzRotation.h:82
 TLorentzRotation.h:83
 TLorentzRotation.h:84
 TLorentzRotation.h:85
 TLorentzRotation.h:86
 TLorentzRotation.h:87
 TLorentzRotation.h:88
 TLorentzRotation.h:89
 TLorentzRotation.h:90
 TLorentzRotation.h:91
 TLorentzRotation.h:92
 TLorentzRotation.h:93
 TLorentzRotation.h:94
 TLorentzRotation.h:95
 TLorentzRotation.h:96
 TLorentzRotation.h:97
 TLorentzRotation.h:98
 TLorentzRotation.h:99
 TLorentzRotation.h:100
 TLorentzRotation.h:101
 TLorentzRotation.h:102
 TLorentzRotation.h:103
 TLorentzRotation.h:104
 TLorentzRotation.h:105
 TLorentzRotation.h:106
 TLorentzRotation.h:107
 TLorentzRotation.h:108
 TLorentzRotation.h:109
 TLorentzRotation.h:110
 TLorentzRotation.h:111
 TLorentzRotation.h:112
 TLorentzRotation.h:113
 TLorentzRotation.h:114
 TLorentzRotation.h:115
 TLorentzRotation.h:116
 TLorentzRotation.h:117
 TLorentzRotation.h:118
 TLorentzRotation.h:119
 TLorentzRotation.h:120
 TLorentzRotation.h:121
 TLorentzRotation.h:122
 TLorentzRotation.h:123
 TLorentzRotation.h:124
 TLorentzRotation.h:125
 TLorentzRotation.h:126
 TLorentzRotation.h:127
 TLorentzRotation.h:128
 TLorentzRotation.h:129
 TLorentzRotation.h:130
 TLorentzRotation.h:131
 TLorentzRotation.h:132
 TLorentzRotation.h:133
 TLorentzRotation.h:134
 TLorentzRotation.h:135
 TLorentzRotation.h:136
 TLorentzRotation.h:137
 TLorentzRotation.h:138
 TLorentzRotation.h:139
 TLorentzRotation.h:140
 TLorentzRotation.h:141
 TLorentzRotation.h:142
 TLorentzRotation.h:143
 TLorentzRotation.h:144
 TLorentzRotation.h:145
 TLorentzRotation.h:146
 TLorentzRotation.h:147
 TLorentzRotation.h:148
 TLorentzRotation.h:149
 TLorentzRotation.h:150
 TLorentzRotation.h:151
 TLorentzRotation.h:152
 TLorentzRotation.h:153
 TLorentzRotation.h:154
 TLorentzRotation.h:155
 TLorentzRotation.h:156
 TLorentzRotation.h:157
 TLorentzRotation.h:158
 TLorentzRotation.h:159
 TLorentzRotation.h:160
 TLorentzRotation.h:161
 TLorentzRotation.h:162
 TLorentzRotation.h:163
 TLorentzRotation.h:164
 TLorentzRotation.h:165
 TLorentzRotation.h:166
 TLorentzRotation.h:167
 TLorentzRotation.h:168
 TLorentzRotation.h:169
 TLorentzRotation.h:170
 TLorentzRotation.h:171
 TLorentzRotation.h:172
 TLorentzRotation.h:173
 TLorentzRotation.h:174
 TLorentzRotation.h:175
 TLorentzRotation.h:176
 TLorentzRotation.h:177
 TLorentzRotation.h:178
 TLorentzRotation.h:179
 TLorentzRotation.h:180
 TLorentzRotation.h:181
 TLorentzRotation.h:182
 TLorentzRotation.h:183
 TLorentzRotation.h:184
 TLorentzRotation.h:185
 TLorentzRotation.h:186
 TLorentzRotation.h:187
 TLorentzRotation.h:188
 TLorentzRotation.h:189
 TLorentzRotation.h:190
 TLorentzRotation.h:191
 TLorentzRotation.h:192
 TLorentzRotation.h:193
 TLorentzRotation.h:194
 TLorentzRotation.h:195
 TLorentzRotation.h:196
 TLorentzRotation.h:197
 TLorentzRotation.h:198
 TLorentzRotation.h:199
 TLorentzRotation.h:200
 TLorentzRotation.h:201
 TLorentzRotation.h:202
 TLorentzRotation.h:203
 TLorentzRotation.h:204
 TLorentzRotation.h:205
 TLorentzRotation.h:206
 TLorentzRotation.h:207
 TLorentzRotation.h:208
 TLorentzRotation.h:209
 TLorentzRotation.h:210
 TLorentzRotation.h:211
 TLorentzRotation.h:212
 TLorentzRotation.h:213
 TLorentzRotation.h:214
 TLorentzRotation.h:215
 TLorentzRotation.h:216
 TLorentzRotation.h:217
 TLorentzRotation.h:218
 TLorentzRotation.h:219
 TLorentzRotation.h:220
 TLorentzRotation.h:221
 TLorentzRotation.h:222
 TLorentzRotation.h:223
 TLorentzRotation.h:224
 TLorentzRotation.h:225
 TLorentzRotation.h:226
 TLorentzRotation.h:227
 TLorentzRotation.h:228
 TLorentzRotation.h:229
 TLorentzRotation.h:230
 TLorentzRotation.h:231
 TLorentzRotation.h:232
 TLorentzRotation.h:233
 TLorentzRotation.h:234
 TLorentzRotation.h:235
 TLorentzRotation.h:236
 TLorentzRotation.h:237
 TLorentzRotation.h:238
 TLorentzRotation.h:239
 TLorentzRotation.h:240
 TLorentzRotation.h:241
 TLorentzRotation.h:242
 TLorentzRotation.h:243
 TLorentzRotation.h:244
 TLorentzRotation.h:245
 TLorentzRotation.h:246
 TLorentzRotation.h:247
 TLorentzRotation.h:248
 TLorentzRotation.h:249
 TLorentzRotation.h:250
 TLorentzRotation.h:251
 TLorentzRotation.h:252
 TLorentzRotation.h:253
 TLorentzRotation.h:254
 TLorentzRotation.h:255
 TLorentzRotation.h:256
 TLorentzRotation.h:257
 TLorentzRotation.h:258
 TLorentzRotation.h:259
 TLorentzRotation.h:260
 TLorentzRotation.h:261
 TLorentzRotation.h:262
 TLorentzRotation.h:263
 TLorentzRotation.h:264
 TLorentzRotation.h:265
 TLorentzRotation.h:266
 TLorentzRotation.h:267
 TLorentzRotation.h:268
 TLorentzRotation.h:269
 TLorentzRotation.h:270
 TLorentzRotation.h:271
 TLorentzRotation.h:272
 TLorentzRotation.h:273
 TLorentzRotation.h:274
 TLorentzRotation.h:275
 TLorentzRotation.h:276
 TLorentzRotation.h:277
 TLorentzRotation.h:278
 TLorentzRotation.h:279
 TLorentzRotation.h:280
 TLorentzRotation.h:281
 TLorentzRotation.h:282
 TLorentzRotation.h:283
 TLorentzRotation.h:284
 TLorentzRotation.h:285
 TLorentzRotation.h:286
 TLorentzRotation.h:287
 TLorentzRotation.h:288
 TLorentzRotation.h:289
 TLorentzRotation.h:290
 TLorentzRotation.h:291
 TLorentzRotation.h:292
 TLorentzRotation.h:293
 TLorentzRotation.h:294
 TLorentzRotation.h:295
 TLorentzRotation.h:296
 TLorentzRotation.h:297
 TLorentzRotation.h:298
 TLorentzRotation.h:299
 TLorentzRotation.h:300
 TLorentzRotation.h:301
 TLorentzRotation.h:302
 TLorentzRotation.h:303
 TLorentzRotation.h:304
 TLorentzRotation.h:305
 TLorentzRotation.h:306
 TLorentzRotation.h:307
 TLorentzRotation.h:308
 TLorentzRotation.h:309
 TLorentzRotation.h:310