ROOT logo
ROOT » MATH » PHYSICS » TLorentzVector

class TLorentzVector: public TObject

The Physics Vector package 
-*                    ==========================                       
-* The Physics Vector package consists of five classes:                
-*   - TVector2                                                        
-*   - TVector3                                                        
-*   - TRotation                                                       
-*   - TLorentzVector                                                  
-*   - TLorentzRotation                                                
-* It is a combination of CLHEPs Vector package written by             
-* Leif Lonnblad, Andreas Nilsson and Evgueni Tcherniaev               
-* and a ROOT package written by Pasha Murat.                          
-* for CLHEP see:             
-* Adaption to ROOT by Peter Malzacher                                 


TLorentzVector is a general four-vector class, which can be used either for the description of position and time (x,y,z,t) or momentum and energy (px,py,pz,E).


TLorentzVector has been implemented as a set a TVector3 and a Double_t variable. By default all components are initialized by zero.

  TLorentzVector v1;      // initialized by (0., 0., 0., 0.)
  TLorentzVector v2(1., 1., 1., 1.);
  TLorentzVector v3(v1);
  TLorentzVector v4(TVector3(1., 2., 3.),4.);

For backward compatibility there are two constructors from an Double_t and Float_t  C array.

Access to the components

There are two sets of access functions to the components of a LorentzVector: X(), Y(), Z(), T() and Px(), Py(), Pz() and E(). Both sets return the same values but the first set is more relevant for use where TLorentzVector describes a combination of position and time and the second set is more relevant where TLorentzVector describes momentum and energy:

  Double_t xx =v.X();
  Double_t tt = v.T();

  Double_t px = v.Px();
  Double_t ee = v.E();

The components of TLorentzVector can also accessed by index:

  xx = v(0);       or     xx = v[0];
  yy = v(1);              yy = v[1];
  zz = v(2);              zz = v[2];
  tt = v(3);              tt = v[3];

You can use the Vect() member function to get the vector component of TLorentzVector:

  TVector3 p = v.Vect();

For setting components also two sets of member functions can be used: SetX(),.., SetPx(),..:
  v.SetX(1.);        or    v.SetPx(1.);
  ...                               ...
  v.SetT(1.);              v.SetE(1.);

To set more the one component by one call you can use the SetVect() function for the TVector3 part or SetXYZT(), SetPxPyPzE(). For convenience there is also a SetXYZM():

  v.SetXYZM(x,y,z,m);   //   ->  v=(x,y,z,e=Sqrt(x*x+y*y+z*z+m*m))

Vector components in noncartesian coordinate systems

There are a couple of memberfunctions to get and set the TVector3 part of the parameters in
sherical coordinate systems:

  Double_t m, theta, cost, phi, pp, pp2, ppv2, pp2v2;
  m = v.Rho();
  t = v.Theta();
  cost = v.CosTheta();
  phi = v.Phi();


or get infoormation about the r-coordinate in cylindrical systems:

  Double_t pp, pp2, ppv2, pp2v2;
  pp = v.Perp();         // get transvers component
  pp2 = v.Perp2();       // get transverse component squared
  ppv2 = v.Perp(v1);      // get transvers component with
                         // respect to another vector
  pp2v2 = v.Perp(v1);

for convenience there are two more set functions SetPtEtaPhiE(pt,eta,phi,e); and SetPtEtaPhiM(pt,eta,phi,m);

Arithmetic and comparison operators

The TLorentzVector class provides operators to add, subtract or compare four-vectors:

  v3 = -v1;
  v1 = v2+v3;
  v1+= v3;
  v1 = v2 + v3;
  v1-= v3;

  if (v1 == v2) {...}
  if(v1 != v3) {...}

Magnitude/Invariant mass, beta, gamma, scalar product

The scalar product of two four-vectors is calculated with the (-,-,-,+) metric,
   i.e.   s = v1*v2 = t1*t2-x1*x2-y1*y2-z1*z2
The magnitude squared mag2 of a four-vector is therfore:
          mag2 = v*v = t*t-x*x-y*y-z*z
It mag2 is negative mag = -Sqrt(-mag*mag). The member functions are:

  Double_t s, s2;
  s  = v1.Dot(v2);     // scalar product
  s  = v1*v2;         // scalar product
  s2 = v.Mag2();   or    s2 = v.M2();
  s  = v.Mag();          s  = v.M();

Since in case of momentum and energy the magnitude has the meaning of invariant mass TLorentzVector provides the more meaningful aliases M2() and M();

The member functions Beta() and Gamma() returns beta and gamma = 1/Sqrt(1-beta*beta).

Lorentz boost

A boost in a general direction can be parameterized with three parameters which can be taken as the components of a three vector b = (bx,by,bz). With
  x = (x,y,z) and gamma = 1/Sqrt(1-beta*beta) (beta being the module of vector b), an arbitary active Lorentz boost transformation (from the rod frame to the original frame) can be written as:
          x = x' + (gamma-1)/(beta*beta) * (b*x') * b + gamma * t' * b
          t = gamma (t'+ b*x').

The member function Boost() performs a boost transformation from the rod frame to the original frame. BoostVector() returns a TVector3 of the spatial components divided by the time component:

  TVector3 b;
  b = v.BoostVector();   // b=(x/t,y/t,z/t)


There are four sets of functions to rotate the TVector3 component of a TLorentzVector:
rotation around axes
rotation around an arbitary axis
  v.Rotate(TMath::Pi()/4., v1); // rotation around v1
transformation from rotated frame
  v.RotateUz(direction); //  direction must be a unit TVector3
by TRotation (see TRotation)
  TRotation r;
  v.Transform(r);    or     v *= r; // Attention v=M*v


Angle between two vectors
  Double_t a = v1.Angle(v2.Vect());  // get angle between v1 and v2
Light-cone components
Member functions Plus() and Minus() return the positive and negative light-cone components:

  Double_t pcone = v.Plus();
  Double_t mcone = v.Minus();

CAVEAT: The values returned are T{+,-}Z. It is known that some authors find it easier to define these components as (T{+,-}Z)/sqrt(2). Thus check what definition is used in the physics you're working in and adapt your code accordingly.

Transformation by TLorentzRotation
A general Lorentz transformation see class TLorentzRotation can be used by the Transform() member function, the *= or * operator of the TLorentzRotation class:

  TLorentzRotation l;
  v = l*v;     or     v *= l;  // Attention v = l*v

Function Members (Methods)

TLorentzVector(const Double_t* carray)
TLorentzVector(const Float_t* carray)
TLorentzVector(const TLorentzVector& lorentzvector)
TLorentzVector(const TVector3& vector3, Double_t t)
TLorentzVector(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0, Double_t t = 0.0)
voidTObject::AbstractMethod(const char* method) const
Double_tAngle(const TVector3& v) const
virtual voidTObject::AppendPad(Option_t* option = "")
Double_tBeta() const
voidBoost(const TVector3& b)
voidBoost(Double_t, Double_t, Double_t)
TVector3BoostVector() const
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
static TClass*TObject::Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
Double_tCosTheta() const
virtual voidTObject::Delete(Option_t* option = "")MENU
Double_tDeltaPhi(const TLorentzVector& v) const
Double_tDeltaR(const TLorentzVector& v) const
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
Double_tDot(const TLorentzVector& q) const
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
Double_tDrEtaPhi(const TLorentzVector& v) const
virtual voidTObject::Dump() constMENU
Double_tE() const
Double_tEnergy() const
virtual voidTObject::Error(const char* method, const char* msgfmt) const
Double_tEt() const
Double_tEt(const TVector3& v) const
Double_tEt2() const
Double_tEt2(const TVector3& v) const
Double_tEta() const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
Double_tGamma() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
voidGetXYZT(Double_t* carray) const
voidGetXYZT(Float_t* carray) const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual TClass*TObject::IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
Double_tM() const
Double_tM2() const
Double_tMag() const
Double_tMag2() const
voidTObject::MayNotUse(const char* method) const
Double_tMinus() const
Double_tMt() const
Double_tMt2() const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
Bool_toperator!=(const TLorentzVector& q) const
Double_toperator()(int i) const
Double_t&operator()(int i)
TLorentzVectoroperator*(Double_t a) const
Double_toperator*(const TLorentzVector& q) const
TLorentzVector&operator*=(Double_t a)
TLorentzVector&operator*=(const TRotation& m)
TLorentzVector&operator*=(const TLorentzRotation&)
TLorentzVectoroperator+(const TLorentzVector& q) const
TLorentzVector&operator+=(const TLorentzVector& q)
TLorentzVectoroperator-() const
TLorentzVectoroperator-(const TLorentzVector& q) const
TLorentzVector&operator-=(const TLorentzVector& q)
TLorentzVector&operator=(const TLorentzVector& q)
TObject&TObject::operator=(const TObject& rhs)
Bool_toperator==(const TLorentzVector& q) const
Double_toperator[](int i) const
Double_t&operator[](int i)
Double_tP() const
virtual voidTObject::Paint(Option_t* option = "")
Double_tPerp() const
Double_tPerp(const TVector3& v) const
Double_tPerp2() const
Double_tPerp2(const TVector3& v) const
Double_tPhi() const
Double_tPlus() const
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
Double_tPseudoRapidity() const
Double_tPt() const
Double_tPt(const TVector3& v) const
Double_tPx() const
Double_tPy() const
Double_tPz() const
Double_tRapidity() const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
Double_tRho() const
voidRotate(Double_t a, const TVector3& v)
voidRotateUz(TVector3& newUzVector)
voidRotateX(Double_t angle)
voidRotateY(Double_t angle)
voidRotateZ(Double_t angle)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetE(Double_t a)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetPerp(Double_t r)
voidSetPhi(Double_t phi)
voidSetPtEtaPhiE(Double_t pt, Double_t eta, Double_t phi, Double_t e)
voidSetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m)
voidSetPx(Double_t a)
voidSetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e)
voidSetPy(Double_t a)
voidSetPz(Double_t a)
voidSetRho(Double_t rho)
voidSetT(Double_t a)
voidSetTheta(Double_t th)
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetVect(const TVector3& p)
voidSetVectM(const TVector3& spatial, Double_t mass)
voidSetVectMag(const TVector3& spatial, Double_t magnitude)
voidSetX(Double_t a)
voidSetXYZM(Double_t x, Double_t y, Double_t z, Double_t m)
voidSetXYZT(Double_t x, Double_t y, Double_t z, Double_t t)
voidSetY(Double_t a)
voidSetZ(Double_t a)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidTObject::ShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
virtual voidTObject::Streamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
voidTObject::StreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Double_tT() const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
Double_tTheta() const
TLorentzVector&Transform(const TRotation& m)
TLorentzVector&Transform(const TLorentzRotation&)
virtual voidTObject::UseCurrentStyle()
TVector3Vect() const
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
Double_tX() const
Double_tY() const
Double_tZ() const
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const

Data Members

enum { kX
enum TObject::EStatusBits { kCanDelete
enum TObject::[unnamed] { kIsOnHeap
Double_tfEtime or energy of (x,y,z,t) or (px,py,pz,e)
TVector3fP3 vector component

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TLorentzVector(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0, Double_t t = 0.0)
TLorentzVector(const Double_t * x0)
TLorentzVector(const Float_t * x0)
TLorentzVector(const TVector3& vector3, Double_t t)
TLorentzVector(const TLorentzVector & p)
void Boost(Double_t , Double_t , Double_t )
Boost this Lorentz vector
Double_t Rapidity() const
return rapidity
TLorentzVector & Transform(const TLorentzRotation & m)
Transform this Lorentzvector
void Streamer(TBuffer& b)
 Stream an object of class TLorentzVector.
Double_t X() const
{ return fP.X(); }
Double_t Y() const
{ return fP.Y(); }
Double_t Z() const
{ return fP.Z(); }
Double_t T() const
{ return fE; }
void SetX(Double_t a)
{ fP.SetX(a); }
void SetY(Double_t a)
{ fP.SetY(a); }
void SetZ(Double_t a)
{ fP.SetZ(a); }
void SetT(Double_t a)
{ fE = a; }
Double_t Px() const
{ return X(); }
Double_t Py() const
{ return Y(); }
Double_t Pz() const
{ return Z(); }
Double_t P() const
{ return fP.Mag(); }
Double_t E() const
{ return T(); }
Double_t Energy() const
{ return T(); }
void SetPx(Double_t a)
{ SetX(a); }
void SetPy(Double_t a)
{ SetY(a); }
void SetPz(Double_t a)
{ SetZ(a); }
void SetE(Double_t a)
{ SetT(a); }
TVector3 Vect() const
{ return fP; }
void SetVect(const TVector3& p)
{ fP = p; }
Double_t Phi() const
Double_t Theta() const
Double_t CosTheta() const
Double_t Rho() const
void SetTheta(Double_t th)
void SetPhi(Double_t phi)
void SetRho(Double_t rho)
void SetXYZT(Double_t x, Double_t y, Double_t z, Double_t t)
void SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e)
void SetXYZM(Double_t x, Double_t y, Double_t z, Double_t m)
void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m)
void SetPtEtaPhiE(Double_t pt, Double_t eta, Double_t phi, Double_t e)
void GetXYZT(Double_t *carray)
void GetXYZT(Float_t *carray)
Double_t Perp2() const
{ return fP.Perp2(); }
Double_t Perp() const
{ return fP.Perp(); }
Double_t Pt() const
{ return Perp(); }
void SetPerp(Double_t r)
Double_t Perp2(const TVector3& v) const
Double_t Perp(const TVector3& v) const
Double_t Pt(const TVector3& v) const
Double_t Et2() const
Double_t Et() const
Double_t Et2(const TVector3& v) const
Double_t Et(const TVector3& v) const
Double_t DeltaPhi(const TLorentzVector& v) const
Double_t Eta() const
Double_t DeltaR(const TLorentzVector& v) const
Double_t DrEtaPhi(const TLorentzVector& v) const
TVector2 EtaPhiVector()
Double_t Angle(const TVector3& v) const
Double_t Mag2() const
Double_t Mag() const
Double_t M2() const
{ return Mag2(); }
Double_t M() const
{ return Mag(); }
Double_t Mt2() const
Double_t Mt() const
Double_t Beta() const
Double_t Gamma() const
void SetVectMag(const TVector3& spatial, Double_t magnitude)
void SetVectM(const TVector3& spatial, Double_t mass)
Double_t Dot(const TLorentzVector& q) const
Double_t Plus() const
Double_t Minus() const
TVector3 BoostVector() const
void Boost(const TVector3& b)
Double_t PseudoRapidity() const
void RotateX(Double_t angle)
void RotateY(Double_t angle)
void RotateZ(Double_t angle)
void RotateUz(TVector3& newUzVector)
void Rotate(Double_t a, const TVector3& v)
TLorentzVector & Transform(const TRotation & m)