TLorentzRotation.h

Go to the documentation of this file.
00001 // @(#)root/physics:$Id: TLorentzRotation.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Peter Malzacher   19/06/99
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TLorentzRotation
00013 #define ROOT_TLorentzRotation
00014 
00015 
00016 #ifndef ROOT_TRotation
00017 #include "TRotation.h"
00018 #endif
00019 #ifndef ROOT_TLorentzVector
00020 #include "TLorentzVector.h"
00021 #endif
00022 
00023 
00024 class TLorentzRotation : public TObject {
00025 
00026 
00027 public:
00028 
00029 class TLorentzRotationRow {
00030 public:
00031    inline TLorentzRotationRow(const TLorentzRotation &, int);
00032    inline Double_t operator [] (int) const;
00033 private:
00034    const TLorentzRotation * fRR;
00035    int fII;
00036 };
00037    // Helper class for implemention of C-style subscripting r[i][j]
00038 
00039    TLorentzRotation();
00040    // Default constructor. Gives a unit matrix.
00041 
00042    TLorentzRotation(const TRotation &);
00043    // Constructor for 3d rotations.
00044 
00045    TLorentzRotation(const TLorentzRotation &);
00046    // Copy constructor.
00047 
00048    TLorentzRotation(Double_t, Double_t, Double_t);
00049    TLorentzRotation(const TVector3 &);
00050    // Constructors giving a Lorenz-boost.
00051 
00052    inline Double_t XX() const;
00053    inline Double_t XY() const;
00054    inline Double_t XZ() const;
00055    inline Double_t XT() const;
00056    inline Double_t YX() const;
00057    inline Double_t YY() const;
00058    inline Double_t YZ() const;
00059    inline Double_t YT() const;
00060    inline Double_t ZX() const;
00061    inline Double_t ZY() const;
00062    inline Double_t ZZ() const;
00063    inline Double_t ZT() const;
00064    inline Double_t TX() const;
00065    inline Double_t TY() const;
00066    inline Double_t TZ() const;
00067    inline Double_t TT() const;
00068    // Elements of the matrix.
00069 
00070    inline TLorentzRotationRow operator [] (int) const;
00071    // Returns object of the helper class for C-style subscripting r[i][j]
00072 
00073 
00074    Double_t operator () (int, int) const;
00075    // Fortran-style subscriptimg: returns (i,j) element of the matrix.
00076 
00077 
00078    inline TLorentzRotation & operator = (const TLorentzRotation &);
00079    inline TLorentzRotation & operator = (const TRotation &);
00080    // Assignment.
00081 
00082    inline Bool_t operator == (const TLorentzRotation &) const;
00083    inline Bool_t operator != (const TLorentzRotation &) const;
00084    // Comparisons.
00085 
00086    inline Bool_t IsIdentity() const;
00087    // Returns true if the Identity matrix.
00088 
00089    inline TLorentzVector VectorMultiplication(const TLorentzVector&) const;
00090    inline TLorentzVector operator * (const TLorentzVector &) const;
00091    // Multiplication with a Lorentz vector.
00092 
00093    TLorentzRotation MatrixMultiplication(const TLorentzRotation &) const;
00094    inline TLorentzRotation operator * (const TLorentzRotation &) const;
00095    inline TLorentzRotation & operator *= (const TLorentzRotation &);
00096    inline TLorentzRotation & Transform(const TLorentzRotation &);
00097    inline TLorentzRotation & Transform(const TRotation &);
00098    // Matrix multiplication.
00099    // Note: a *= b; <=> a = a * b; while a.Transform(b); <=> a = b * a;
00100 
00101    inline TLorentzRotation Inverse() const;
00102    // Return the inverse.
00103 
00104    inline TLorentzRotation & Invert();
00105    // Inverts the LorentzRotation matrix.
00106 
00107    inline TLorentzRotation & Boost(Double_t, Double_t, Double_t);
00108    inline TLorentzRotation & Boost(const TVector3 &);
00109    // Lorenz boost.
00110 
00111    inline TLorentzRotation & RotateX(Double_t);
00112    // Rotation around x-axis.
00113 
00114    inline TLorentzRotation & RotateY(Double_t);
00115    // Rotation around y-axis.
00116 
00117    inline TLorentzRotation & RotateZ(Double_t);
00118    // Rotation around z-axis.
00119 
00120    inline TLorentzRotation & Rotate(Double_t, const TVector3 &);
00121    inline TLorentzRotation & Rotate(Double_t, const TVector3 *);
00122    // Rotation around specified vector.
00123 
00124 protected:
00125 
00126    Double_t fxx, fxy, fxz, fxt,
00127             fyx, fyy, fyz, fyt,
00128             fzx, fzy, fzz, fzt,
00129             ftx, fty, ftz, ftt;
00130    // The matrix elements.
00131 
00132    void SetBoost(Double_t, Double_t, Double_t);
00133    // Set elements according to a boost vector.
00134 
00135    TLorentzRotation(Double_t, Double_t, Double_t, Double_t,
00136                     Double_t, Double_t, Double_t, Double_t,
00137                     Double_t, Double_t, Double_t, Double_t,
00138                     Double_t, Double_t, Double_t, Double_t);
00139    // Protected constructor.
00140 
00141    ClassDef(TLorentzRotation,1) // Lorentz transformations including boosts and rotations
00142 
00143 };
00144 
00145 
00146 
00147 inline Double_t TLorentzRotation::XX() const { return fxx; }
00148 inline Double_t TLorentzRotation::XY() const { return fxy; }
00149 inline Double_t TLorentzRotation::XZ() const { return fxz; }
00150 inline Double_t TLorentzRotation::XT() const { return fxt; }
00151 inline Double_t TLorentzRotation::YX() const { return fyx; }
00152 inline Double_t TLorentzRotation::YY() const { return fyy; }
00153 inline Double_t TLorentzRotation::YZ() const { return fyz; }
00154 inline Double_t TLorentzRotation::YT() const { return fyt; }
00155 inline Double_t TLorentzRotation::ZX() const { return fzx; }
00156 inline Double_t TLorentzRotation::ZY() const { return fzy; }
00157 inline Double_t TLorentzRotation::ZZ() const { return fzz; }
00158 inline Double_t TLorentzRotation::ZT() const { return fzt; }
00159 inline Double_t TLorentzRotation::TX() const { return ftx; }
00160 inline Double_t TLorentzRotation::TY() const { return fty; }
00161 inline Double_t TLorentzRotation::TZ() const { return ftz; }
00162 inline Double_t TLorentzRotation::TT() const { return ftt; }
00163 
00164 inline TLorentzRotation::TLorentzRotationRow::TLorentzRotationRow
00165 (const TLorentzRotation & r, int i) : fRR(&r), fII(i) {}
00166 
00167 inline Double_t TLorentzRotation::TLorentzRotationRow::operator [] (int jj) const {
00168    return fRR->operator()(fII,jj);
00169 }
00170 
00171 inline TLorentzRotation::TLorentzRotationRow TLorentzRotation::operator [] (int i) const {
00172    return TLorentzRotationRow(*this, i);
00173 }
00174 
00175 inline TLorentzRotation & TLorentzRotation::operator = (const TLorentzRotation & r) {
00176    fxx = r.fxx; fxy = r.fxy; fxz = r.fxz; fxt = r.fxt;
00177    fyx = r.fyx; fyy = r.fyy; fyz = r.fyz; fyt = r.fyt;
00178    fzx = r.fzx; fzy = r.fzy; fzz = r.fzz; fzt = r.fzt;
00179    ftx = r.ftx; fty = r.fty; ftz = r.ftz; ftt = r.ftt;
00180    return *this;
00181 }
00182 
00183 //inline TLorentzRotation &
00184 //TLorentzRotation::operator = (const TRotation & r) {
00185 //  mxx = r.xx(); mxy = r.xy(); mxz = r.xz(); mxt = 0.0;
00186 //  myx = r.yx(); myy = r.yy(); myz = r.yz(); myt = 0.0;
00187 //  mzx = r.zx(); mzy = r.zy(); mzz = r.zz(); mzt = 0.0;
00188 //  mtx = 0.0;    mty = 0.0;    mtz = 0.0;    mtt = 1.0;
00189 //  return *this;
00190 //}
00191 
00192 inline TLorentzRotation & TLorentzRotation::operator = (const TRotation & r) {
00193    fxx = r.XX(); fxy = r.XY(); fxz = r.XZ(); fxt = 0.0;
00194    fyx = r.YX(); fyy = r.YY(); fyz = r.YZ(); fyt = 0.0;
00195    fzx = r.ZX(); fzy = r.ZY(); fzz = r.ZZ(); fzt = 0.0;
00196    ftx = 0.0;    fty = 0.0;    ftz = 0.0;    ftt = 1.0;
00197    return *this;
00198 }
00199 
00200 
00201 //inline Bool_t
00202 //TLorentzRotation::operator == (const TLorentzRotation & r) const {
00203 //  return (mxx == r.xx() && mxy == r.xy() && mxz == r.xz() && mxt == r.xt() &&
00204 //          myx == r.yx() && myy == r.yy() && myz == r.yz() && myt == r.yt() &&
00205 //          mzx == r.zx() && mzy == r.zy() && mzz == r.zz() && mzt == r.zt() &&
00206 //          mtx == r.tx() && mty == r.ty() && mtz == r.tz() && mtt == r.tt())
00207 //  ? kTRUE : kFALSE;
00208 //}
00209 
00210 inline Bool_t TLorentzRotation::operator == (const TLorentzRotation & r) const {
00211    return (fxx == r.fxx && fxy == r.fxy && fxz == r.fxz && fxt == r.fxt &&
00212            fyx == r.fyx && fyy == r.fyy && fyz == r.fyz && fyt == r.fyt &&
00213            fzx == r.fzx && fzy == r.fzy && fzz == r.fzz && fzt == r.fzt &&
00214            ftx == r.ftx && fty == r.fty && ftz == r.ftz && ftt == r.ftt)
00215    ? kTRUE : kFALSE;
00216 }
00217 
00218 //inline Bool_t
00219 //TLorentzRotation::operator != (const TLorentzRotation & r) const {
00220 //  return (mxx != r.xx() || mxy != r.xy() || mxz != r.xz() || mxt != r.xt() ||
00221 //          myx != r.yx() || myy != r.yy() || myz != r.yz() || myt != r.yt() ||
00222 //          mzx != r.zx() || mzy != r.zy() || mzz != r.zz() || mzt != r.zt() ||
00223 //          mtx != r.tx() || mty != r.ty() || mtz != r.tz() || mtt != r.tt())
00224 //  ? kTRUE : kFALSE;
00225 //}
00226 
00227 inline Bool_t TLorentzRotation::operator != (const TLorentzRotation & r) const {
00228    return (fxx != r.fxx || fxy != r.fxy || fxz != r.fxz || fxt != r.fxt ||
00229            fyx != r.fyx || fyy != r.fyy || fyz != r.fyz || fyt != r.fyt ||
00230            fzx != r.fzx || fzy != r.fzy || fzz != r.fzz || fzt != r.fzt ||
00231            ftx != r.ftx || fty != r.fty || ftz != r.ftz || ftt != r.ftt)
00232    ? kTRUE : kFALSE;
00233 }
00234 
00235 inline Bool_t TLorentzRotation::IsIdentity() const {
00236    return (fxx == 1.0 && fxy == 0.0 && fxz == 0.0 && fxt == 0.0 &&
00237            fyx == 0.0 && fyy == 1.0 && fyz == 0.0 && fyt == 0.0 &&
00238            fzx == 0.0 && fzy == 0.0 && fzz == 1.0 && fzt == 0.0 &&
00239            ftx == 0.0 && fty == 0.0 && ftz == 0.0 && ftt == 1.0)
00240    ? kTRUE : kFALSE;
00241 }
00242 
00243 
00244 inline TLorentzVector TLorentzRotation::VectorMultiplication(const TLorentzVector & p) const {
00245    return TLorentzVector(fxx*p.X()+fxy*p.Y()+fxz*p.Z()+fxt*p.T(),
00246                          fyx*p.X()+fyy*p.Y()+fyz*p.Z()+fyt*p.T(),
00247                          fzx*p.X()+fzy*p.Y()+fzz*p.Z()+fzt*p.T(),
00248                          ftx*p.X()+fty*p.Y()+ftz*p.Z()+ftt*p.T());
00249 }
00250 
00251 inline TLorentzVector TLorentzRotation::operator * (const TLorentzVector & p) const {
00252    return VectorMultiplication(p);
00253 }
00254 
00255 inline TLorentzRotation TLorentzRotation::operator * (const TLorentzRotation & m) const {
00256    return MatrixMultiplication(m);
00257 }
00258 
00259 inline TLorentzRotation & TLorentzRotation::operator *= (const TLorentzRotation & m) {
00260    return *this = MatrixMultiplication(m);
00261 }
00262 
00263 inline TLorentzRotation & TLorentzRotation::Transform(const TLorentzRotation & m) {
00264    return *this = m.MatrixMultiplication(*this);
00265 }
00266 
00267 inline TLorentzRotation & TLorentzRotation::Transform(const TRotation & m){
00268    return Transform(TLorentzRotation(m));
00269 }
00270 
00271 inline TLorentzRotation TLorentzRotation::Inverse() const {
00272    return TLorentzRotation( fxx,  fyx,  fzx, -ftx,
00273                             fxy,  fyy,  fzy, -fty,
00274                             fxz,  fyz,  fzz, -ftz,
00275                            -fxt, -fyt, -fzt,  ftt);
00276 }
00277 
00278 inline TLorentzRotation & TLorentzRotation::Invert() {
00279    return *this = Inverse();
00280 }
00281 
00282 inline TLorentzRotation & TLorentzRotation::Boost(Double_t bx, Double_t by, Double_t bz) {
00283    return Transform(TLorentzRotation(bx, by, bz));
00284 }
00285 
00286 inline TLorentzRotation & TLorentzRotation::Boost(const TVector3 & b) {
00287    return Transform(TLorentzRotation(b));
00288 }
00289 
00290 inline TLorentzRotation & TLorentzRotation::RotateX(Double_t angle) {
00291    return Transform(TRotation().RotateX(angle));
00292 }
00293 
00294 inline TLorentzRotation & TLorentzRotation::RotateY(Double_t angle) {
00295    return Transform(TRotation().RotateY(angle));
00296 }
00297 
00298 inline TLorentzRotation & TLorentzRotation::RotateZ(Double_t angle) {
00299    return Transform(TRotation().RotateZ(angle));
00300 }
00301 
00302 inline TLorentzRotation & TLorentzRotation::Rotate(Double_t angle, const TVector3 & axis) {
00303    return Transform(TRotation().Rotate(angle, axis));
00304 }
00305 
00306 inline TLorentzRotation & TLorentzRotation::Rotate(Double_t angle, const TVector3 * axis) {
00307    return Transform(TRotation().Rotate(angle, axis));
00308 }
00309 
00310 #endif

Generated on Tue Jul 5 14:27:00 2011 for ROOT_528-00b_version by  doxygen 1.5.1