// Initializing a TLorentzVector with energy=10 GeV, momentum=(20, 30, 40) GeV/c TLorentzVector vec1(20, 30, 40, 10); // Calculating the magnitude of the three-momentum double pMagnitude = vec1.P(); // Printing the magnitude to the console std::cout << "The magnitude of the momentum is: " << pMagnitude << std::endl;
// Initializing a TLorentzVector with energy=10 GeV, momentum=(20, 30, 40) GeV/c TLorentzVector vec1(20, 30, 40, 10); // Performing a boost in the x-direction with a velocity of 0.5c vec1.Boost(0.5, 0, 0); // Printing the energy and momentum components after the boost std::cout << "After boost: (" << vec1.E() << ", " << vec1.Px() << ", " << vec1.Py() << ", " << vec1.Pz() << ")" << std::endl;This example initializes a TLorentzVector and performs a boost in the x-direction with a velocity of 0.5c. The resulting energy and momentum components are printed to the console. Package library: ROOT (https://root.cern.ch/)