// lt-1.cc // A ZOOM PhysicsVectors tutorial example // // Tutorial example 1 for the LorentzBoost class: // // Construction and component access // // * Constructing LorentzBoosts // * Output to ostreams // * Constructing an array of LorentzBoosts // * 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" 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 it afore-mentioned output // a bit more readable: #include "ZMutility/iomanip" using std::setw; int main() { // ***** Constructing a LorentzBoost // ***** Output to ostreams // (See tutorial example sv-3 for how to construct and access // UnitVectors, example sv-1 for how to construct and access // SpaceVectors, and example lv-1 for how to construct and access // LorentzVectors.) // Here is how to construct a LorentzBoost from // a direction and a scalar beta: //--------------------------------------------- cout << "Constructing b1 from a direction and a beta value \n"; UnitVector u1( 1, 1, 1 ); Float8 beta = .765; LorentzBoost b1( u1, .765 ); // <------------- cout << "b1 = " << b1 << endl; // Here is how to construct a LorentzBoost from a SpaceVector: //------------------------------------------------------------ // In this case, the SpaceVector represents the direction, and // the beta. This means that the magnitude of the vector must // be less than 1 to be physically meaningful. cout << "Constructing b2 from a vector \n"; SpaceVector v1( .3, .4, .5 ); LorentzBoost b2( v1 ); // <------------- cout << "b2 = " << b2 << endl; // Here is how to construct a LorentzBoost from three beta components: //-------------------------------------------------------------------- cout << "Constructing b3 from three beta components \n"; Float8 betaX = .66667; Float8 betaY = .00001; Float8 betaZ = .72100; LorentzBoost b3 ( betaX, betaY, betaZ ); // <------------ cout << "b3 = " << b3 << endl; // Here is how to construct a LorentzBoost from // a symmetric matrix representation: //--------------------------------------------- // A LorentzBoost can be represented by a symmetric matrix, and // as such it can be constructed from one. To prohibit any // illegal creation from a non-symmetric matrix, it will not allow // construction from a standard 4x4 matrix, only the symmetric. cout << "Constructing b4 from a symmetric matrix representation \n"; ZMpvRep4x4Symmetric m_rep_s ( 2.064742, 0.0, 0.0, 2.294157 , 1.0, 0.0, 0.000000 , 1.0, 0.000000 , 2.064742 ); LorentzBoost b4( m_rep_s ); // <------------- cout << "b4 = " << b4 << endl; // ***** Constructing an array of LorentzBoost // Here is how to construct an array of LorentzBoost::IDENTITY boosts: //-------------------------------------------------------------------- // These hundred boosts will be initialized to the identity matrix LorentzBoost ba [100]; // <------------- // This tutorial does not make use of these. // ***** Using different forms of components // Here is how to obtain the direction of a LorentzBoost: //------------------------------------------------------- //UnitVector u2 = b4.direction(); // <------------- UnitVector u2 = b4.getDirection(); // <------------- cout << "b4 is a pure boost in the " << u2 << " direction " << endl; // Here is how to obtain the beta and gamma values of a LorentzBoost: //------------------------------------------------------------------- beta = b3.beta(); // <------------- cout << "For b3, beta is " << beta; // You can also output a value directly, say, gamma, for example: cout << " and gamma is " << b3.gamma() << endl; // <------------- // Here is how to obtain a SpaceVector representing a LorentzBoost: //----------------------------------------------------------------- // Here, the magnitude of the vector will represent the value of // beta, and the direction obviously indicates the direction of // the boost. SpaceVector v2; v2 = b1.boostVector(); // <------------- cout << "b1 can be represented by the SpaceVector " << v2 << "\nwhich has a magnitude of " << v2.mag() << endl; // Here is how to obtain a 4x4 matrix representing a LorentzBoost: //---------------------------------------------------------------- ZMpvRep4x4 m_rep = b2.rep4x4(); // <------------- cout << "b2's matrix representation is: " << endl; 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 << endl; // Here is how to obtain individual matrix components: //---------------------------------------------------- cout << "b1's matrix components are: " << endl; cout << setw(15) << b1.xx() << setw(15) << b1.xy() // <------------- << setw(15) << b1.xz() << setw(15) << b1.xt() << endl; // In addition to looking at each separate element of the matrix, it // is also possible to look at each row or column: cout << b1.row2() << endl << endl; // <------------- cout << b3.col1() << endl; // <------------- // ***** Changing individual components // Here is how to modify multiple components at one time: //------------------------------------------------------- beta = .5; b1.set( u2, beta ); // <------------- cout << "Now, b1 = " << b1 << endl; b1.set( v2 ); // <------------- cout << "Now, b1 = " << b1 << endl; betaX = 0.0; betaY = 0.7; betaZ = 0.5; b1.set( betaX, betaY, betaZ ); // <------------- cout << "Now, b1 = " << b1 << endl; b1.set( m_rep_s ); // <------------- cout << "Now, b1 = " << b1 << endl; return 0; } /* end of main */