TLorentzVector is a C++ class provided by the ROOT package library for representing a four-vector. It is commonly used in particle physics simulations to represent energies and momenta of particles.
The SetPtEtaPhiM method is used to set the momentum, pseudorapidity, azimuthal angle, and mass of the vector. Here are some code examples:
Example 1: Set a TLorentzVector with a transverse momentum of 50 GeV, pseudorapidity of 0.8, azimuthal angle of 1.2 radians, and a mass of 100 GeV.
```c++ // Include the ROOT headers and namespace #include
int main() { // Set values for the four-vector double pt = 50; // GeV/c double eta = 0.8; // pseudorapidity double phi = 1.2; // radians double m = 100; // GeV/c^2
// Create a TLorentzVector and set the values TLorentzVector vec; vec.SetPtEtaPhiM(pt, eta, phi, m);
return 0; }
Example 2: Set a TLorentzVector to have the same momentum and mass as a previously defined vector, but change the pseudorapidity and azimuthal angle.
c++
// Include the ROOT headers and namespace
#include
int main() {
// Previously defined vector
TLorentzVector vec1(30, 1.2, -0.6, 50);
// Set new values for pseudorapidity and azimuthal angle
double eta = 0.8; // pseudorapidity
double phi = 1.2; // radians
// Create a new TLorentzVector and set the values
TLorentzVector vec2;
vec2.SetPtEtaPhiM(vec1.Pt(), eta, phi, vec1.M());
return 0;
}
```
The examples show how to create and set values for a TLorentzVector using the SetPtEtaPhiM method. The package library used is ROOT.
C++ (Cpp) TLorentzVector::SetPtEtaPhiM - 30 examples found. These are the top rated real world C++ (Cpp) examples of TLorentzVector::SetPtEtaPhiM extracted from open source projects. You can rate examples to help us improve the quality of examples.