Four-Vectors
The Vec4
class gives an implementation of four-vectors.
The member function names are based on the assumption that these
represent momentum vectors. Thus one can get or set
px()
, py()
, pz()
and
e()
, but not x, y, z or t. (When
production vertices are defined in the particle class, this is
partly circumvented by new methods that hide a Vec4
.)
All four values can be set in the constructor, or later by the
p
method, with input in the order
(px, py, pz, e)
.
The Particle
object contains a Vec4 p
that
stores the particle four-momentum, and another Vec4 vProd
for the production vertex. Therefore a user would not normally access the
Vec4
class directly, but by using the similarly-named methods
of the Particle
class, see
Particle Properties.
(The latter also stores the particle mass separately, offering an element
of redundancy, helpful in avoiding some roundoff errors.)
However, you may find some knowledge of the four-vectors
convenient, e.g. as part of some simple analysis code based
directly on the PYTHIA output, say to define the four-vector sum
of a set of particles.
A set of overloaded operators are defined for four-vectors, so that
one may naturally add, subtract, multiply or divide four-vectors with
each other or with double numbers, for all the cases that are
meaningful. Of course the equal sign also works as expected.
The << operator is overloaded to write out the values of the
four components of a Vec4
.
A number of methods provides output of derived quantities, such as:
mCalc(), m2Calc()
the (squared) mass, calculated from
the four-vectors. If m^2 < 0 the mass is given with a
minus sign, -sqrt(-m^2).
pT(), pT2()
the (squared) transverse momentum.
pAbs(), pAbs2()
the (squared) absolute momentum.
theta()
the polar angle, in the range 0 through
pi.
phi()
the azimuthal angle, in the range -pi
through pi.
thetaXZ()
the angle in the xz plane, in the
range -pi through pi, with 0 along the +z
axis.
pPlus(), pMinus()
the combinations E+-p_z.
There are also some friend
methods that take two or three
four-vectors as argument:
m(Vec4&, Vec4&), m2(Vec4&, Vec4&)
the (squared)
invariant mass.
dot3(Vec4&, Vec4&)
the three-product.
cross3(Vec4&, Vec4&)
the cross-product.
theta(Vec4&, Vec4&), costheta(Vec4&, Vec4&)
the
(cosine) of the opening angle between the vectors.
phi(Vec4&, Vec4&), cosphi(Vec4&, Vec4&)
the
(cosine) of the azimuthal angle between the vectors around the
z axis, in the range 0 through pi.
phi(Vec4&, Vec4&, Vec4&), cosphi(Vec4&, Vec4&, Vec4&)
the (cosine) of the azimuthal angle between the first two vectors
around the direction of the third, in the range 0 through pi.
Some member functions can be used to modify vectors, including some
for rotations and boosts:
rescale3(factor), rescale4(factor)
multiply the
three-vector or all components by this factor.
flip3(), flip4()
flip the sign of the
three-vector or all components.
rot(theta, phi)
rotate by this polar and azimuthal
angle.
rotaxis(phi, nx, ny, nz), rotaxis(phi, n)
rotate
by this azimuthal angle around the axis provided either by the
three-vector (nx, ny, nz)
or the four-vector
n
.
bst(betaX, betaY, betaZ), bst(betaX, betaY, betaZ, gamma)
boost the particle by this beta vector. Sometimes it may be
convenient also to provide the gamma value, especially for large
boosts where numerical accuracy may suffer.
bst(Vec4&), bstback(Vec4&)
boost with a
beta = p/E or beta = -p/E, respectively.
For a longer sequence of rotations and boosts, and where several
Vec4
are to be rotated and boosted in the same way,
a more efficient approach is to define a RotBstMatrix
,
which forms a separate auxiliary class. You can build up this matrix
by successive calls to the methods
rot(theta, phi)
rotate by this polar and azimuthal
angle.
rot(Vec4& p)
rotate so that a vector originally along
the +z axis becomes parallel with p. More specifically,
rotate by -phi, theta and phi, with angles
defined by p.
bst(betaX, betaY, betaZ)
boost the particle by this
beta vector.
bst(Vec4&), bstback(Vec4&)
boost with a
beta = p/E or beta = -p/E, respectively.
bst(Vec4& p1, Vec4& p2)
boost so that p_1
is transformed to p_2. It is assumed that the two vectors
obey p_1^2 = p_2^2.
toCMframe(Vec4& p1, Vec4& p2)
boost and rotate to the
rest frame of p_1 and p_2, with p_1 along
the +z axis.
fromCMframe(Vec4& p1, Vec4& p2)
rotate and boost from the
rest frame of p_1 and p_2, with p_1 along
the +z axis, to the actual frame of p_1 and p_2,
i.e. the inverse of the above.
rotbst(RotBstMatrix&)
combine an existing matrix with
another one.
invert()
invert the matrix, which corresponds to an
opposite sequence and sign of rotations and boosts.
reset()
reset to no rotation/boost; default at
creation.