Logo ROOT   6.10/00
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
math/genvector/doc/LorentzVector.md
Go to the documentation of this file.
1 // LorentzVector doxygen page
2 
3 /** \page LorentzVectorPage LorentzVector Classes
4 
5 To avoid exposing templated parameter to the users, typedefs are defined for all types of vectors based an double's and float's. To use them, one must include the header file _Math/Vector4D.h_. The following typedef's, defined in the header file _Math/Vector4Dfwd.h_, are available for the different instantiations of the template class ROOT::Math::LorentzVector:
6 
7 * ROOT::Math::XYZTVector vector based on x,y,z,t coordinates (cartesian) in double precision
8 * ROOT::Math::XYZTVectorF vector based on x,y,z,t coordinates (cartesian) in float precision
9 * ROOT::Math::PtEtaPhiEVector vector based on pt (rho),eta,phi and E (t) coordinates in double precision
10 * ROOT::Math::PtEtaPhiMVector vector based on pt (rho),eta,phi and M (t) coordinates in double precision
11 * ROOT::Math::PxPyPzMVector vector based on px,py,pz and M (mass) coordinates in double precision
12 
13 The metric used for all the LorentzVector's is (-,-,-,+)
14 
15 #### Constructors and Assignment
16 
17 The following declarations are available:
18 
19 <pre>XYZTVector v1; // create an empty vector (x = 0, y = 0, z = 0, t = 0)
20 XYZTVector v2(1,2,3,4); // create a vector with x=1, y = 2, z = 3, t = 4
21 PtEtaPhiEVector v3(1,2,PI,5); // create a vector with pt = 1, eta = 2, phi = PI, E = 5
22 </pre>
23 
24 Note that each type of vector is constructed by passing its coordinates representations, so a XYZTVector(1,2,3,4) is different from a PtEtaPhiEVector(1,2,3,4).
25 
26 In addition the Vector classes can be constructed by any vector, which implements the accessors x(), y() and z() and t(). This cann be another ROOT::Math::LorentzVector based on a different coordinate system or even any vector of a different package, like the CLHEP HepLorentzVector that implements the required signature.
27 
28 <pre>XYZTVector v1(1,2,3,4);
29 PtEtaPhiEVector v2(v1);
30 
31 CLHEP::HepLorentzVector q(1,2,3,4);
32 XYZTVector v3(q)
33 </pre>
34 
35 #### Coordinate Accessors
36 
37 All the same coordinate accessors are available through the interface of the class ROOT::Math::LorentzVector. For example:
38 
39 <pre>v1.X(); v1.X(); v1.Z(); v1.T() // returns cartesian components for the cartesian vector v1
40 v2.Px(); v2.Py(); v2.Pz(); v2.E() // returns cartesian components for the cylindrical vector v2
41 v1.Pt(); v1.Eta(); v1.Phi(); v1.M() // returns other components for the cartesian vector v1
42 </pre>
43 
44 In addition, all the 4 coordinates of the vector can be retrieved with the GetCoordinates method:
45 
46 <pre>double d[4];
47 v1.GetCoordinates(d); // fill d array with (x,y,z,t) components of v1
48 v2.GetCoordinates(d); // fill d array with (pt,eta,phi,e) components of v2
49 std::vector <double>w(4);
50 v1.GetCoordinates(w.begin(),w.end()); // fill std::vector with (x,y,z,t) components of v1</double> </pre>
51 
52 To get information on all the coordinate accessors see the reference documentation of ROOT::Math::LorentzVector
53 
54 #### Setter Methods
55 
56 One can set only all the three coordinates via:
57 
58 <pre>v1.SetCoordinates(c1,c2,c3,c4); // sets the (x,y,z,t) for a XYZTVector
59 v2.SetCoordinates(c1,c2,c3,c4); // sets pt,eta,phi,e for a PtEtaPhiEVector
60 v2.SetXYZ(x,y,z,t); // sets the 4 cartesian components for the PtEtaPhiEVector
61 </pre>
62 
63 Single coordinate setter methods are available for the basic vector coordinates, like SetX() for a XYZTVector or SetPt() for a PtEtaPhiEVector. Attempting to do a SetX() on a non cartesian vector will not compile.
64 
65 <pre>XYZTVector v1; v1.SetX(1) // OK setting x for a cartesian vector
66 PtEtaPhiEVector v2; v2.SetX(1) // ERROR: cannot set X for a non-cartesian vector. Method will not compile
67 v2.SetR(1) // OK setting Pt for a PtEtaPhiEVector vector
68 </pre>
69 
70 In addition there are setter methods from C arrays or iterators.
71 
72 <pre>double d[4] = {1.,2.,3.,4.};
73 XYZTVector v;
74 v.SetCoordinates(d); // set (x,y,z,t) components of v using values from d
75 </pre>
76 
77 or for example from an std::vector using the iterators
78 
79 <pre>std::vector <double>w(4);
80 v.SetCoordinates(w.begin(),w.end()); // set (x,y,z,t) components of v using values from w</double> </pre>
81 
82 #### Arithmetic Operations
83 
84 The following operations are possible between LorentzVectors classes, even of different coordinate system types: ( v and w are two LorentzVector of the same type, q is a generic LorentzVector implementing x(), y(), z() and t() and a is a generic scalar type: double, flot, int, etc.... )
85 
86 <pre>v += q;
87 v -= q;
88 v = -q;
89 v *= a;
90 v /= a;
91 w = v + q;
92 w = v - q;
93 w = v * a;
94 w = a * v;
95 w = v / a;
96 </pre>
97 
98 #### Comparison
99 
100 <pre>v == w;
101 v != w;
102 </pre>
103 
104 #### Other Methods
105 
106 <pre>a = v.Dot(q); // dot product in metric (+,+,+,-) of two LorentzVector's
107 XYZVector s = v.Vect() // return the spatial components (x,y,z)
108 v.Beta(); // return beta and gamma value
109 v.Gamma() // (vector must be time-like otherwise result is meaningless)
110 XYZVector b = v.BoostToCM() // return boost vector which will bring the Vector in its mas frame (P=0)
111 </pre>
112 
113 */