- Attention
TLorentzVector is a legacy class. It is slower and worse for serialization than the recommended superior alternative ROOT::Math::LorentzVector. ROOT provides specialisations of the ROOT::Math::LorentzVector template which offer superior runtime performance, i.e.:
- ROOT::Math::PtEtaPhiMVector based on pt (rho),eta,phi and M (t) coordinates in double precision
- ROOT::Math::PtEtaPhiEVector based on pt (rho),eta,phi and E (t) coordinates in double precision
- ROOT::Math::PxPyPzMVector based on px,py,pz and M (mass) coordinates in double precision
- ROOT::Math::PxPyPzEVector based on px,py,pz and E (energy) coordinates in double precision
- ROOT::Math::XYZTVector based on x,y,z,t coordinates (cartesian) in double precision (same as PxPyPzEVector)
- ROOT::Math::XYZTVectorF based on x,y,z,t coordinates (cartesian) in float precision (same as PxPyPzEVector but float)
More details can be found in the documentation of the Physics Vectors package.
Description
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).
Declaration
TLorentzVector has been implemented as a set a TVector3 and a Double_t variable. By default all components are initialized by zero.
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:
The components of TLorentzVector can also accessed by index:
You can use the Vect() member function to get the vector component of TLorentzVector:
winID h TVirtualViewer3D TVirtualGLPainter p
For setting components also two sets of member functions can be used:
v.SetX(1.);
or v.SetPx(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.SetPxPyPzE(px,py,pz,
e);
Vector components in non-cartesian coordinate systems
There are a couple of member functions to get and set the TVector3 part of the parameters in spherical coordinate systems:
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
or get information about the r-coordinate in cylindrical systems:
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:
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 therefore:
It mag2 is negative mag = -Sqrt(-mag*mag). The member functions are:
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 parameterised 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 arbitrary 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
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:
Rotations
There are four sets of functions to rotate the TVector3 component of a TLorentzVector:
rotation around axes
rotation around an arbitrary axis
v.Rotate(TMath::Pi()/4., v1); // rotation around v1
transformation from rotated frame
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
<div class="legacybox"><h2>Legacy Code</h2> TRotation is a legacy interface: there will be no bug fix...
Misc
Angle between two vectors
Light-cone components
Member functions Plus() and Minus() return the positive and negative light-cone components:
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.
A general Lorentz transformation see class TLorentzRotation can be used by the Transform() member function, the *= or operator of the TLorentzRotation class:
<div class="legacybox"><h2>Legacy Code</h2> TLorentzRotation is a legacy interface: there will be no ...
Definition at line 31 of file TLorentzVector.h.
|
| | TLorentzVector () |
| |
| | 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, Double_t y, Double_t z, Double_t t) |
| |
| | ~TLorentzVector () override |
| |
| Double_t | Angle (const TVector3 &v) const |
| |
| Double_t | Beta () const |
| |
| void | Boost (const TVector3 &) |
| |
| void | Boost (Double_t, Double_t, Double_t) |
| |
| TVector3 | BoostVector () const |
| |
| Double_t | CosTheta () const |
| |
| Double_t | DeltaPhi (const TLorentzVector &) const |
| |
| Double_t | DeltaR (const TLorentzVector &, Bool_t useRapidity=kFALSE) const |
| |
| Double_t | Dot (const TLorentzVector &) const |
| |
| Double_t | DrEtaPhi (const TLorentzVector &) const |
| |
| Double_t | DrRapidityPhi (const TLorentzVector &) const |
| |
| Double_t | E () const |
| |
| Double_t | Energy () const |
| |
| Double_t | Et () const |
| |
| Double_t | Et (const TVector3 &) const |
| |
| Double_t | Et2 () const |
| |
| Double_t | Et2 (const TVector3 &) const |
| |
| Double_t | Eta () const |
| |
| TVector2 | EtaPhiVector () |
| |
| Double_t | Gamma () const |
| |
| void | GetXYZT (Double_t *carray) const |
| |
| void | GetXYZT (Float_t *carray) const |
| |
| TClass * | IsA () const override |
| |
| Double_t | M () const |
| |
| Double_t | M2 () const |
| |
| Double_t | Mag () const |
| |
| Double_t | Mag2 () const |
| |
| Double_t | Minus () const |
| |
| Double_t | Mt () const |
| |
| Double_t | Mt2 () const |
| |
| | operator ROOT::Math::PxPyPzEVector () const |
| |
| Bool_t | operator!= (const TLorentzVector &) const |
| |
| Double_t & | operator() (int i) |
| |
| Double_t | operator() (int i) const |
| |
| Double_t | operator* (const TLorentzVector &) const |
| |
| TLorentzVector | operator* (Double_t a) const |
| |
| TLorentzVector & | operator*= (const TLorentzRotation &) |
| |
| TLorentzVector & | operator*= (const TRotation &) |
| |
| TLorentzVector & | operator*= (Double_t a) |
| |
| TLorentzVector | operator+ (const TLorentzVector &) const |
| |
| TLorentzVector & | operator+= (const TLorentzVector &) |
| |
| TLorentzVector | operator- () const |
| |
| TLorentzVector | operator- (const TLorentzVector &) const |
| |
| TLorentzVector & | operator-= (const TLorentzVector &) |
| |
| TLorentzVector & | operator= (const TLorentzVector &) |
| |
| Bool_t | operator== (const TLorentzVector &) const |
| |
| Double_t & | operator[] (int i) |
| |
| Double_t | operator[] (int i) const |
| |
| Double_t | P () const |
| |
| Double_t | Perp () const |
| |
| Double_t | Perp (const TVector3 &v) const |
| |
| Double_t | Perp2 () const |
| |
| Double_t | Perp2 (const TVector3 &v) const |
| |
| Double_t | Phi () const |
| |
| Double_t | Plus () const |
| |
| void | Print (Option_t *option="") const override |
| | Print the TLorentz vector components as (x,y,z,t) and (P,eta,phi,E) representations.
|
| |
| Double_t | PseudoRapidity () const |
| |
| Double_t | Pt () const |
| |
| Double_t | Pt (const TVector3 &v) const |
| |
| Double_t | Px () const |
| |
| Double_t | Py () const |
| |
| Double_t | Pz () const |
| |
| Double_t | Rapidity () const |
| |
| Double_t | Rho () const |
| |
| void | Rotate (Double_t, const TVector3 &) |
| |
| void | RotateUz (const TVector3 &newUzVector) |
| |
| void | RotateX (Double_t angle) |
| |
| void | RotateY (Double_t angle) |
| |
| void | RotateZ (Double_t angle) |
| |
| void | SetE (Double_t a) |
| |
| void | SetPerp (Double_t) |
| |
| void | SetPhi (Double_t phi) |
| |
| void | SetPtEtaPhiE (Double_t pt, Double_t eta, Double_t phi, Double_t e) |
| |
| void | SetPtEtaPhiM (Double_t pt, Double_t eta, Double_t phi, Double_t m) |
| |
| void | SetPx (Double_t a) |
| |
| void | SetPxPyPzE (Double_t px, Double_t py, Double_t pz, Double_t e) |
| |
| void | SetPy (Double_t a) |
| |
| void | SetPz (Double_t a) |
| |
| void | SetRho (Double_t rho) |
| |
| void | SetT (Double_t a) |
| |
| void | SetTheta (Double_t theta) |
| |
| void | SetVect (const TVector3 &vect3) |
| |
| void | SetVectM (const TVector3 &spatial, Double_t mass) |
| |
| void | SetVectMag (const TVector3 &spatial, Double_t magnitude) |
| |
| void | SetX (Double_t a) |
| |
| void | SetXYZM (Double_t x, Double_t y, Double_t z, Double_t m) |
| |
| void | SetXYZT (Double_t x, Double_t y, Double_t z, Double_t t) |
| |
| void | SetY (Double_t a) |
| |
| void | SetZ (Double_t a) |
| |
| void | Streamer (TBuffer &) override |
| | Stream an object of class TObject.
|
| |
| void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
| |
| Double_t | T () const |
| |
| Double_t | Theta () const |
| |
| TLorentzVector & | Transform (const TLorentzRotation &) |
| |
| TLorentzVector & | Transform (const TRotation &) |
| |
| TVector3 | Vect () const |
| |
| Double_t | X () const |
| |
| Double_t | Y () const |
| |
| Double_t | Z () const |
| |
| | TObject () |
| | TObject constructor.
|
| |
| | TObject (const TObject &object) |
| | TObject copy ctor.
|
| |
| virtual | ~TObject () |
| | TObject destructor.
|
| |
| void | AbstractMethod (const char *method) const |
| | Use this method to implement an "abstract" method that you don't want to leave purely abstract.
|
| |
| virtual void | AppendPad (Option_t *option="") |
| | Append graphics object to current pad.
|
| |
| virtual void | Browse (TBrowser *b) |
| | Browse object. May be overridden for another default action.
|
| |
| ULong_t | CheckedHash () |
| | Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
|
| |
| virtual const char * | ClassName () const |
| | Returns name of class to which the object belongs.
|
| |
| virtual void | Clear (Option_t *="") |
| |
| virtual TObject * | Clone (const char *newname="") const |
| | Make a clone of an object using the Streamer facility.
|
| |
| virtual Int_t | Compare (const TObject *obj) const |
| | Compare abstract method.
|
| |
| virtual void | Copy (TObject &object) const |
| | Copy this to obj.
|
| |
| virtual void | Delete (Option_t *option="") |
| | Delete this object.
|
| |
| virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
| | Computes distance from point (px,py) to the object.
|
| |
| virtual void | Draw (Option_t *option="") |
| | Default Draw method for all objects.
|
| |
| virtual void | DrawClass () const |
| | Draw class inheritance tree of the class to which this object belongs.
|
| |
| virtual TObject * | DrawClone (Option_t *option="") const |
| | Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
|
| |
| virtual void | Dump () const |
| | Dump contents of object on stdout.
|
| |
| virtual void | Error (const char *method, const char *msgfmt,...) const |
| | Issue error message.
|
| |
| virtual void | Execute (const char *method, const char *params, Int_t *error=nullptr) |
| | Execute method on this object with the given parameter string, e.g.
|
| |
| virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr) |
| | Execute method on this object with parameters stored in the TObjArray.
|
| |
| virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
| | Execute action corresponding to an event at (px,py).
|
| |
| virtual void | Fatal (const char *method, const char *msgfmt,...) const |
| | Issue fatal error message.
|
| |
| virtual TObject * | FindObject (const char *name) const |
| | Must be redefined in derived classes.
|
| |
| virtual TObject * | FindObject (const TObject *obj) const |
| | Must be redefined in derived classes.
|
| |
| virtual Option_t * | GetDrawOption () const |
| | Get option used by the graphics system to draw this object.
|
| |
| virtual const char * | GetIconName () const |
| | Returns mime type name of object.
|
| |
| virtual const char * | GetName () const |
| | Returns name of object.
|
| |
| virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
| | Returns string containing info about the object at position (px,py).
|
| |
| virtual Option_t * | GetOption () const |
| |
| virtual const char * | GetTitle () const |
| | Returns title of object.
|
| |
| virtual UInt_t | GetUniqueID () const |
| | Return the unique object id.
|
| |
| virtual Bool_t | HandleTimer (TTimer *timer) |
| | Execute action in response of a timer timing out.
|
| |
| virtual ULong_t | Hash () const |
| | Return hash value for this object.
|
| |
| Bool_t | HasInconsistentHash () const |
| | Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
|
| |
| virtual void | Info (const char *method, const char *msgfmt,...) const |
| | Issue info message.
|
| |
| virtual Bool_t | InheritsFrom (const char *classname) const |
| | Returns kTRUE if object inherits from class "classname".
|
| |
| virtual Bool_t | InheritsFrom (const TClass *cl) const |
| | Returns kTRUE if object inherits from TClass cl.
|
| |
| virtual void | Inspect () const |
| | Dump contents of this object in a graphics canvas.
|
| |
| void | InvertBit (UInt_t f) |
| |
| Bool_t | IsDestructed () const |
| | IsDestructed.
|
| |
| virtual Bool_t | IsEqual (const TObject *obj) const |
| | Default equal comparison (objects are equal if they have the same address in memory).
|
| |
| virtual Bool_t | IsFolder () const |
| | Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
|
| |
| R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
| |
| virtual Bool_t | IsSortable () const |
| |
| R__ALWAYS_INLINE Bool_t | IsZombie () const |
| |
| virtual void | ls (Option_t *option="") const |
| | The ls function lists the contents of a class on stdout.
|
| |
| void | MayNotUse (const char *method) const |
| | Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
|
| |
| virtual Bool_t | Notify () |
| | This method must be overridden to handle object notification (the base implementation is no-op).
|
| |
| void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
| | Use this method to declare a method obsolete.
|
| |
| void | operator delete (void *, size_t) |
| | Operator delete for sized deallocation.
|
| |
| void | operator delete (void *ptr) |
| | Operator delete.
|
| |
| void | operator delete (void *ptr, void *vp) |
| | Only called by placement new when throwing an exception.
|
| |
| void | operator delete[] (void *, size_t) |
| | Operator delete [] for sized deallocation.
|
| |
| void | operator delete[] (void *ptr) |
| | Operator delete [].
|
| |
| void | operator delete[] (void *ptr, void *vp) |
| | Only called by placement new[] when throwing an exception.
|
| |
| void * | operator new (size_t sz) |
| |
| void * | operator new (size_t sz, void *vp) |
| |
| void * | operator new[] (size_t sz) |
| |
| void * | operator new[] (size_t sz, void *vp) |
| |
| TObject & | operator= (const TObject &rhs) |
| | TObject assignment operator.
|
| |
| virtual void | Paint (Option_t *option="") |
| | This method must be overridden if a class wants to paint itself.
|
| |
| virtual void | Pop () |
| | Pop on object drawn in a pad to the top of the display list.
|
| |
| virtual Int_t | Read (const char *name) |
| | Read contents of object with specified name from the current directory.
|
| |
| virtual void | RecursiveRemove (TObject *obj) |
| | Recursively remove this object from a list.
|
| |
| void | ResetBit (UInt_t f) |
| |
| virtual void | SaveAs (const char *filename="", Option_t *option="") const |
| | Save this object in the file specified by filename.
|
| |
| virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
| | Save a primitive as a C++ statement(s) on output stream "out".
|
| |
| void | SetBit (UInt_t f) |
| |
| void | SetBit (UInt_t f, Bool_t set) |
| | Set or unset the user status bits as specified in f.
|
| |
| virtual void | SetDrawOption (Option_t *option="") |
| | Set drawing option for object.
|
| |
| virtual void | SetUniqueID (UInt_t uid) |
| | Set the unique object id.
|
| |
| void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
| |
| virtual void | SysError (const char *method, const char *msgfmt,...) const |
| | Issue system error message.
|
| |
| R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
| |
| Int_t | TestBits (UInt_t f) const |
| |
| virtual void | UseCurrentStyle () |
| | Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
|
| |
| virtual void | Warning (const char *method, const char *msgfmt,...) const |
| | Issue warning message.
|
| |
| virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) |
| | Write this object to the current directory.
|
| |
| virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const |
| | Write this object to the current directory.
|
| |