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 
00036 class TMBLorentzVector: public TMBVector3 {
00037 
00038 public:
00039 
00041    enum ECoordinates { 
00042        kX = 0, 
00043        kY = 1, 
00044        kZ = 2, 
00045        kE = 3, 
00046        kNUM_COORDINATES = 4, 
00047        kSIZE = kNUM_COORDINATES 
00048    };
00049 
00051    enum EInitializer { 
00052        kXYZE, 
00053        kXYZM, 
00054        kPEtaPhiE, 
00055        kPEtaPhiM, 
00056        kPtEtaPhiE, 
00057        kPtEtaPhiM 
00058    };
00059 
00060    TMBLorentzVector(Double_t a = 0.0, Double_t b = 0.0,
00061                     Double_t c = 0.0, Double_t d = 0.0, 
00062                     EInitializer init = kXYZE) 
00063        : TMBVector3 ()
00064    {
00068        Set(a,b,c,d,init);
00069    }
00070 
00071    TMBLorentzVector(const TVector3& vect, Double_t v4, EInitializer init=kXYZE):
00072       TMBVector3(vect) {
00075       switch (init) {
00076          case kXYZM: case kPEtaPhiM: case kPtEtaPhiM: fM=v4;
00077          default: SetE(v4);
00078       }
00079    }
00080    TMBLorentzVector(const Double_t * a, EInitializer init=kXYZE) 
00081     : TMBVector3()
00082    {
00086        Set(a[0],a[1],a[2],a[3],init);
00087    }
00088    TMBLorentzVector(const Float_t * a, EInitializer init=kXYZE) {
00092        Set(a[0],a[1],a[2],a[3],init);
00093    }
00094 
00095    TMBLorentzVector(const TMBLorentzVector& lv): 
00096      TMBVector3(lv.Vect()), fM(lv.fM) {
00098      }
00099 
00100    TMBLorentzVector(const TLorentzVector& lv): TMBVector3(lv.Vect()) {
00102       SetE(lv.E()); }
00103 
00104    virtual ~TMBLorentzVector() {}
00106 
00107 
00109 
00110 
00111    Double_t M() const { 
00113       return fM; }
00114 
00115    virtual Double_t E()  const { 
00116       return TMath::Sqrt(fM*fM+Mag32()); }
00117    Double_t Energy() const { 
00118       return E(); }
00119    Double_t T() const { 
00120       return E(); }
00121 
00122    virtual const TMBVector3& Vect() const { 
00123       return *this; }
00124    virtual TMBVector3& Vect() { 
00125       return *this; }
00126 
00127    void GetXYZT(Double_t *carray) const { 
00129       GetXYZ(carray); carray[3]=E(); }
00130    void GetXYZT(Float_t *carray) const {
00132       GetXYZ(carray); carray[3]=E(); }
00133 
00134    Double_t operator () (int i) const;
00135    Double_t operator [] (int i) const { 
00138       return operator ()(i); } 
00139 
00141 
00143 
00144 
00145    void Set(Double_t a = 0.0, Double_t b = 0.0,
00146        Double_t c = 0.0, Double_t d = 0.0, 
00147        EInitializer init = kXYZE) {
00151        switch (init) {
00152        case kXYZM: SetXYZM(a,b,c,d); break;
00153        case kPEtaPhiE: SetPEtaPhiE(a,b,c,d); break;
00154        case kPEtaPhiM: SetPEtaPhiM(a,b,c,d); break;
00155        case kPtEtaPhiE: SetPtEtaPhiE(a,b,c,d); break;
00156        case kPtEtaPhiM: SetPtEtaPhiM(a,b,c,d); break;
00157        default: SetXYZT(a,b,c,d);
00158        }
00159    }
00160 
00161    void SetM(Double_t a) { 
00162       fM=a; }
00163 
00164    void SetT(Double_t a) { 
00165       Double_t m2=a*a-Mag32(); 
00166       fM=m2>0?TMath::Sqrt(m2) : -TMath::Sqrt(-m2); 
00167    }
00168    void SetE(Double_t a) { 
00169       SetT(a); }
00170 
00171    void SetVect(const TVector3 & vect3) { 
00172       Vect()=vect3; }
00173 
00174    void SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e) {
00176       SetXYZT(px,py,pz,e); }
00177    void SetXYZT(Double_t  x, Double_t  y, Double_t  z, Double_t t) {
00179       SetXYZ(x,y,z); SetE(t); }
00180    void SetXYZM(Double_t  x, Double_t  y, Double_t  z, Double_t m) {
00182       SetXYZ(x,y,z); SetM(m); }
00183    void SetPtEtaPhiE(Double_t pt, Double_t eta, Double_t phi, Double_t e) {
00185       SetPtEtaPhi(pt,eta,phi); SetE(e); }
00186    void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m) {
00188       SetPtEtaPhi(pt,eta,phi); fM=m; }
00189    void SetPEtaPhiE(Double_t p, Double_t eta, Double_t phi, Double_t e) {
00191       SetPtEtaPhi(p*TMath::Sin(2.*TMath::ATan(TMath::Exp(-eta))),eta,phi); SetE(e); }
00192    void SetPEtaPhiM(Double_t p, Double_t eta, Double_t phi, Double_t m) {
00194       SetPtEtaPhi(p*TMath::Sin(2.*TMath::ATan(TMath::Exp(-eta))),eta,phi); fM=m; }
00195 
00197 
00198    TMBLorentzVector & operator = (const TMBLorentzVector & lv) {
00200       Vect()=lv.Vect(); fM = lv.fM; return *this; }
00201    
00202 
00203    TMBLorentzVector   operator +  (const TMBLorentzVector &lv) const {
00205       return TMBLorentzVector(Vect()+lv.Vect(), E()+lv.E()); }
00206    TMBLorentzVector & operator += (const TMBLorentzVector &lv) {
00208       Double_t e=E(); Vect()+=lv.Vect(); SetE(e+lv.E()); return *this; }
00209 
00210    TMBLorentzVector   operator -  (const TMBLorentzVector &lv) const {
00212       return TMBLorentzVector(Vect()-lv.Vect(), E()-lv.E()); }
00213    TMBLorentzVector & operator -= (const TMBLorentzVector &lv) {
00215       Double_t e=E(); Vect()-=lv.Vect(); SetE(e-lv.E()); return *this; }
00216 
00217    TMBLorentzVector operator - () const {
00219       return TMBLorentzVector(-Vect(),-E()); }
00220 
00221    TMBLorentzVector operator * (Double_t a) const {
00223       return TMBLorentzVector(Vect()*a, E()*a); }
00224    TMBLorentzVector & operator *= (Double_t a) {
00226       Vect()*=a; fM*=a; return *this; }
00227 
00228    Bool_t operator == (const TMBLorentzVector &lv) const {
00231       return (fM==lv.fM && Vect()==lv.Vect()); }
00232    Bool_t operator != (const TMBLorentzVector &lv) const {
00235       return !(operator == (lv)); }
00236 
00239    Bool_t is_equal (const TMBLorentzVector &lv) const;
00240 
00241    Double_t Mag2() const { 
00242       return fM*fM; }
00243    Double_t M2() const { 
00244       return Mag2(); }
00245 
00246    Double_t Mag() const { 
00247       return fM;
00248    }
00249 
00250    Double_t Mt2() const { 
00251       return E()*E() - Z()*Z(); }
00252    
00253 
00254    Double_t Mt() const { 
00255       Double_t mm=Mt2(); 
00256       return mm < 0.0 ? -TMath::Sqrt(-mm) : TMath::Sqrt(mm); }
00257 
00258    Double_t Beta() const { 
00260       if (E()!=0) return Mag3() / E(); 
00261       else Warning("Beta()", "E()==0.!"); return 0.; }
00262    Double_t Gamma() const {
00264       Double_t b = Beta();
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 Thu Apr 3 04:14:24 2008 for CAF by doxygen 1.3.4