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
A cartesian 2-dimensional vector |
|
A polar coordinate 2-dimensional vector |
|
A cartesian 3-dimensional vector |
|
A spherical coordinate 3-dimensional vector |
|
A cartesian Lorentz vector |
|
A Lorentz vector using pseudorapidity and mass |
|
A Lorentz vector using pseudorapidity and energy |