coffea.nanoevents.methods.vector

2D, 3D, and Lorentz vector class mixins

These mixins will eventually be superceded by the vector library, which will hopefully be feature-compatible. The 2D vector provides cartesian and polar coordinate attributes, where r represents the polar distance from the origin.. The 3D vector provides cartesian and spherical coordinates, where rho represents the 3D distance from the origin and r is the axial distance from the z axis, so that it can subclass the 2D vector. The Lorentz vector also subclasses the 3D vector, adding t as the fourth cartesian coordinate. Aliases typical of momentum vectors are also provided.

A small example:

import numpy as np
import awkward as ak
from coffea.nanoevents.methods import vector

n = 1000

vec = ak.zip(
    {
        "x": np.random.normal(size=n),
        "y": np.random.normal(size=n),
        "z": np.random.normal(size=n),
    },
    with_name="ThreeVector",
    behavior=vector.behavior,
)

vec4 = ak.zip(
    {
        "pt": vec.r,
        "eta": -np.log(np.tan(vec.theta/2)),
        "phi": vec.phi,
        "mass": np.full(n, 1.),
    },
    with_name="PtEtaPhiMLorentzVector",
    behavior=vector.behavior,
)

assert np.allclose(np.array(vec4.x), np.array(vec.x))
assert np.allclose(np.array(vec4.y), np.array(vec.y))
assert np.allclose(np.array(vec4.z), np.array(vec.z))
assert np.allclose(np.array(abs(2*vec + vec4) / abs(vec)), 3)

Classes

TwoVector()

A cartesian 2-dimensional vector

PolarTwoVector()

A polar coordinate 2-dimensional vector

ThreeVector()

A cartesian 3-dimensional vector

SphericalThreeVector()

A spherical coordinate 3-dimensional vector

LorentzVector()

A cartesian Lorentz vector

PtEtaPhiMLorentzVector()

A Lorentz vector using pseudorapidity and mass

PtEtaPhiELorentzVector()

A Lorentz vector using pseudorapidity and energy

Class Inheritance Diagram

Inheritance diagram of coffea.nanoevents.methods.vector.TwoVector, coffea.nanoevents.methods.vector.PolarTwoVector, coffea.nanoevents.methods.vector.ThreeVector, coffea.nanoevents.methods.vector.SphericalThreeVector, coffea.nanoevents.methods.vector.LorentzVector, coffea.nanoevents.methods.vector.PtEtaPhiMLorentzVector, coffea.nanoevents.methods.vector.PtEtaPhiELorentzVector