Mathematical utilities (skhep.math)

Module for mathematical functions and utilities.

Mathematical functions relevant to kinematics

skhep.math.kinematics.Kallen_function(x, y, z)

The Kallen function, aka triangle or lambda function, named after physicist Anders Olof Gunnar Kallen [Kallen].

Definition:
\[\begin{split}\begin{eqnarray} \lambda(x,y,z) &=& x^2 + y^2 + z^2 - 2 x y - 2 y z - 2 z x \\ &=& (x-y-z)^2 - 4 y z \\ &=& [ x - (\sqrt{y}+\sqrt{z})^2 ] [ x - (\sqrt{y}-\sqrt{z})^2 ] \,\,\,\mathrm{if} \,\,\,y, z > 0 \end{eqnarray}\end{split}\]
Example:

Calculate in the rest frame of a particle of mass M decaying to 2 particles labeled 1 and 2, \(P (M) \to p1 (m1) + p2 (m2)\), the momenta of 1 and 2 given by \(p = |\mathbf{p1}| = |\mathbf{p2}|\):

>>> from skhep.math  import Kallen_function
>>> from skhep.units import MeV, GeV
>>> from math import sqrt
>>> M = 5.279 * GeV; m1 = 493.7 * MeV; m2 = 139.6 * MeV
>>> p = sqrt( Kallen_function( M**2, m1**2, m2**2 ) ) / (2*M)
>>> print p / GeV   # print the CMS momentum in GeV
2.61453580221
Reference:
[Kallen]https://en.wikipedia.org/wiki/K%C3%A4ll%C3%A9n_function
skhep.math.kinematics.lifetime_to_width(tau)

Convert from a particle lifetime to a decay width.

Parameters:
tau : float > 0
Particle lifetime, typically in picoseconds (any HEP time unit is OK).
Returns:

Particle decay width, in the HEP standard energy unit MeV.

skhep.math.kinematics.width_to_lifetime(Gamma)

Convert from a particle decay width to a lifetime.

Parameters:
Gamma : float > 0
Particle decay width, typically in MeV (any HEP energy unit is OK).
Returns:

Particle lifetime, in the HEP standard time unit ns.

Vector classes

Two vector classes are available:

  • Vector3D : a 3-dimensional vector.
  • LorentzVector: a Lorentz vector, i.e. a 4-dimensional Minkowski space-time vector
    or a 4-momentum vector. The metric is (-1,-1,-1,+1).
class skhep.math.vectors.LorentzVector(x=0.0, y=0.0, z=0.0, t=0.0)

Class representing a Lorentz vector, either a 4-dimensional Minkowski space-time vector or a 4-momentum vector. The 4-vector components can be seen as (x,y,z,t) or (px,py,pz,E).

Constructors:
__init__(x=0., y=0., z=0., t=0.) from4vector(avector) from3vector(vector3d, t)
beta()

Return \(\beta = v/c\).

dot(other)

Dot product with another Lorentz vector.

e

Return the energy/time component, aka momentum coordinate at position 3.

eta()

Return the pseudorapidity.

classmethod from3vector(vector3d, t)

Constructor from a 3D-vector and the time/energy component.

classmethod from4vector(other)

Copy constructor.

gamma()

Return \(\gamma = 1/\sqrt{1-\beta^2}\).

islightlike()

Check if Lorentz vector is light-like.

isspacelike()

Check if Lorentz vector is space-like.

istimelike()

Check if Lorentz vector is time-like.

m

Return the invariant mass.

m2

Return the square of the invariant mass.

mag

Magnitude, a.k.a. norm, of the Lorentz vector.

mag2

Square of the magnitude, a.k.a. norm, of the Lorentz vector.

mass

Return the invariant mass.

mass2

Return the square of the invariant mass.

phi(deg=False)

Return the spherical or cylindrical coordinate phi of the 3D-vector.

Options:
deg : return the angle in degrees (default is radians)
pseudorapidity()

“Return the pseudorapidity. Alternative to eta() method.

px

Return the 3D-vector coordinate px, aka first momentum coordinate at position 0.

py

Return the 3D-vector coordinate px, aka second momentum coordinate at position 1.

pz

Return the 3D-vector coordinate pz, aka third momentum coordinate at position 2.

rapidity()

Return the rapidity.

set(x, y, z, t)

Update/set all components at once.

sete(e)

Update/set the energy/time component.

setpx(px)

Update/set the px component.

setpy(py)

Update/set the py component.

setpz(pz)

Update/set the pz component.

t

Return the time/energy component, aka coordinate at position 3.

theta(deg=False)

Return the spherical coordinate theta of the 3D-vector.

Options:
deg : return the angle in degrees (default is radians)
transversemass()

Return the transverse mass.

x

Return the 3D-vector coordinate x, aka first coordinate at position 0.

y

Return the 3D-vector coordinate x, aka second coordinate at position 1.

z

Return the 3D-vector coordinate z, aka third coordinate at position 2.

class skhep.math.vectors.Vector3D(x=0.0, y=0.0, z=0.0)

Vector class in 3 dimensions.

Constructors:
__init__(x=0., y=0., z=0.) origin() frompoint(x, y, z) fromvector(avector) fromsphericalcoords(r, theta, phi) fromcylindricalcoords(rho, phi, z) fromiterable(values)
angle(other, deg=False)

Angle with respect to another vector.

Options:
deg : return the angle in degrees (default is radians)
cross(v1, v2)

Cross product with another vector.

dot(other)

Dot product with another vector.

classmethod fromcylindricalcoords(rho, phi, z)

Constructor from a space point specified in cylindrical coordinates.

rho : radial distance from the z-axis (rho > 0) phi : azimuthal angle in radians (phi in [-pi, pi) rad) z : height

classmethod fromiterable(values)

Constructor from a suitable iterable object. Suitable means here that all entries are numbers and the length equals 3.

classmethod frompoint(x, y, z)

Constructor from an explicit space point.

classmethod fromsphericalcoords(r, theta, phi)

Constructor from a space point specified in spherical coordinates.

r : radius, the radial distance from the origin (r > 0) theta : inclination in radians (theta in [0, pi] rad) phi : azimuthal angle in radians (phi in [0, 2pi) rad)

classmethod fromvector(other)

Copy constructor.

isantiparallel(other)

Check if another vector is antiparallel. Two vectors are antiparallel if they have opposite direction but not necessarily the same magnitude.

isopposite(other)

Two vectors are opposite if they have the same magnitude but opposite direction.

isparallel(other)

Check if another vector is parallel. Two vectors are parallel if they have the same direction but not necessarily the same magnitude.

isperpendicular(other)

Check if another vector is perpendicular.

mag

Magnitude, a.k.a. norm, of the vector.

mag2

Square of the magnitude, a.k.a. norm, of the vector.

classmethod origin()

Shortcut constuctor for the origin (x=0.,y=0.,z=0.). Equivalent to the default constructor Vector3D().

perpendicular()

Return the vector perpendicular to itself.

phi

Return the spherical or cylindrical coordinate phi.

Options:
deg : return the angle in degrees (default is radians)
rho

Return the cylindrical coordinate rho.

set(x, y, z)

Update the vector components all at once.

theta

Return the spherical coordinate theta.

Options:
deg : return the angle in degrees (default is radians)
tolist()

Return the vector as a list.

unit()

Return the normalized vector, i.e. the unit vector along the direction of itself.

x

Return the x, aka first coordinate at position 0.

y

Return the y, aka second coordinate at position 1.

z

Return the z, aka third coordinate at position 2.