Interface for all vectors

Contents

Interface for all vectors#

Vectors of all backends, 2D/3D/4D, geometric and momentum, have the following attributes, properties, and methods.

For interfaces specialized to 2D/3D/4D vectors or momentum vectors, see

class vector._methods.VectorProtocol#
lib#

The module used for functions used in compute functions (such as sqrt, sin, cos). Usually numpy.

Type:

module

ProjectionClass2D#

The class that would result from projecting this vector onto azimuthal coordinates only.

Type:

type

ProjectionClass3D#

The class that would result from projecting this vector onto azimuthal and longitudinal coordinates only.

Type:

type

ProjectionClass4D#

The class that would result from projecting this vector onto azimuthal, longitudinal, and temporal coordinates.

Type:

type

GenericClass#

The most generic concrete class for this type, for vectors without momentum-synonyms.

Type:

type

MomentumClass#

The momentum class for this type, for vectors with momentum-synonyms.

Type:

type

to_Vector2D() VectorProtocolPlanar#

Projects this vector/these vectors onto azimuthal coordinates only.

to_Vector3D() VectorProtocolSpatial#

Projects this vector/these vectors onto azimuthal and longitudinal coordinates only.

If 2D, a default \(z\) component of \(0\) is imputed.

The longitudinal coordinate can be passed as a named argument.

to_Vector4D() VectorProtocolLorentz#

Projects this vector/these vectors onto azimuthal, longitudinal, and temporal coordinates.

If 3D, a default \(t\) component of \(0\) is imputed.

If 2D, a \(z\) component of \(0\) is imputed along with a default \(t\) component of \(0\).

The longitudinal and temporal coordinates can be passed as named arguments.

to_2D() VectorProtocolPlanar#

Projects this vector/these vectors onto azimuthal coordinates only.

Alias for vector._methods.VectorProtocol.to_Vector2D().

to_3D() VectorProtocolSpatial#

Projects this vector/these vectors onto azimuthal and longitudinal coordinates only.

If 2D, a default \(z\) component of \(0\) is imputed.

The longitudinal coordinate can be passed as a named argument.

Alias for vector._methods.VectorProtocol.to_Vector3D().

to_4D() VectorProtocolLorentz#

Projects this vector/these vectors onto azimuthal, longitudinal, and temporal coordinates.

If 3D, a default \(t\) component of \(0\) is imputed.

If 2D, a \(z\) component of \(0\) is imputed along with a default \(t\) component of \(0\).

The longitudinal and temporal coordinates can be passed as named arguments.

Alias for vector._methods.VectorProtocol.to_Vector4D().

to_xy() VectorProtocolPlanar#

Converts to \(x\)-\(y\) coordinates, possibly eliminating dimensions with a projection.

to_pxpy() VectorProtocolPlanar#

Converts to \(px\)-\(py\) coordinates, possibly eliminating dimensions with a projection.

to_rhophi() VectorProtocolPlanar#

Converts to \(\rho\)-\(\phi\) coordinates, possibly eliminating dimensions with a projection.

to_ptphi() VectorProtocolPlanar#

Converts to \(pt\)-\(\phi\) coordinates, possibly eliminating dimensions with a projection.

to_xyz() VectorProtocolSpatial#

Converts to \(x\)-\(y\)-\(z\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(z\) coordinate can be passed as a named argument.

to_xytheta() VectorProtocolSpatial#

Converts to \(x\)-\(y\)-\(\theta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(theta\) coordinate can be passed as a named argument.

to_xyeta() VectorProtocolSpatial#

Converts to \(x\)-\(y\)-\(\eta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(eta\) coordinate can be passed as a named argument.

to_pxpypz() VectorProtocolSpatial#

Converts to \(px\)-\(py\)-\(pz\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(pz\) coordinate can be passed as a named argument.

to_pxpytheta() VectorProtocolSpatial#

Converts to \(px\)-\(py\)-\(\theta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(theta\) coordinate can be passed as a named argument.

to_pxpyeta() VectorProtocolSpatial#

Converts to \(px\)-\(py\)-\(\eta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(eta\) coordinate can be passed as a named argument.

to_rhophiz() VectorProtocolSpatial#

Converts to \(\rho\)-\(\phi\)-\(z\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(z\) coordinate can be passed as a named argument.

to_rhophitheta() VectorProtocolSpatial#

Converts to \(\rho\)-\(\phi\)-\(\theta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(theta\) coordinate can be passed as a named argument.

to_rhophieta() VectorProtocolSpatial#

Converts to \(\rho\)-\(\phi\)-\(\eta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(eta\) coordinate can be passed as a named argument.

to_ptphipz() VectorProtocolSpatial#

Converts to \(pt\)-\(\phi\)-\(pz\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(pz\) coordinate can be passed as a named argument.

to_ptphitheta() VectorProtocolSpatial#

Converts to \(pt\)-\(\phi\)-\(\theta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(theta\) coordinate can be passed as a named argument.

to_ptphieta() VectorProtocolSpatial#

Converts to \(pt\)-\(\phi\)-\(\eta\) coordinates, possibly eliminating or imputing dimensions with a projection.

The \(eta\) coordinate can be passed as a named argument.

to_xyzt() VectorProtocolLorentz#

Converts to \(x\)-\(y\)-\(z\)-\(t\) coordinates, possibly imputing dimensions with a projection.

The \(z\) and \(t\) coordinates can be passed as a named argument.

to_xyztau() VectorProtocolLorentz#

Converts to \(x\)-\(y\)-\(z\)-\(\tau\) coordinates, possibly imputing dimensions with a projection.

The \(z\) and \(tau\) coordinates can be passed as a named argument.

to_xythetat() VectorProtocolLorentz#

Converts to \(x\)-\(y\)-\(\theta\)-\(t\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(t\) coordinates can be passed as a named argument.

to_xythetatau() VectorProtocolLorentz#

Converts to \(x\)-\(y\)-\(\theta\)-\(\tau\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(tau\) coordinates can be passed as a named argument.

to_xyetat() VectorProtocolLorentz#

Converts to \(x\)-\(y\)-\(\eta\)-\(t\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(t\) coordinates can be passed as a named argument.

to_xyetatau() VectorProtocolLorentz#

Converts to \(x\)-\(y\)-\(\eta\)-\(\tau\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(tau\) coordinates can be passed as a named argument.

to_pxpypzenergy() VectorProtocolLorentz#

Converts to \(px\)-\(py\)-\(pz\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(pz\) and \(energy\) coordinates can be passed as a named argument.

to_pxpythetaenergy() VectorProtocolLorentz#

Converts to \(px\)-\(py\)-\(\theta\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(energy\) coordinates can be passed as a named argument.

to_pxpyetaenergy() VectorProtocolLorentz#

Converts to \(px\)-\(py\)-\(\eta\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(energy\) coordinates can be passed as a named argument.

to_pxpypzmass() VectorProtocolLorentz#

Converts to \(px\)-\(py\)-\(pz\)-\(mass\) coordinates, possibly imputing dimensions with a projection.

The \(pz\) and \(mass\) coordinates can be passed as a named argument.

to_pxpythetamass() VectorProtocolLorentz#

Converts to \(px\)-\(py\)-\(\theta\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(mass\) coordinates can be passed as a named argument.

to_pxpyetamass() VectorProtocolLorentz#

Converts to \(px\)-\(py\)-\(\eta\)-\(mass\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(mass\) coordinates can be passed as a named argument.

to_rhophizt() VectorProtocolLorentz#

Converts to \(\rho\)-\(\phi\)-\(z\)-\(t\) coordinates, possibly imputing dimensions with a projection.

The \(z\) and \(t\) coordinates can be passed as a named argument.

to_rhophiztau() VectorProtocolLorentz#

Converts to \(\rho\)-\(\phi\)-\(z\)-\(\tau\) coordinates, possibly imputing dimensions with a projection.

The \(z\) and \(tau\) coordinates can be passed as a named argument.

to_rhophithetat() VectorProtocolLorentz#

Converts to \(\rho\)-\(\phi\)-\(\theta\)-\(t\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(t\) coordinates can be passed as a named argument.

to_rhophithetatau() VectorProtocolLorentz#

Converts to \(\rho\)-\(\phi\)-\(\theta\)-\(\tau\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(tau\) coordinates can be passed as a named argument.

to_rhophietat() VectorProtocolLorentz#

Converts to \(\rho\)-\(\phi\)-\(\eta\)-\(t\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(t\) coordinates can be passed as a named argument.

to_rhophietatau() VectorProtocolLorentz#

Converts to \(\rho\)-\(\phi\)-\(\eta\)-\(\tau\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(tau\) coordinates can be passed as a named argument.

to_ptphipzenergy() VectorProtocolLorentz#

Converts to \(pt\)-\(\phi\)-\(pz\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(pz\) and \(energy\) coordinates can be passed as a named argument.

to_ptphithetaenergy() VectorProtocolLorentz#

Converts to \(pt\)-\(\phi\)-\(\theta\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(energy\) coordinates can be passed as a named argument.

to_ptphietaenergy() VectorProtocolLorentz#

Converts to \(pt\)-\(\phi\)-\(\eta\)-\(energy\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(energy\) coordinates can be passed as a named argument.

to_ptphipzmass() VectorProtocolLorentz#

Converts to \(pt\)-\(\phi\)-\(pz\)-\(mass\) coordinates, possibly imputing dimensions with a projection.

The \(pz\) and \(mass\) coordinates can be passed as a named argument.

to_ptphithetamass() VectorProtocolLorentz#

Converts to \(pt\)-\(\phi\)-\(\theta\)-\(mass\) coordinates, possibly imputing dimensions with a projection.

The \(theta\) and \(mass\) coordinates can be passed as a named argument.

to_ptphietamass() VectorProtocolLorentz#

Converts to \(pt\)-\(\phi\)-\(\theta\)-\(mass\) coordinates, possibly imputing dimensions with a projection.

The \(eta\) and \(mass\) coordinates can be passed as a named argument.

unit() SameVectorType#

Returns vector(s) normalized to unit length, which is rho == 1 for 2D vectors, mag == 1 for 3D vectors, and tau == 1 for 4D vectors.

dot(other: VectorProtocol) Any#

Vector dot product of self with other.

This method is equivalent to the @ operator.

add(other: VectorProtocol) VectorProtocol#

Sum of self and other.

This method is equivalent to the + operator.

subtract(other: VectorProtocol) VectorProtocol#

Difference of self minus other.

This method is equivalent to the - operator.

scale(factor: Any) SameVectorType#

Returns vector(s) scaled by a factor, changing the length(s) but not the direction(s).

This method is equivalent to the * operator.

equal(other: VectorProtocol) Any#

Returns True if self is exactly equal to other (possibly for arrays of vectors), False otherwise.

This method is equivalent to the == operator.

Typically, you’ll want to check vector._methods.VectorProtocol.isclose() to allow for numerical errors.

not_equal(other: VectorProtocol) Any#

Returns False if self is exactly equal to other (possibly for arrays of vectors), True otherwise.

This method is equivalent to the != operator.

Typically, you’ll want to check vector._methods.VectorProtocol.isclose() to allow for numerical errors.

isclose(other: VectorProtocol, rtol: Any = 1e-05, atol: Any = 1e-08, equal_nan: Any = False) Any#

Returns True if self is approximately equal to other (possibly for arrays of vectors), False otherwise.

The relative tolerance (rtol) and absolute tolerance (atol) are interpreted as in np.isclose:

close_enough = abs(self - other) <= atol + rtol * abs(other)
like(other: VectorProtocol) VectorProtocol#

Projects the vector into the geometric coordinates of the other vector.

Value(s) of \(0\) is/are imputed while transforming vector from a lower geometric dimension to a higher geometric dimension.

vec_4d + vec_3d.like(vec_4d)

For more flexibility (passing new coordinate values), see vector._methods.Vector2D.to_Vector3D(), vector._methods.Vector2D.to_Vector4D(), and vector._methods.Vector3D.to_Vector4D(), which can be used as:

vec_2d.to_Vector3D(z=3.0)
vec_2d.to_Vector4D(z=3.0, t=4.0)
vec_3d.to_Vector4D(t=4.0)