TLorentzVector v1(40, 0, 0, 40); // Create a four-vector with Px=40, E=40 TLorentzVector v2(0, 40, 0, 40); // Create another with Py=40, E=40 TLorentzVector v_sum = v1 + v2; // Sum the two vectors cout << "v_sum has Px = " << v_sum.Px() << endl; // prints "v_sum has Px = 40"
TLorentzVector v_original(50, 40, 30, 100); // Create a four-vector with non-zero components TLorentzVector v_boosted = v_original.Boost(-0.5, 0, 0); // Boost the vector along the x-axis cout << "v_boosted has Px = " << v_boosted.Px() << endl; // prints "v_boosted has Px = 86.6025"This example creates a four-vector with non-zero components and energy, then applies a boost along the x-axis using the `Boost` function. The resulting vector has a new value for the Px component which is calculated based on the boost parameters. Both examples use the `TLorentzVector` class from the ROOT package library for C++.