KAHIBARO Bookshelves
Discord Login Register

21.1. Four-Vectors

TLorentzVector

In particle and nuclear physics, many quantities are most naturally described with four-vectors. ROOT provides the class TLorentzVector to represent a relativistic four-momentum, and this class is used extensively in real analyses.

Conceptually, a four-vector for a particle is written as
$$
p^\mu = (E, p_x, p_y, p_z)
$$
where $E$ is the energy and $(p_x, p_y, p_z)$ are the components of the three-momentum. In ROOT, TLorentzVector stores these components and provides many convenience methods to compute derived kinematic quantities.

A TLorentzVector object can be created on the stack like any other C++ object:

cpp
TLorentzVector p;

At this point, its components are zero. You normally set its value using one of the setter methods. The most common are SetPxPyPzE and SetPtEtaPhiM:

cpp
TLorentzVector p1;
p1.SetPxPyPzE(0.3, 0.4, 1.2, 2.0);   // px, py, pz in GeV, E in GeV
TLorentzVector p2;
p2.SetPtEtaPhiM(20.0, 0.5, 1.0, 0.139);  // pt, eta, phi, mass

The choice of method depends on how your data are stored. Collider experiments often provide transverse momentum $p_T$, pseudorapidity $\eta$, azimuthal angle $\phi$, and mass, so SetPtEtaPhiM is especially useful.

You can also construct and initialize a four-vector in a single line:

cpp
TLorentzVector p3(0.1, 0.2, 0.3, 0.5);  // px, py, pz, E

By default, this constructor expects the Cartesian components $(p_x, p_y, p_z)$ and the energy $E$.

One of the main advantages of TLorentzVector is that it overloads arithmetic operators. You can add four-vectors to obtain the combined four-momentum of a system:

cpp
TLorentzVector p_total = p1 + p2;

This expression corresponds to event-by-event combination of two particles into a composite system, for example two photons forming a $\pi^0$, or two leptons forming a $Z$ boson candidate.

Subtraction is also defined and sometimes used to form differences of four-momenta, though addition is more common in analyses that reconstruct invariant masses and similar quantities.

The class provides many member functions to access its components and derived kinematic variables. The basic getters are

cpp
double px  = p1.Px();
double py  = p1.Py();
double pz  = p1.Pz();
double e   = p1.E();
double m   = p1.M();       // invariant mass
double pt  = p1.Pt();
double p   = p1.P();       // magnitude of 3-momentum
double eta = p1.Eta();
double phi = p1.Phi();

The invariant mass is computed internally via
$$
m^2 = E^2 - \vec{p}^{\,2} = E^2 - (p_x^2 + p_y^2 + p_z^2)
$$
using the convention $c = 1$ and metric signature $(+,-,-,-)$.

Key invariant quantity:
For a TLorentzVector $p$, the invariant mass is defined by
$$m^2 = E^2 - \vec{p}^{\,2}$$
This quantity is the same in all inertial reference frames.

ROOT also includes methods for more advanced operations, such as Lorentz boosts. For example, if you have a boost vector $\vec{\beta}$, you can transform p into a different frame:

cpp
TVector3 beta_vec(0.1, 0.0, 0.0);  // boost along x
p.Boost(-beta_vec);                // perform a Lorentz boost

Boosts are typically used in detailed analyses that transform to the center-of-mass frame of a system or to the rest frame of a particle. The general concept of reference frames and boosts is discussed elsewhere, so here it is enough to recognize that TLorentzVector natively supports these operations.

In many event analyses, you work with collections of particles. For example, you might loop over two muon candidates and combine them:

cpp
TLorentzVector mu1, mu2;
// ... set mu1 and mu2 from event data ...
TLorentzVector dimuon = mu1 + mu2;
double m_dimuon = dimuon.M();

This pattern, adding four-vectors and using the mass or other derived quantities, appears very frequently when reconstructing decays or resonances from their decay products.

TLorentzVector also integrates well with ROOT histograms and TTrees. You can store components or derived quantities like Pt() and M() as branches, fill histograms of these values, and use them for selection cuts. The object itself is a regular ROOT class, so it can be written to and read from ROOT files where needed.

Overall, TLorentzVector provides a compact, convenient, and physics-friendly representation of four-momenta, with built-in functionality that supports most of the standard kinematic calculations in particle and nuclear physics analyses.

Energy and momentum

In relativistic kinematics, energy and momentum are tightly connected. For a particle of mass $m$, three-momentum $\vec{p}$, and energy $E$, the fundamental relation is
$$
E^2 = \vec{p}^{\,2} + m^2,
$$
with $c = 1$ units. This relation is built into TLorentzVector and underlies its invariant mass calculations.

In ROOT, the spatial momentum magnitude $p$ and the energy $E$ are related through this formula. If you set the four-vector using SetPxPyPzE, you must ensure that the values are physically consistent if you want a real mass. If $E^2 < \vec{p}^{\,2}$, the mass becomes imaginary and the kinematics no longer represent a physical particle.

TLorentzVector allows you to start from different sets of input quantities. The two most common are:

  1. Energy and Cartesian momentum components:
    $$
    (E, p_x, p_y, p_z)
    $$
    You pass these to SetPxPyPzE(px, py, pz, E) and ROOT computes all derived quantities for you.
  2. Transverse momentum, pseudorapidity, azimuthal angle, and mass:
    $$
    (p_T, \eta, \phi, m).
    $$
    You pass these to SetPtEtaPhiM(pt, eta, phi, m). Internally, TLorentzVector converts them to $p_x, p_y, p_z, E$ using the standard relations between these variables.

For many collider analyses, information is naturally provided in terms of $p_T, \eta, \phi$ and either a known particle mass or an approximation. In that situation, you can view energy as a derived quantity:
$$
E = \sqrt{\vec{p}^{\,2} + m^2}, \quad \vec{p}^{\,2} = p_T^2 + p_z^2.
$$
ROOT handles this automatically once the appropriate four-vector is set.

In code, you can inspect how energy and momentum relate for a given particle:

cpp
TLorentzVector p;
p.SetPtEtaPhiM(50.0, 0.3, 2.5, 0.105); // pt in GeV, m in GeV
double e  = p.E();
double p3 = p.P();
double m  = p.M();

If you check numerically, the values satisfy:
$$
E^2 \approx p^2 + m^2.
$$

Relativistic energy momentum relation:
For any TLorentzVector representing a physical particle,
$$E^2 = \vec{p}^{\,2} + m^2,$$
with $c = 1$. This relation connects energy, momentum, and mass and is used to compute the invariant mass via
$$m^2 = E^2 - \vec{p}^{\,2}.$$

When you combine particles into a composite system, energy and momentum also add as four-vectors. Suppose you have two particles with four-momenta $p_1^\mu$ and $p_2^\mu$. The total four-momentum is
$$
P^\mu = p_1^\mu + p_2^\mu,
$$
so its energy and three-momentum are
$$
E_{\text{tot}} = E_1 + E_2,
\quad
\vec{P}_{\text{tot}} = \vec{p}_1 + \vec{p}_2.
$$
In ROOT:

cpp
TLorentzVector p1, p2;
// ... set both vectors ...
TLorentzVector Ptot = p1 + p2;
double E_tot  = Ptot.E();
double P_tot  = Ptot.P();
double M_tot  = Ptot.M();  // invariant mass of the system

This is the basis for reconstructing resonances. For example, if p1 and p2 are two photon four-vectors from a $\pi^0$ decay, Ptot.M() approximates the $\pi^0$ mass.

In fixed-target or collider setups, you sometimes work in a specific reference frame where the total spatial momentum is zero. In that center-of-mass frame, the total energy is particularly simple:
$$
E_{\text{cm}} = \sqrt{s},
$$
where $s = P_{\text{tot}}^2$ is the invariant mass squared of the system. TLorentzVector lets you inspect this through:

cpp
double s = Ptot.M2();     // invariant mass squared
double sqrt_s = Ptot.M(); // invariant mass

Energy and momentum conservation then become conservation of the total four-vector in an interaction or decay.

Although TLorentzVector does not enforce conservation laws by itself, it provides the tools to check them. In an event, you can sum visible final state four-momenta, compare with the initial state, and study missing momentum or energy as needed in more advanced analyses.

From a practical standpoint, working with energy and momentum through TLorentzVector keeps the relativistic relations consistent and reduces the need to manually recompute kinematic quantities. You specify whichever set of variables your experiment provides, and then rely on ROOT to give you energies, momenta, and invariant masses in a uniform and convenient way.

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!

Where to Move

Move chapter:

  • ☰ 1. Introduction to ROOT
    • ☰ 1.1. What Is ROOT?
      • ☰ 1.2. Installing ROOT
        • ☰ 1.3. Starting ROOT
          • ☰ 1.4. Your First ROOT Session
          • ☰ 2. C++ Basics for ROOT
            • ☰ 2.1. Why ROOT Uses C++
              • ☰ 2.2. Variables and Data Types
                • ☰ 2.3. Operators
                  • ☰ 2.4. Conditional Statements
                    • ☰ 2.5. Loops
                      • ☰ 2.6. Functions
                        • ☰ 2.7. Arrays and Vectors
                        • ☰ 3. ROOT Macros
                          • ☰ 3.1. What Is a ROOT Macro?
                            • ☰ 3.2. Running ROOT Macros
                              • ☰ 3.3. Functions Inside ROOT Macros
                                • ☰ 3.4. Compiling ROOT Macros
                                  • ☰ 3.5. Organizing a ROOT Project
                                  • ☰ 4. ROOT Objects and the ROOT Object Model
                                    • ☰ 4.1. Introduction to ROOT Classes
                                      • ☰ 4.2. Object Names and Titles
                                        • ☰ 4.3. ROOT Collections
                                          • ☰ 4.4. Inspecting ROOT Objects
                                          • ☰ 5. Histograms
                                            • ☰ 5.1. Introduction to Histograms
                                              • ☰ 5.2. Creating a 1D Histogram
                                                • ☰ 5.3. Filling Histograms
                                                  • ☰ 5.4. Drawing Histograms
                                                    • ☰ 5.5. Histogram Properties
                                                      • ☰ 5.6. Accessing Histogram Bins
                                                        • ☰ 5.7. Histogram Errors
                                                          • ☰ 5.8. Normalizing Histograms
                                                            • ☰ 5.9. Combining Histograms
                                                            • ☰ 6. Two-Dimensional Histograms
                                                              • ☰ 6.1. Creating 2D Histograms
                                                                • ☰ 6.2. Filling 2D Histograms
                                                                  • ☰ 6.3. Drawing 2D Histograms
                                                                    • ☰ 6.4. Projections
                                                                      • ☰ 6.5. Profiles
                                                                      • ☰ 7. Graphs
                                                                        • ☰ 7.1. Introduction to TGraph
                                                                          • ☰ 7.2. Creating a TGraph
                                                                            • ☰ 7.3. Graph Styling
                                                                              • ☰ 7.4. TGraphErrors
                                                                                • ☰ 7.5. TGraphAsymmErrors
                                                                                  • ☰ 7.6. MultiGraph
                                                                                  • ☰ 8. Canvases and Plotting
                                                                                    • ☰ 8.1. TCanvas
                                                                                      • ☰ 8.2. Dividing a Canvas
                                                                                        • ☰ 8.3. Drawing Multiple Objects
                                                                                          • ☰ 8.4. Legends
                                                                                            • ☰ 8.5. Text and Annotations
                                                                                              • ☰ 8.6. Logarithmic Axes
                                                                                                • ☰ 8.7. Saving Plots
                                                                                                • ☰ 9. Styling ROOT Plots
                                                                                                  • ☰ 9.1. ROOT Plot Styles
                                                                                                    • ☰ 9.2. Axis Configuration
                                                                                                      • ☰ 9.3. Line Styles
                                                                                                        • ☰ 9.4. Marker Styles
                                                                                                          • ☰ 9.5. Publication-Quality Figures
                                                                                                          • ☰ 10. Mathematical Functions
                                                                                                            • ☰ 10.1. Introduction to TF1
                                                                                                              • ☰ 10.2. Built-in Functions
                                                                                                                • ☰ 10.3. Custom Functions
                                                                                                                  • ☰ 10.4. Evaluating Functions
                                                                                                                    • ☰ 10.5. Function Integrals
                                                                                                                    • ☰ 11. Curve Fitting
                                                                                                                      • ☰ 11.1. Introduction to Fitting
                                                                                                                        • ☰ 11.2. Gaussian Fits
                                                                                                                          • ☰ 11.3. Polynomial Fits
                                                                                                                            • ☰ 11.4. Custom Fit Functions
                                                                                                                              • ☰ 11.5. Fit Parameters
                                                                                                                                • ☰ 11.6. Goodness of Fit
                                                                                                                                  • ☰ 11.7. Fit Residuals
                                                                                                                                    • ☰ 11.8. Fitting Graphs
                                                                                                                                    • ☰ 12. ROOT Files
                                                                                                                                      • ☰ 12.1. Introduction to ROOT Files
                                                                                                                                        • ☰ 12.2. Creating ROOT Files
                                                                                                                                          • ☰ 12.3. Writing Objects
                                                                                                                                            • ☰ 12.4. Reading ROOT Files
                                                                                                                                              • ☰ 12.5. Exploring ROOT Files
                                                                                                                                                • ☰ 12.6. Directories Inside ROOT Files
                                                                                                                                                • ☰ 13. TTrees
                                                                                                                                                  • ☰ 13.1. Introduction to TTrees
                                                                                                                                                    • ☰ 13.2. Creating a TTree
                                                                                                                                                      • ☰ 13.3. Filling a TTree
                                                                                                                                                        • ☰ 13.4. Writing a TTree to a File
                                                                                                                                                          • ☰ 13.5. Reading a TTree
                                                                                                                                                            • ☰ 13.6. Inspecting TTrees
                                                                                                                                                              • ☰ 13.7. Drawing Data from TTrees
                                                                                                                                                                • ☰ 13.8. Applying Selection Cuts
                                                                                                                                                                  • ☰ 13.9. Branch Addresses
                                                                                                                                                                  • ☰ 14. Event-Based Data Analysis
                                                                                                                                                                    • ☰ 14.1. Understanding Event Data
                                                                                                                                                                      • ☰ 14.2. Event Loops
                                                                                                                                                                        • ☰ 14.3. Event Selection
                                                                                                                                                                          • ☰ 14.4. Derived Quantities
                                                                                                                                                                            • ☰ 14.5. Analysis Workflow
                                                                                                                                                                            • ☰ 15. Working with Real Experimental Data
                                                                                                                                                                              • ☰ 15.1. Importing Text Data
                                                                                                                                                                                • ☰ 15.2. Converting Data to ROOT
                                                                                                                                                                                  • ☰ 15.3. Data Cleaning
                                                                                                                                                                                    • ☰ 15.4. Data Calibration
                                                                                                                                                                                      • ☰ 15.5. Signal and Background
                                                                                                                                                                                      • ☰ 16. Random Numbers and Simulations
                                                                                                                                                                                        • ☰ 16.1. Random Number Generation
                                                                                                                                                                                          • ☰ 16.2. Common Distributions
                                                                                                                                                                                            • ☰ 16.3. Simple Monte Carlo Simulation
                                                                                                                                                                                              • ☰ 16.4. Detector Resolution Simulation
                                                                                                                                                                                                • ☰ 16.5. Efficiency Simulation
                                                                                                                                                                                                • ☰ 17. Statistical Analysis with ROOT
                                                                                                                                                                                                  • ☰ 17.1. Basic Statistics
                                                                                                                                                                                                    • ☰ 17.2. Probability Distributions
                                                                                                                                                                                                      • ☰ 17.3. Statistical Uncertainties
                                                                                                                                                                                                        • ☰ 17.4. Chi-Square Tests
                                                                                                                                                                                                          • ☰ 17.5. Confidence Intervals
                                                                                                                                                                                                          • ☰ 18. Modern ROOT with RDataFrame
                                                                                                                                                                                                            • ☰ 18.1. Introduction to RDataFrame
                                                                                                                                                                                                              • ☰ 18.2. Loading Data
                                                                                                                                                                                                                • ☰ 18.3. Filtering Data
                                                                                                                                                                                                                  • ☰ 18.4. Defining New Columns
                                                                                                                                                                                                                    • ☰ 18.5. Creating Histograms
                                                                                                                                                                                                                      • ☰ 18.6. Statistical Operations
                                                                                                                                                                                                                        • ☰ 18.7. Saving Results
                                                                                                                                                                                                                          • ☰ 18.8. Multithreading
                                                                                                                                                                                                                          • ☰ 19. ROOT and Python
                                                                                                                                                                                                                            • ☰ 19.1. Introduction to PyROOT
                                                                                                                                                                                                                              • ☰ 19.2. ROOT Objects in Python
                                                                                                                                                                                                                                • ☰ 19.3. Reading ROOT Files with Python
                                                                                                                                                                                                                                  • ☰ 19.4. PyROOT and NumPy
                                                                                                                                                                                                                                    • ☰ 19.5. PyROOT and Matplotlib
                                                                                                                                                                                                                                      • ☰ 19.6. Choosing Between C++ and Python
                                                                                                                                                                                                                                      • ☰ 20. Advanced TTree Techniques
                                                                                                                                                                                                                                        • ☰ 20.1. Trees with Multiple Branches
                                                                                                                                                                                                                                          • ☰ 20.2. Storing std::vector Objects
                                                                                                                                                                                                                                            • ☰ 20.3. TChain
                                                                                                                                                                                                                                              • ☰ 20.4. Friends
                                                                                                                                                                                                                                                • ☰ 20.5. Efficient TTree Analysis
                                                                                                                                                                                                                                                • ☰ 21. ROOT for Particle and Nuclear Physics
                                                                                                                                                                                                                                                  • ☰ 21.1. Four-Vectors
                                                                                                                                                                                                                                                    • ☰ 21.2. Particle Kinematics
                                                                                                                                                                                                                                                      • ☰ 21.3. Invariant Mass
                                                                                                                                                                                                                                                        • ☰ 21.4. Angular Distributions
                                                                                                                                                                                                                                                          • ☰ 21.5. Detector Spectra
                                                                                                                                                                                                                                                          • ☰ 22. Debugging and Common ROOT Problems
                                                                                                                                                                                                                                                            • ☰ 22.1. ROOT Object Ownership
                                                                                                                                                                                                                                                              • ☰ 22.2. Null Pointers
                                                                                                                                                                                                                                                                • ☰ 22.3. Segmentation Faults
                                                                                                                                                                                                                                                                  • ☰ 22.4. Missing Histograms
                                                                                                                                                                                                                                                                    • ☰ 22.5. ROOT File Problems
                                                                                                                                                                                                                                                                      • ☰ 22.6. TTree Branch Problems
                                                                                                                                                                                                                                                                        • ☰ 22.7. Histogram Range Problems
                                                                                                                                                                                                                                                                          • ☰ 22.8. Fit Failures
                                                                                                                                                                                                                                                                            • ☰ 22.9. Debugging ROOT Macros
                                                                                                                                                                                                                                                                            • ☰ 23. Writing Better ROOT Analysis Code
                                                                                                                                                                                                                                                                              • ☰ 23.1. Separating Analysis and Plotting
                                                                                                                                                                                                                                                                                • ☰ 23.2. Using Functions
                                                                                                                                                                                                                                                                                  • ☰ 23.3. Using Header Files
                                                                                                                                                                                                                                                                                    • ☰ 23.4. Naming Conventions
                                                                                                                                                                                                                                                                                      • ☰ 23.5. Avoiding Hard-Coded Values
                                                                                                                                                                                                                                                                                        • ☰ 23.6. Configuration Parameters
                                                                                                                                                                                                                                                                                          • ☰ 23.7. Reproducible Analysis
                                                                                                                                                                                                                                                                                            • ☰ 23.8. Version Control with Git
                                                                                                                                                                                                                                                                                            • ☰ 24. Final Project
                                                                                                                                                                                                                                                                                              • ☰ 24.1. Project Overview
                                                                                                                                                                                                                                                                                                • ☰ 24.2. Analyze a complete scientific dataset using ROOT.
                                                                                                                                                                                                                                                                                                  • ☰ 24.3. Import the Data
                                                                                                                                                                                                                                                                                                    • ☰ 24.4. Explore the Dataset
                                                                                                                                                                                                                                                                                                      • ☰ 24.5. Apply Data Selection
                                                                                                                                                                                                                                                                                                        • ☰ 24.6. Create Histograms
                                                                                                                                                                                                                                                                                                          • ☰ 24.7. Fit the Data
                                                                                                                                                                                                                                                                                                            • ☰ 24.8. Calculate Physical Quantities
                                                                                                                                                                                                                                                                                                              • ☰ 24.9. Estimate Statistical Uncertainties
                                                                                                                                                                                                                                                                                                                • ☰ 24.10. Create Publication-Quality Figures
                                                                                                                                                                                                                                                                                                                  • ☰ 24.11. Save the Analysis Results
                                                                                                                                                                                                                                                                                                                    • ☰ 24.12. Write a Short Analysis Report
                                                                                                                                                                                                                                                                                                                    • ☰ 25. Appendices
                                                                                                                                                                                                                                                                                                                      • ☰ 25.1. A. ROOT Command Cheat Sheet
                                                                                                                                                                                                                                                                                                                        • ☰ 25.2. B. ROOT Histogram Classes
                                                                                                                                                                                                                                                                                                                          • ☰ 25.3. C. ROOT Graph Classes
                                                                                                                                                                                                                                                                                                                            • ☰ 25.4. D. Common TTree Commands
                                                                                                                                                                                                                                                                                                                              • ☰ 25.5. E. Common Drawing Options
                                                                                                                                                                                                                                                                                                                                • ☰ 25.6. F. Common Fit Functions
                                                                                                                                                                                                                                                                                                                                  • ☰ 25.7. G. ROOT C++ Cheat Sheet
                                                                                                                                                                                                                                                                                                                                    • ☰ 25.8. H. PyROOT Cheat Sheet
                                                                                                                                                                                                                                                                                                                                      • ☰ 25.9. I. Common ROOT Errors and Solutions
                                                                                                                                                                                                                                                                                                                                        • ☰ 25.10. J. Recommended ROOT Analysis Workflow