Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

TMBLorentzVector.hpp

Go to the documentation of this file.
00001 #ifndef INCLUDE_TMBLORENTZVECTOR
00002 #define INCLUDE_TMBLORENTZVECTOR
00003 
00004 
00005 // See copyright statements at end of file.
00006 
00007 #ifndef INCLUDE_TMBVECTOR3
00008 #include "tmb_tree/TMBVector3.hpp"
00009 #endif
00010 #ifndef ROOT_TRotation
00011 #include "TRotation.h"
00012 #endif
00013 
00014 #ifndef ROOT_TLorentzVector
00015 #include "TLorentzVector.h"
00016 #endif
00017 
00018 class TLorentzRotation;
00019 
00035 class TMBLorentzVector: public TMBVector3 {
00036 
00037 public:
00038 
00040    enum ECoordinates { 
00041        kX = 0, 
00042        kY = 1, 
00043        kZ = 2, 
00044        kE = 3, 
00045        kNUM_COORDINATES = 4, 
00046        kSIZE = kNUM_COORDINATES 
00047    };
00048 
00050    enum EInitializer { 
00051        kXYZE, 
00052        kXYZM, 
00053        kPEtaPhiE, 
00054        kPEtaPhiM, 
00055        kPtEtaPhiE, 
00056        kPtEtaPhiM 
00057    };
00058 
00059    TMBLorentzVector(Double_t a = 0.0, Double_t b = 0.0,
00060                     Double_t c = 0.0, Double_t d = 0.0, 
00061                     EInitializer init = kXYZE) 
00062        : TMBVector3 ()
00063    {
00067        Set(a,b,c,d,init);
00068    }
00069 
00070    TMBLorentzVector(const TVector3& vect, Double_t v4, EInitializer init=kXYZE):
00071       TMBVector3(vect) {
00074       switch (init) {
00075          case kXYZM: case kPEtaPhiM: case kPtEtaPhiM: fM=v4;
00076          default: SetE(v4);
00077       }
00078    }
00079    TMBLorentzVector(const Double_t * a, EInitializer init=kXYZE) 
00080     : TMBVector3()
00081    {
00085        Set(a[0],a[1],a[2],a[3],init);
00086    }
00087    TMBLorentzVector(const Float_t * a, EInitializer init=kXYZE) {
00091        Set(a[0],a[1],a[2],a[3],init);
00092    }
00093 
00094    TMBLorentzVector(const TMBLorentzVector& lv): 
00095      TMBVector3(lv.Vect()), fM(lv.fM) {
00097      }
00098 
00099    TMBLorentzVector(const TLorentzVector& lv): TMBVector3(lv.Vect()) {
00101       SetE(lv.E()); }
00102 
00103    virtual ~TMBLorentzVector() {}
00105 
00106 
00108 
00109 
00110    Double_t M() const { 
00112       return fM; }
00113 
00114    virtual Double_t E()  const { 
00115       return TMath::Sqrt(fM*fM+Mag32()); }
00116    Double_t Energy() const { 
00117       return E(); }
00118    Double_t T() const { 
00119       return E(); }
00120 
00121    virtual const TMBVector3& Vect() const { 
00122       return *this; }
00123    virtual TMBVector3& Vect() { 
00124       return *this; }
00125 
00126    void GetXYZT(Double_t *carray) const { 
00128       GetXYZ(carray); carray[3]=E(); }
00129    void GetXYZT(Float_t *carray) const {
00131       GetXYZ(carray); carray[3]=E(); }
00132 
00133    Double_t operator () (int i) const;
00134    Double_t operator [] (int i) const { 
00137       return operator ()(i); } 
00138 
00140 
00142 
00143 
00144    void Set(Double_t a = 0.0, Double_t b = 0.0,
00145        Double_t c = 0.0, Double_t d = 0.0, 
00146        EInitializer init = kXYZE) {
00150        switch (init) {
00151        case kXYZM: SetXYZM(a,b,c,d); break;
00152        case kPEtaPhiE: SetPEtaPhiE(a,b,c,d); break;
00153        case kPEtaPhiM: SetPEtaPhiM(a,b,c,d); break;
00154        case kPtEtaPhiE: SetPtEtaPhiE(a,b,c,d); break;
00155        case kPtEtaPhiM: SetPtEtaPhiM(a,b,c,d); break;
00156        default: SetXYZT(a,b,c,d);
00157        }
00158    }
00159 
00160    void SetM(Double_t a) { 
00161       fM=a; }
00162 
00163    void SetT(Double_t a) { 
00164       Double_t m2=a*a-Mag32(); 
00165       fM=m2>0?TMath::Sqrt(m2) : -TMath::Sqrt(-m2); 
00166    }
00167    void SetE(Double_t a) { 
00168       SetT(a); }
00169 
00170    void SetVect(const TVector3 & vect3) { 
00171       Vect()=vect3; }
00172 
00173    void SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e) {
00175       SetXYZT(px,py,pz,e); }
00176    void SetXYZT(Double_t  x, Double_t  y, Double_t  z, Double_t t) {
00178       SetXYZ(x,y,z); SetE(t); }
00179    void SetXYZM(Double_t  x, Double_t  y, Double_t  z, Double_t m) {
00181       SetXYZ(x,y,z); SetM(m); }
00182    void SetPtEtaPhiE(Double_t pt, Double_t eta, Double_t phi, Double_t e) {
00184       SetPtEtaPhi(pt,eta,phi); SetE(e); }
00185    void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m) {
00187       SetPtEtaPhi(pt,eta,phi); fM=m; }
00188    void SetPEtaPhiE(Double_t p, Double_t eta, Double_t phi, Double_t e) {
00190       SetPtEtaPhi(p*TMath::Sin(2.*TMath::ATan(TMath::Exp(-eta))),eta,phi); SetE(e); }
00191    void SetPEtaPhiM(Double_t p, Double_t eta, Double_t phi, Double_t m) {
00193       SetPtEtaPhi(p*TMath::Sin(2.*TMath::ATan(TMath::Exp(-eta))),eta,phi); fM=m; }
00194 
00196 
00197    TMBLorentzVector & operator = (const TMBLorentzVector & lv) {
00199       Vect()=lv.Vect(); fM = lv.fM; return *this; }
00200    
00201 
00202    TMBLorentzVector   operator +  (const TMBLorentzVector &lv) const {
00204       return TMBLorentzVector(Vect()+lv.Vect(), E()+lv.E()); }
00205    TMBLorentzVector & operator += (const TMBLorentzVector &lv) {
00207       Double_t e=E(); Vect()+=lv.Vect(); SetE(e+lv.E()); return *this; }
00208 
00209    TMBLorentzVector   operator -  (const TMBLorentzVector &lv) const {
00211       return TMBLorentzVector(Vect()-lv.Vect(), E()-lv.E()); }
00212    TMBLorentzVector & operator -= (const TMBLorentzVector &lv) {
00214       Double_t e=E(); Vect()-=lv.Vect(); SetE(e-lv.E()); return *this; }
00215 
00216    TMBLorentzVector operator - () const {
00218       return TMBLorentzVector(-Vect(),-E()); }
00219 
00220    TMBLorentzVector operator * (Double_t a) const {
00222       return TMBLorentzVector(Vect()*a, E()*a); }
00223    TMBLorentzVector & operator *= (Double_t a) {
00225       Vect()*=a; fM*=a; return *this; }
00226 
00227    Bool_t operator == (const TMBLorentzVector &lv) const {
00230       return (fM==lv.fM && Vect()==lv.Vect()); }
00231    Bool_t operator != (const TMBLorentzVector &lv) const {
00234       return !(operator == (lv)); }
00235 
00238    Bool_t is_equal (const TMBLorentzVector &lv) const;
00239 
00240    Double_t Mag2() const { 
00241       return fM*fM; }
00242    Double_t M2() const { 
00243       return Mag2(); }
00244 
00245    Double_t Mag() const { 
00246       return fM;
00247    }
00248 
00249    Double_t Mt2() const { 
00250       return E()*E() - Z()*Z(); }
00251    
00252 
00253    Double_t Mt() const { 
00254       Double_t mm=Mt2(); 
00255       return mm < 0.0 ? -TMath::Sqrt(-mm) : TMath::Sqrt(mm); }
00256 
00257    Double_t Beta() const { 
00259       if (E()!=0) return Mag3() / E(); 
00260       else Warning("Beta()", "E()==0.!"); return 0.; }
00261    Double_t Gamma() const {
00263       Double_t b = Beta();
00264       b*=b;
00265       if (b!=1.) return 1.0/TMath::Sqrt(1- b*b);
00266       else Warning("Gamma()", "Beta()==1.!"); return 0.; }
00267 
00268    Double_t Dot(const TMBLorentzVector &lv) const {
00270       return E()*lv.E() - Vect().Dot(lv.Vect()); }
00271    Double_t operator * (const TMBLorentzVector &lv) const {
00273       return Dot(lv);}
00274 
00275    void SetVectMag(const TVector3 & spatial, Double_t magnitude) {
00277       Vect()=spatial; SetE(TMath::Sqrt(magnitude * magnitude + spatial * spatial)); }
00278    void SetVectM(const TVector3 & spatial, Double_t mass) {
00280       SetVectMag(spatial, mass); }
00281    void SetVectE(const TVector3 & spatial, Double_t e) {
00283       Vect()=spatial; SetE(e); }
00284 
00285    Double_t Plus() const { 
00293       return E() + Vect().Z(); }
00294    Double_t Minus() const { 
00302       return E() - Vect().Z(); }
00303 
00304    TVector3 BoostVector() const {
00306       if (E()!=0.) return 1./E()*Vect();
00307       else Warning("BoostVector()","E()==0.!"); return TVector3(); }
00308 
00309    void Boost(Double_t x, Double_t y, Double_t z) { 
00311       Boost(TVector3(x,y,z)); }
00312    void Boost(const TVector3 & b);
00313 
00314    Double_t Rapidity() const { 
00316       if (E()!=Pz()) return .5*log( (E()+Pz()) / (E()-Pz()) );
00317       else Warning("Rapidity", "E()==Pz()!"); return 0.; }
00318 
00319 
00320    TMBLorentzVector & operator *= (const TRotation &m) {
00322       Vect() *= m; return *this; }
00323    TMBLorentzVector & Transform(const TRotation &m) {
00325       Vect().Transform(m); return *this; }
00326    TMBLorentzVector & operator *= (const TLorentzRotation &);
00327    TMBLorentzVector & Transform(const TLorentzRotation &);
00329 
00330    operator TLorentzVector() const { 
00332       return TLorentzVector(X(),Y(),Z(),E()); }
00333 
00334 private:
00335    Double32_t fM; 
00336    ClassDef(TMBLorentzVector,1) // A four vector with (-,-,-,+) metric
00337 };
00338 
00339 inline
00340 TMBLorentzVector operator * (Double_t a, const TMBLorentzVector & p) {
00342    return TMBLorentzVector(a*p.Vect(), a*p.E());
00343 }
00344 
00345 /*************************************************************************
00346 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00347 * All rights reserved.                                                  *
00348 *                                                                       *
00349 * For the licensing terms see $ROOTSYS/LICENSE.                         *
00350 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00351 *************************************************************************/
00352 
00353 //------------------------------------------------------------------------------
00354 // Copyright(c) 1995-1997, P.Murat (CDF collaboration, FNAL)
00355 //
00356 // Permission to use, copy, modify and distribute this software and its
00357 // documentation for non-commercial purposes is hereby granted without fee,
00358 // provided that the above copyright notice appears in all copies and
00359 // that both the copyright notice and this permission notice appear in
00360 // the supporting documentation. The authors make no claims about the
00361 // suitability of this software for any purpose.
00362 // It is provided "as is" without express or implied warranty.
00363 // *0001 Mar 29 1999 P.Murat: add forgotten scalar product (dot operator)
00364 //------------------------------------------------------------------------------
00365 
00366 #endif // INCLUDE_TMBLORENTZVECTOR

Generated on Tue Mar 28 10:13:05 2006 for CAF by doxygen 1.3.4