TwoVector

class coffea.nanoevents.methods.vector.TwoVector[source]

Bases: object

A cartesian 2-dimensional vector

A heavy emphasis towards a momentum vector interpretation is assumed, hence properties like px and py are provided in addition to x and y.

This mixin class requires the parent class to provide items x and y.

Attributes Summary

phi

Polar angle relative to X axis

pt

Alias for r

pt2

Alias for r2

px

Alias for x

py

Alias for y

r

Distance from origin in XY plane

r2

Squared r

unit

Unit vector, a vector of length 1 pointing in the same direction

Methods Summary

absolute()

Returns magnitude of the 2D vector

add(other)

Add two vectors together elementwise using x and y components

delta_phi(other)

Compute difference in angle between two vectors

divide(other)

Divide this vector by a scalar elementwise using its cartesian components

dot(other)

Compute the dot product of two vectors

multiply(other)

Multiply this vector by a scalar elementwise using x and y components

negative()

Returns the negative of the vector

subtract(other)

Subtract a vector from another elementwise using x and y components

sum([axis])

Sum an array of vectors elementwise using x and y components

Attributes Documentation

phi

Polar angle relative to X axis

\(\text{arctan2}(y, x)\)

pt

Alias for r

pt2

Alias for r2

px

Alias for x

py

Alias for y

r

Distance from origin in XY plane

\(\sqrt{x^2+y^2}\)

r2

Squared r

unit

Unit vector, a vector of length 1 pointing in the same direction

Methods Documentation

absolute()[source]

Returns magnitude of the 2D vector

Alias for r

add(other)[source]

Add two vectors together elementwise using x and y components

delta_phi(other)[source]

Compute difference in angle between two vectors

Returns a value within [-pi, pi)

divide(other)[source]

Divide this vector by a scalar elementwise using its cartesian components

This is realized by using the multiplication functionality

dot(other)[source]

Compute the dot product of two vectors

multiply(other)[source]

Multiply this vector by a scalar elementwise using x and y components

negative()[source]

Returns the negative of the vector

subtract(other)[source]

Subtract a vector from another elementwise using x and y components

sum(axis=-1)[source]

Sum an array of vectors elementwise using x and y components