// lt-2.cc // A ZOOM PhysicsVectors tutorial example // // Tutorial example 2 for the LorentzTransformation class: // // Construction and component access // // * Constructing LorentzTransformations // * Output to ostreams // * Constructing an array of LorentzTransformations // * Using different forms of coordinates // * Changing individual components // * Components of the matrix representation // Key lines are marked by // <------------- // Get the LorentzTransformation class #include "ZMutility/ZMenvironment.h" #include "PhysicsVectors/LorentzTransformation.h" #include "PhysicsVectors/LorentzVector.h" #include "PhysicsVectors/Rotation.h" ZM_USING_NAMESPACE( zmpv ) USING( std::cout ) USING( std::endl ) // These classes themselves pull in FixedTypes, but just to // remind ourselves that we are using Float8, not double, for // 64-bit floats... #include "ZMutility/FixedTypes.h" ZM_USING_NAMESPACE( zmfxt ) // This example will use iostream output, so get that -- // in a portable way. #include "ZMutility/iostream" using std::cout; using std::endl; // This example also tries to make the afore-mentioned output // a bit more readable: #include "ZMutility/iomanip" using std::setw; #include "ZMutility/cmath" using CMATH_NAMESPACE::sqrt; const Float8 PI = 3.1415926535897931; int main() { // ***** Constructing a LorentzTransformation // ***** Output to ostreams // Here is how to construct a LorentzTransformation from a Rotation: //------------------------------------------------------------------ // (See tutorial example ro-1 for how to construct and access // Rotations, example lv-1 for how to construct and access // LorentzVectors, and example lt-1 for how to construct and // access LorentzBoosts.) cout << "Constructing lt1 from a Rotation \n"; Rotation r1 ( PI/6, PI, -PI/2 ); LorentzTransformation lt1 ( r1 ); // <------------- // Here is how to output a LorentzTransformation: //----------------------------------------------- cout << "lt1 = " << lt1 << endl; // <------------- // Here is how to construct a LorentzTransformation from a LorentzBoost: //---------------------------------------------------------------------- cout << "Constructing lt2 from a LorentzBoost \n"; LorentzBoost b1( UnitVector(1, 1, 1), .5 ); LorentzTransformation lt2( b1 ); // <------------- cout << "lt2 = " << lt2 << endl; // Here is how to construct a LorentzTransformation // from a LorentzBoost and a Rotation: //------------------------------------------------- cout << "Constructing lt3 from a LorentzBoost and a Rotation \n"; Rotation r2 ( PI, .1, - PI/7 ); LorentzBoost b2 ( .75, .4, -.5 ); LorentzTransformation lt3( b2, r2 ); // <------------- cout << "Constructing lt4 from a Rotation and a LorentzBoost \n"; LorentzTransformation lt4( r2, b2 ); // <------------- cout << "lt3 = " << lt3 << endl; cout << "lt4 = " << lt4 << endl; // Here is how to construct a LorentzTransformation // from a set of LorentzVectors: //------------------------------------------------- cout << "Constructing lt5 from a set of 4-vectors \n"; LorentzVector w1( 0.5 , -0.5 , sqrt(2.0)/2, Tcomponent(0) ); LorentzVector w2( 0.5 , -0.5 , -sqrt(2.0)/2, Tcomponent(0) ); LorentzVector w3( sqrt(2.0)/2, sqrt(2.0)/2, 0.0, Tcomponent(0) ); LorentzVector w4( 0.0 , 0.0 , 0.0, Tcomponent(1) ); LorentzTransformation lt5( w1, w2, w3, w4 ); // <------------- // The four, 4-vectors will now form the // four columns of the transformation cout << "lt5 = " << lt5 << endl; // Here is how to construct a LorentzTransformation // from a matrix representation: //------------------------------------------------- cout << "Constructing lt6 from a matrix representation \n"; ZMpvRep4x4 m_rep( 1.05934, 0.12554, 0.00810, 0.37152 , 0.15419, 1.32899, 0.03621, 0.88954 , 0.16565, 0.36564, 1.10602, 0.62000 , 0.41643, 0.95690, 0.47397, 1.52109 ); LorentzTransformation lt6 ( m_rep ); // <------------- cout << "lt6 = " << lt6 << endl; // ***** Constructing an array of LorentzTransformations // How to construct an array of LorentzTransformation::IDENTITY // transformations: //----------------------------------------------------------- // These hundred transformations will be initialized // to the identity matrix LorentzTransformation lta [100]; // <------------- // This tutorial does not make use of these. // ***** Using different forms of components // Here is how to decompose into a Rotation and a LorentzBoost //------------------------------------------------------------ // Please examine the Formulas and Definitions document for further // information on the mathematical meaning behind decomposition // into a boost and a rotation versus into a rotation and a boost. LorentzBoost b3; Rotation r3; lt5.decompose( r3, b3 ); // <------------- cout << "lt5 = " << lt5 << endl; cout << "lt5 decomposes into r3 = " << endl << r3 << " and b3 = " << endl << b3 << endl; // The same can be done in a reverse order: lt5.decompose( b3, r3 ); // <------------- cout << "This time, lt5 decomposes into r3 = " << endl << r3 << " and b3 = " << endl << b3 << endl; // Here is how to obtain a 4x4 matrix representing // a LorentzTransformation: //------------------------------------------------ m_rep = lt1.rep4x4(); // -------------- cout << setw(15) << m_rep.xx_ << setw(15) << m_rep.xy_ << setw(15) << m_rep.xz_ << setw(15) << m_rep.xt_ << endl; cout << setw(15) << m_rep.yx_ << setw(15) << m_rep.yy_ << setw(15) << m_rep.yz_ << setw(15) << m_rep.yt_ << endl; cout << setw(15) << m_rep.zx_ << setw(15) << m_rep.zy_ << setw(15) << m_rep.zz_ << setw(15) << m_rep.zt_ << endl; cout << setw(15) << m_rep.tx_ << setw(15) << m_rep.ty_ << setw(15) << m_rep.tz_ << setw(15) << m_rep.tt_ << endl; // Here is how to obtain individual matrix components: //---------------------------------------------------- Float8 elem_xx = lt2.xx(); // <------------- cout << "The xx element of lt2 = " << elem_xx << endl; // You can also just output the values directly cout << "Row1 is: " << endl << lt2.xx() << " " << lt2.xy() << " " // <------------- << lt2.xz() << " " << lt2.xt() << endl; // The above applies for all elements from xx,xy,xz,...,ty,tz,tt // Here is how to obtain rows of the matrix: //------------------------------------------ LorentzVector w5 = lt3.row1(); // <------------- cout << "The first row of lt3 is " << w5 << endl; // You can also just output the values directly cout << lt3.row2() << endl << lt3.row3() << endl << lt3.row4() << endl; // Here is how to change multiple components at once: //--------------------------------------------------- cout << "lt1 is " << lt1 << endl; // By LorentzBoost: lt1.set( b2 ); // <------------- cout << "lt1 is now: " << lt1 << endl; // By Rotation: lt1.set( r3 ); // <------------- cout << "lt1 is now: " << lt1 << endl; // By LorentzBoost and Rotation lt1.set( b1, r3 ); // <------------- cout << "lt1 is now: " << lt1 << endl; // By Rotation and LorentzBoost lt1.set( r3, b1 ); // <------------- cout << "lt1 is now: " << lt1 << endl; // By columns lt1.set( w1, w2, w3, w4 ); // <------------- cout << "lt1 is now: " << lt1 << endl; // By rows lt1.setRows( w1, w2, w3, w4 ); // <------------- cout << "lt1 is now: " << lt1 << endl; // By 4x4 matrix representation lt1.set ( m_rep ); // <------------- cout << "lt1 is now: " << lt1 << endl; return 0; } /* end of main */