TLorentzVector P1(10, 20, 30, 40); // Initialize P1 with momentum (10, 20, 30) and energy 40 TLorentzVector P2(5, 10, 15, 20); // Initialize P2 with momentum (5, 10, 15) and energy 20 TLorentzVector sum = P1 + P2; // Add P1 and P2 together to get the total momentum and energy cout << "Total momentum: (" << sum.Px() << ", " << sum.Py() << ", " << sum.Pz() << ")" << endl; cout << "Total energy: " << sum.E() << endl;
TLorentzVector P(20, 30, 40, 50); // Initialize P with momentum (20, 30, 40) and energy 50 double beta = 0.5; // Set the boost factor, which determines how much P will be boosted P.Boost(0, 0, beta); // Boost P along the z-axis with the given beta value cout << "Boosted momentum: (" << P.Px() << ", " << P.Py() << ", " << P.Pz() << ")" << endl; cout << "Boosted energy: " << P.E() << endl;Package library: The TLorentzVector class is part of the ROOT framework's Mathcore library.