Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:56:46

0001 // @(#)root/physics:$Id$
0002 // Author: Peter Malzacher   19/06/99
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TLorentzRotation
0013 #define ROOT_TLorentzRotation
0014 
0015 
0016 #include "TRotation.h"
0017 #include "TLorentzVector.h"
0018 
0019 
0020 class TLorentzRotation : public TObject {
0021 
0022 
0023 public:
0024 
0025 class TLorentzRotationRow {
0026 public:
0027    inline TLorentzRotationRow(const TLorentzRotation &, int);
0028    inline Double_t operator [] (int) const;
0029 private:
0030    const TLorentzRotation * fRR;
0031    int fII;
0032 };
0033    // Helper class for implementation of C-style subscripting r[i][j]
0034 
0035    TLorentzRotation();
0036    // Default constructor. Gives a unit matrix.
0037 
0038    TLorentzRotation(const TRotation &);
0039    // Constructor for 3d rotations.
0040 
0041    TLorentzRotation(const TLorentzRotation &);
0042    // Copy constructor.
0043 
0044    TLorentzRotation(Double_t, Double_t, Double_t);
0045    TLorentzRotation(const TVector3 &);
0046    // Constructors giving a Lorenz-boost.
0047 
0048    inline Double_t XX() const;
0049    inline Double_t XY() const;
0050    inline Double_t XZ() const;
0051    inline Double_t XT() const;
0052    inline Double_t YX() const;
0053    inline Double_t YY() const;
0054    inline Double_t YZ() const;
0055    inline Double_t YT() const;
0056    inline Double_t ZX() const;
0057    inline Double_t ZY() const;
0058    inline Double_t ZZ() const;
0059    inline Double_t ZT() const;
0060    inline Double_t TX() const;
0061    inline Double_t TY() const;
0062    inline Double_t TZ() const;
0063    inline Double_t TT() const;
0064    // Elements of the matrix.
0065 
0066    inline TLorentzRotationRow operator [] (int) const;
0067    // Returns object of the helper class for C-style subscripting r[i][j]
0068 
0069 
0070    Double_t operator () (int, int) const;
0071    // Fortran-style subscriptimg: returns (i,j) element of the matrix.
0072 
0073 
0074    inline TLorentzRotation & operator = (const TLorentzRotation &);
0075    inline TLorentzRotation & operator = (const TRotation &);
0076    // Assignment.
0077 
0078    inline Bool_t operator == (const TLorentzRotation &) const;
0079    inline Bool_t operator != (const TLorentzRotation &) const;
0080    // Comparisons.
0081 
0082    inline Bool_t IsIdentity() const;
0083    // Returns true if the Identity matrix.
0084 
0085    inline TLorentzVector VectorMultiplication(const TLorentzVector&) const;
0086    inline TLorentzVector operator * (const TLorentzVector &) const;
0087    // Multiplication with a Lorentz vector.
0088 
0089    TLorentzRotation MatrixMultiplication(const TLorentzRotation &) const;
0090    inline TLorentzRotation operator * (const TLorentzRotation &) const;
0091    inline TLorentzRotation & operator *= (const TLorentzRotation &);
0092    inline TLorentzRotation & Transform(const TLorentzRotation &);
0093    inline TLorentzRotation & Transform(const TRotation &);
0094    // Matrix multiplication.
0095    // Note: a *= b; <=> a = a * b; while a.Transform(b); <=> a = b * a;
0096 
0097    inline TLorentzRotation Inverse() const;
0098    // Return the inverse.
0099 
0100    inline TLorentzRotation & Invert();
0101    // Inverts the LorentzRotation matrix.
0102 
0103    inline TLorentzRotation & Boost(Double_t, Double_t, Double_t);
0104    inline TLorentzRotation & Boost(const TVector3 &);
0105    // Lorenz boost.
0106 
0107    inline TLorentzRotation & RotateX(Double_t);
0108    // Rotation around x-axis.
0109 
0110    inline TLorentzRotation & RotateY(Double_t);
0111    // Rotation around y-axis.
0112 
0113    inline TLorentzRotation & RotateZ(Double_t);
0114    // Rotation around z-axis.
0115 
0116    inline TLorentzRotation & Rotate(Double_t, const TVector3 &);
0117    inline TLorentzRotation & Rotate(Double_t, const TVector3 *);
0118    // Rotation around specified vector.
0119 
0120 protected:
0121 
0122    Double_t fxx, fxy, fxz, fxt,
0123             fyx, fyy, fyz, fyt,
0124             fzx, fzy, fzz, fzt,
0125             ftx, fty, ftz, ftt;
0126    // The matrix elements.
0127 
0128    void SetBoost(Double_t, Double_t, Double_t);
0129    // Set elements according to a boost vector.
0130 
0131    TLorentzRotation(Double_t, Double_t, Double_t, Double_t,
0132                     Double_t, Double_t, Double_t, Double_t,
0133                     Double_t, Double_t, Double_t, Double_t,
0134                     Double_t, Double_t, Double_t, Double_t);
0135    // Protected constructor.
0136 
0137    ClassDefOverride(TLorentzRotation,1) // Lorentz transformations including boosts and rotations
0138 
0139 };
0140 
0141 
0142 
0143 inline Double_t TLorentzRotation::XX() const { return fxx; }
0144 inline Double_t TLorentzRotation::XY() const { return fxy; }
0145 inline Double_t TLorentzRotation::XZ() const { return fxz; }
0146 inline Double_t TLorentzRotation::XT() const { return fxt; }
0147 inline Double_t TLorentzRotation::YX() const { return fyx; }
0148 inline Double_t TLorentzRotation::YY() const { return fyy; }
0149 inline Double_t TLorentzRotation::YZ() const { return fyz; }
0150 inline Double_t TLorentzRotation::YT() const { return fyt; }
0151 inline Double_t TLorentzRotation::ZX() const { return fzx; }
0152 inline Double_t TLorentzRotation::ZY() const { return fzy; }
0153 inline Double_t TLorentzRotation::ZZ() const { return fzz; }
0154 inline Double_t TLorentzRotation::ZT() const { return fzt; }
0155 inline Double_t TLorentzRotation::TX() const { return ftx; }
0156 inline Double_t TLorentzRotation::TY() const { return fty; }
0157 inline Double_t TLorentzRotation::TZ() const { return ftz; }
0158 inline Double_t TLorentzRotation::TT() const { return ftt; }
0159 
0160 inline TLorentzRotation::TLorentzRotationRow::TLorentzRotationRow
0161 (const TLorentzRotation & r, int i) : fRR(&r), fII(i) {}
0162 
0163 inline Double_t TLorentzRotation::TLorentzRotationRow::operator [] (int jj) const {
0164    return fRR->operator()(fII,jj);
0165 }
0166 
0167 inline TLorentzRotation::TLorentzRotationRow TLorentzRotation::operator [] (int i) const {
0168    return TLorentzRotationRow(*this, i);
0169 }
0170 
0171 inline TLorentzRotation & TLorentzRotation::operator = (const TLorentzRotation & r) {
0172    fxx = r.fxx; fxy = r.fxy; fxz = r.fxz; fxt = r.fxt;
0173    fyx = r.fyx; fyy = r.fyy; fyz = r.fyz; fyt = r.fyt;
0174    fzx = r.fzx; fzy = r.fzy; fzz = r.fzz; fzt = r.fzt;
0175    ftx = r.ftx; fty = r.fty; ftz = r.ftz; ftt = r.ftt;
0176    return *this;
0177 }
0178 
0179 //inline TLorentzRotation &
0180 //TLorentzRotation::operator = (const TRotation & r) {
0181 //  mxx = r.xx(); mxy = r.xy(); mxz = r.xz(); mxt = 0.0;
0182 //  myx = r.yx(); myy = r.yy(); myz = r.yz(); myt = 0.0;
0183 //  mzx = r.zx(); mzy = r.zy(); mzz = r.zz(); mzt = 0.0;
0184 //  mtx = 0.0;    mty = 0.0;    mtz = 0.0;    mtt = 1.0;
0185 //  return *this;
0186 //}
0187 
0188 inline TLorentzRotation & TLorentzRotation::operator = (const TRotation & r) {
0189    fxx = r.XX(); fxy = r.XY(); fxz = r.XZ(); fxt = 0.0;
0190    fyx = r.YX(); fyy = r.YY(); fyz = r.YZ(); fyt = 0.0;
0191    fzx = r.ZX(); fzy = r.ZY(); fzz = r.ZZ(); fzt = 0.0;
0192    ftx = 0.0;    fty = 0.0;    ftz = 0.0;    ftt = 1.0;
0193    return *this;
0194 }
0195 
0196 
0197 //inline Bool_t
0198 //TLorentzRotation::operator == (const TLorentzRotation & r) const {
0199 //  return (mxx == r.xx() && mxy == r.xy() && mxz == r.xz() && mxt == r.xt() &&
0200 //          myx == r.yx() && myy == r.yy() && myz == r.yz() && myt == r.yt() &&
0201 //          mzx == r.zx() && mzy == r.zy() && mzz == r.zz() && mzt == r.zt() &&
0202 //          mtx == r.tx() && mty == r.ty() && mtz == r.tz() && mtt == r.tt())
0203 //  ? kTRUE : kFALSE;
0204 //}
0205 
0206 inline Bool_t TLorentzRotation::operator == (const TLorentzRotation & r) const {
0207    return (fxx == r.fxx && fxy == r.fxy && fxz == r.fxz && fxt == r.fxt &&
0208            fyx == r.fyx && fyy == r.fyy && fyz == r.fyz && fyt == r.fyt &&
0209            fzx == r.fzx && fzy == r.fzy && fzz == r.fzz && fzt == r.fzt &&
0210            ftx == r.ftx && fty == r.fty && ftz == r.ftz && ftt == r.ftt)
0211    ? kTRUE : kFALSE;
0212 }
0213 
0214 //inline Bool_t
0215 //TLorentzRotation::operator != (const TLorentzRotation & r) const {
0216 //  return (mxx != r.xx() || mxy != r.xy() || mxz != r.xz() || mxt != r.xt() ||
0217 //          myx != r.yx() || myy != r.yy() || myz != r.yz() || myt != r.yt() ||
0218 //          mzx != r.zx() || mzy != r.zy() || mzz != r.zz() || mzt != r.zt() ||
0219 //          mtx != r.tx() || mty != r.ty() || mtz != r.tz() || mtt != r.tt())
0220 //  ? kTRUE : kFALSE;
0221 //}
0222 
0223 inline Bool_t TLorentzRotation::operator != (const TLorentzRotation & r) const {
0224    return (fxx != r.fxx || fxy != r.fxy || fxz != r.fxz || fxt != r.fxt ||
0225            fyx != r.fyx || fyy != r.fyy || fyz != r.fyz || fyt != r.fyt ||
0226            fzx != r.fzx || fzy != r.fzy || fzz != r.fzz || fzt != r.fzt ||
0227            ftx != r.ftx || fty != r.fty || ftz != r.ftz || ftt != r.ftt)
0228    ? kTRUE : kFALSE;
0229 }
0230 
0231 inline Bool_t TLorentzRotation::IsIdentity() const {
0232    return (fxx == 1.0 && fxy == 0.0 && fxz == 0.0 && fxt == 0.0 &&
0233            fyx == 0.0 && fyy == 1.0 && fyz == 0.0 && fyt == 0.0 &&
0234            fzx == 0.0 && fzy == 0.0 && fzz == 1.0 && fzt == 0.0 &&
0235            ftx == 0.0 && fty == 0.0 && ftz == 0.0 && ftt == 1.0)
0236    ? kTRUE : kFALSE;
0237 }
0238 
0239 
0240 inline TLorentzVector TLorentzRotation::VectorMultiplication(const TLorentzVector & p) const {
0241    return TLorentzVector(fxx*p.X()+fxy*p.Y()+fxz*p.Z()+fxt*p.T(),
0242                          fyx*p.X()+fyy*p.Y()+fyz*p.Z()+fyt*p.T(),
0243                          fzx*p.X()+fzy*p.Y()+fzz*p.Z()+fzt*p.T(),
0244                          ftx*p.X()+fty*p.Y()+ftz*p.Z()+ftt*p.T());
0245 }
0246 
0247 inline TLorentzVector TLorentzRotation::operator * (const TLorentzVector & p) const {
0248    return VectorMultiplication(p);
0249 }
0250 
0251 inline TLorentzRotation TLorentzRotation::operator * (const TLorentzRotation & m) const {
0252    return MatrixMultiplication(m);
0253 }
0254 
0255 inline TLorentzRotation & TLorentzRotation::operator *= (const TLorentzRotation & m) {
0256    return *this = MatrixMultiplication(m);
0257 }
0258 
0259 inline TLorentzRotation & TLorentzRotation::Transform(const TLorentzRotation & m) {
0260    return *this = m.MatrixMultiplication(*this);
0261 }
0262 
0263 inline TLorentzRotation & TLorentzRotation::Transform(const TRotation & m){
0264    return Transform(TLorentzRotation(m));
0265 }
0266 
0267 inline TLorentzRotation TLorentzRotation::Inverse() const {
0268    return TLorentzRotation( fxx,  fyx,  fzx, -ftx,
0269                             fxy,  fyy,  fzy, -fty,
0270                             fxz,  fyz,  fzz, -ftz,
0271                            -fxt, -fyt, -fzt,  ftt);
0272 }
0273 
0274 inline TLorentzRotation & TLorentzRotation::Invert() {
0275    return *this = Inverse();
0276 }
0277 
0278 inline TLorentzRotation & TLorentzRotation::Boost(Double_t bx, Double_t by, Double_t bz) {
0279    return Transform(TLorentzRotation(bx, by, bz));
0280 }
0281 
0282 inline TLorentzRotation & TLorentzRotation::Boost(const TVector3 & b) {
0283    return Transform(TLorentzRotation(b));
0284 }
0285 
0286 inline TLorentzRotation & TLorentzRotation::RotateX(Double_t angle) {
0287    return Transform(TRotation().RotateX(angle));
0288 }
0289 
0290 inline TLorentzRotation & TLorentzRotation::RotateY(Double_t angle) {
0291    return Transform(TRotation().RotateY(angle));
0292 }
0293 
0294 inline TLorentzRotation & TLorentzRotation::RotateZ(Double_t angle) {
0295    return Transform(TRotation().RotateZ(angle));
0296 }
0297 
0298 inline TLorentzRotation & TLorentzRotation::Rotate(Double_t angle, const TVector3 & axis) {
0299    return Transform(TRotation().Rotate(angle, axis));
0300 }
0301 
0302 inline TLorentzRotation & TLorentzRotation::Rotate(Double_t angle, const TVector3 * axis) {
0303    return Transform(TRotation().Rotate(angle, axis));
0304 }
0305 
0306 #endif