Python package for seamless handling of Lorentz vectors
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mohamed Elashri 2788240db1
Merge pull request #27 from MohamedElashri/release/0.3.3
Fix signed-mass cancellation boundaries for v0.3.3
2026-11-05 03:50:56 +01:00
.github Prepare 0.3.1 and refresh project examples 2026-11-02 12:23:49 +01:00
benchmarks Fix signed-mass cancellation boundaries for v0.3.3 2026-11-05 03:46:30 +01:00
docs Fix signed-mass cancellation boundaries for v0.3.3 2026-11-05 03:46:30 +01:00
examples Prepare 0.3.1 and refresh project examples 2026-11-02 12:23:49 +01:00
lvec Fix signed-mass cancellation boundaries for v0.3.3 2026-11-05 03:46:30 +01:00
.gitignore Rebuild benchmark framework and document reproducible results 2026-11-01 20:38:09 +01:00
.sanad.toml Lock Actions with Sanad and add Python 3.15 CI (#13) 2026-11-01 14:45:05 +01:00
CITATION.cff Fix signed-mass cancellation boundaries for v0.3.3 2026-11-05 03:46:30 +01:00
CONTRIBUTING.md Fix near-null kinematics and prepare v0.3.2 2026-11-04 00:27:38 +01:00
hatch_build.py Fix subnormal boosts and finish post-merge kernel checks 2026-11-02 01:54:29 +01:00
LICENSE Modernize the package build structure and add GPLv3 licence file. 2024-12-10 09:00:38 -05:00
pyproject.toml Fix signed-mass cancellation boundaries for v0.3.3 2026-11-05 03:46:30 +01:00
README.md Complete dimensional API references and backend documentation 2026-11-02 11:14:28 +01:00
requirements.txt Make Awkward optional and correct Lorentz-vector physics conventions (#7) 2026-11-01 13:35:38 +01:00
user-guide.md Prepare 0.3.0 and fix documentation math rendering 2026-11-02 03:28:15 +01:00

LVec

CI PyPI

Lorentz vectors for particle physics with NumPy and Awkward Array.

Reconstruct invariant masses, select particles, transform reference frames, and calculate decay angles on scalars, dense arrays, or jagged event data. LVec also provides two- and three-dimensional spatial vectors.

Install

Requires Python 3.10 or later and NumPy 2.2.4 or later. Jagged collections additionally require Awkward 2.7.4 or later.

python -m pip install lvec
python -m pip install "lvec[awkward]"  # for jagged event data

Reconstruct a two-particle system

Use consistent energy and momentum units, with c=1 and metric (+,-,-,-).

from lvec import LVec

daughter1 = LVec(px=3., py=0., pz=0., E=5.)
daughter2 = LVec(px=0., py=4., pz=0., E=5.)
parent = daughter1 + daughter2

print(f"Pair mass: {parent.mass:.3f}")  # Pair mass: 8.660
daughter1_cm = daughter1.boost_to_rest(parent)

The same operations act elementwise on arrays. Components are independent, read-only float64 snapshots, so editing an input array cannot change a vector. Use validate=True when constructing physical particle momenta. For event samples, start with jagged events and reductions.

Documentation

The LVec manual provides searchable tutorials, physics conventions, and API reference pages. Sources can also be read here:

Start here Contents
Tutorials Scalars, NumPy arrays, jagged events, particle combinations, and rest frames
Physics guide Coordinates, invariant mass, event selections, rest frames, decay angles, and numerical conventions
API reference Complete 2D, 3D, 4D, and frame interfaces, including aliases and coordinate conversions
Migrating from vector Familiar interfaces and scientific differences to check
Benchmarks Representative measurements, ownership boundaries, and reproduction
Contributing Testing, numerical bug reports, and releases

Citation

Please cite LVec using CITATION.cff.

Licence

LVec is licensed under the GNU General Public License v3.