1 <chapter name="Four-Vectors">
5 The <code>Vec4</code> class gives an implementation of four-vectors.
6 The member function names are based on the assumption that these
7 represent momentum vectors. Thus one can get or set
8 <code>px()</code>, <code>py()</code>, <code>pz()</code> and
9 <code>e()</code>, but not <ei>x, y, z</ei> or <ei>t</ei>. (When
10 production vertices are defined in the particle class, this is
11 partly circumvented by new methods that hide a <code>Vec4</code>.)
12 All four values can be set in the constructor, or later by the
13 <code>p</code> method, with input in the order
14 <code>(px, py, pz, e)</code>.
17 The <code>Particle</code> object contains a <code>Vec4 p</code> that
18 stores the particle four-momentum, and another <code>Vec4 vProd</code>
19 for the production vertex. Therefore a user would not normally access the
20 <code>Vec4</code> class directly, but by using the similarly-named methods
21 of the <code>Particle</code> class, see
22 <aloc href="ParticleProperties">Particle Properties</aloc>.
23 (The latter also stores the particle mass separately, offering an element
24 of redundancy, helpful in avoiding some roundoff errors.)
25 However, you may find some knowledge of the four-vectors
26 convenient, e.g. as part of some simple analysis code based
27 directly on the PYTHIA output, say to define the four-vector sum
28 of a set of particles.
31 A set of overloaded operators are defined for four-vectors, so that
32 one may naturally add, subtract, multiply or divide four-vectors with
33 each other or with double numbers, for all the cases that are
34 meaningful. Of course the equal sign also works as expected.
35 The << operator is overloaded to write out the values of the
36 four components of a <code>Vec4</code>.
39 A number of methods provides output of derived quantities, such as:
41 <li><code>mCalc(), m2Calc()</code> the (squared) mass, calculated from
42 the four-vectors. If <ei>m^2 < 0</ei> the mass is given with a
43 minus sign, <ei>-sqrt(-m^2)</ei>.
44 <li><code>pT(), pT2()</code> the (squared) transverse momentum.</li>
45 <li><code>pAbs(), pAbs2()</code> the (squared) absolute momentum.</li>
46 <li><code>theta()</code> the polar angle, in the range 0 through
48 <li><code>phi()</code> the azimuthal angle, in the range <ei>-pi</ei>
49 through <ei>pi</ei>.</li>
50 <li><code>thetaXZ()</code> the angle in the <ei>xz</ei> plane, in the
51 range <ei>-pi</ei> through <ei>pi</ei>, with 0 along the <ei>+z</ei>
53 <li><code>pPlus(), pMinus()</code> the combinations <ei>E+-p_z</ei>.</li>
57 There are also some <code>friend</code> methods that take two or three
58 four-vectors as argument:
60 <li><code>m(Vec4&, Vec4&), m2(Vec4&, Vec4&)</code> the (squared)
62 <li><code>dot3(Vec4&, Vec4&)</code> the three-product. </li>
63 <li><code>cross3(Vec4&, Vec4&)</code> the cross-product.</li>
64 <li><code>theta(Vec4&, Vec4&), costheta(Vec4&, Vec4&)</code> the
65 (cosine) of the opening angle between the vectors.</li>
66 <li><code>phi(Vec4&, Vec4&), cosphi(Vec4&, Vec4&)</code> the
67 (cosine) of the azimuthal angle between the vectors around the
68 <ei>z</ei> axis, in the range 0 through <ei>pi</ei>.</li>
69 <li><code>phi(Vec4&, Vec4&, Vec4&), cosphi(Vec4&, Vec4&, Vec4&)</code>
70 the (cosine) of the azimuthal angle between the first two vectors
71 around the direction of the third, in the range 0 through <ei>pi</ei>.</li>
75 Some member functions can be used to modify vectors, including some
76 for rotations and boosts:
78 <li><code>rescale3(factor), rescale4(factor)</code> multiply the
79 three-vector or all components by this factor.</li>
80 <li><code>flip3(), flip4()</code> flip the sign of the
81 three-vector or all components.</li>
82 <li><code>rot(theta, phi)</code> rotate by this polar and azimuthal
84 <li><code>rotaxis(phi, nx, ny, nz), rotaxis(phi, n)</code> rotate
85 by this azimuthal angle around the axis provided either by the
86 three-vector <code>(nx, ny, nz)</code> or the four-vector
88 <li><code>bst(betaX, betaY, betaZ), bst(betaX, betaY, betaZ, gamma)</code>
89 boost the particle by this <ei>beta</ei> vector. Sometimes it may be
90 convenient also to provide the <ei>gamma</ei> value, especially for large
91 boosts where numerical accuracy may suffer.</li>
92 <li><code>bst(Vec4&), bstback(Vec4&)</code> boost with a
93 <ei>beta = p/E</ei> or <ei>beta = -p/E</ei>, respectively.
97 For a longer sequence of rotations and boosts, and where several
98 <code>Vec4</code> are to be rotated and boosted in the same way,
99 a more efficient approach is to define a <code>RotBstMatrix</code>,
100 which forms a separate auxiliary class. You can build up this matrix
101 by successive calls to the methods
103 <li><code>rot(theta, phi)</code> rotate by this polar and azimuthal
105 <li><code>rot(Vec4& p)</code> rotate so that a vector originally along
106 the <ei>+z</ei> axis becomes parallel with <ei>p</ei>. More specifically,
107 rotate by <ei>-phi</ei>, <ei>theta</ei> and <ei>phi</ei>, with angles
108 defined by <ei>p</ei>.</li>
109 <li><code>bst(betaX, betaY, betaZ)</code> boost the particle by this
110 <ei>beta</ei> vector.</li>
111 <li><code>bst(Vec4&), bstback(Vec4&)</code> boost with a
112 <ei>beta = p/E</ei> or <ei>beta = -p/E</ei>, respectively. </li>
113 <li><code>bst(Vec4& p1, Vec4& p2)</code> boost so that <ei>p_1</ei>
114 is transformed to <ei>p_2</ei>. It is assumed that the two vectors
115 obey <ei>p_1^2 = p_2^2</ei>.</li>
116 <li><code>toCMframe(Vec4& p1, Vec4& p2)</code> boost and rotate to the
117 rest frame of <ei>p_1</ei> and <ei>p_2</ei>, with <ei>p_1</ei> along
118 the <ei>+z</ei> axis.</li>
119 <li><code>fromCMframe(Vec4& p1, Vec4& p2)</code> rotate and boost from the
120 rest frame of <ei>p_1</ei> and <ei>p_2</ei>, with <ei>p_1</ei> along
121 the <ei>+z</ei> axis, to the actual frame of <ei>p_1</ei> and <ei>p_2</ei>,
122 i.e. the inverse of the above.</li>
123 <li><code>rotbst(RotBstMatrix&)</code> combine an existing matrix with
125 <li><code>invert()</code> invert the matrix, which corresponds to an
126 opposite sequence and sign of rotations and boosts.</li>
127 <li><code>reset()</code> reset to no rotation/boost; default at
133 <!-- Copyright (C) 2008 Torbjorn Sjostrand -->