// lv-4.cc // A ZOOM PhysicsVectors tutorial example // // Tutorial example 4 for the LorentzVector class: // // Boosts and Rotations of LorentzVectors // // * Boosting along a given axis // * Rotating a 4-vector // Key lines are marked with // <------------------ // Get the LorentzVector class #include "ZMutility/ZMenvironment.h" #include "ZMutility/FixedTypes.h" #include "PhysicsVectors/LorentzVector.h" #include "PhysicsVectors/SpaceVector.h" #include "PhysicsVectors/UnitVector.h" ZM_USING_NAMESPACE( zmpv ) USING( std::cout ) USING( std::endl ) // Get the EulerAngles class used for rotations, below #include "PhysicsVectors/EulerAngles.h" // This example will use iostream output, so get that -- // in a portable way. #include "ZMutility/iostream" using std::cout; using std::endl; const Float8 PI = 3.1415926535897931; int main() { // (See tutorial example lv-1 for how to construct and access // LorentzVectors.) // generate a few sample vectors LorentzVector w1 ( 3, 2, 5, Tcomponent (12 ) ); LorentzVector w2 ( -1, 3, 4, Tcomponent ( 5 ) ); LorentzVector w3 ( 3, 4, -12,Tcomponent (13 ) ); LorentzVector w4 ( -3, -1, 4, Tcomponent (5.1) ); LorentzVector w5, w6, w7; // ***** Boosting along a given axis // Here is how to boost along an arbitrary axis //--------------------------------------------- // (See tutorial example sv-3 for how to construct and access // UnitVectors.) UnitVector u1( 45, DEGREES, 30, DEGREES); Float8 beta = .75; cout << "w1 is " << w1 << endl; w1.boost( u1, beta ); // <----------------- cout << "Now, w1 is " << w1 << endl; // The same procedure can be done with a SpaceVector representing // the boost providing its magnitude is less than 1. SpaceVector b(.3, -.6, .7); cout << "w2 is " << w2 << endl; w2.boost( b); // <----------------- cout << "Now, w2 is " << w2 << endl; // Two other methods are provided, working as do the ones above, // but returning new LorentzVectors rather than modifying them. w5 = boostOf( w3, u1, beta ); // <----------------- cout << "w3 was, and still is, " << w3 << endl; cout << "w5 is " << w5 << endl; w6 = boostOf( w4, b ); // <----------------- cout << "w4 was, and still is, " << w4 << endl; cout << "w6 is " << w6 << endl; // Here is how to boost along a coordinate axis //--------------------------------------------- // The exact same format follows for X, Y, and Z directions // w3.boostX(), w3.boostY(), w3.boostZ() cout << "w3 is " << w3 << endl; w3.boostX( beta ); // <----------------- cout << "Now, w3 is " << w3 << endl; // Again, we can do the same boost along an axis without modifying // the original: boostXOf(), boostYOf(), boostZOf() w5 = boostYOf( w4, beta ); cout << "w4 was, and still is, " << w4 << endl; cout << "Now, w5 is " << w5 << endl; // ***** Rotating a 4-vector // Here is how to rotate about an arbitrary axis //---------------------------------------------- u1.set( PI/5, RADIANS, PI/4, RADIANS); Float8 delta = PI/3; cout << "w1 is " << w1 << endl; w1.rotate( u1, delta ); // <----------------- cout << "Now, w1 is " << w1 << endl; // Another methods are provided, working as does the one above, // but returning a new LorentzVector rather than modifying it. w5 = rotationOf( w3, u1, delta ); // <----------------- cout << "w3 was, and still is, " << w3 << endl; cout << "w5 is " << w5 << endl; // How to rotate about a spatial coordinate axis //---------------------------------------------- cout << "w1 is " << w1<< endl; w1.rotateX( delta ); // <----------------- cout << "Now, w1 is " << w1 << endl; // Again, we can take the rotation of a vector rather than modifying it. w7 = rotationZOf( w1, delta ); // <----------------- cout << "w1 was, and still is, " << w1 << endl; cout << "w7 is now " << w7 << endl; // How to rotate a 4-vector using Euler angles //-------------------------------------------- Float8 phi = 0; Float8 theta = PI/2; Float8 psi = -PI; cout << "w2 is " << w2 << endl; w2.rotate( phi, theta, psi ); // <----------------- cout << "Now, w2 is " << w2 <