Skip to main content

pylorentz

https://gitlab.sauerburger.com/frank/pylorentz/badges/master/pipeline.svg https://gitlab.sauerburger.com/frank/pylorentz/badges/master/coverage.svg https://gitlab.sauerburger.com/frank/pylorentz/-/jobs/artifacts/master/raw/pylint.svg?job=pylint https://gitlab.sauerburger.com/frank/pylorentz/-/jobs/artifacts/master/raw/license.svg?job=badges https://gitlab.sauerburger.com/frank/pylorentz/-/jobs/artifacts/master/raw/pypi.svg?job=pypi https://readthedocs.org/projects/pylorentz/badge/?version=latest&style=flat

The python package pylorentz provides classes to facilitate computations with 4-vectors in high-energy physics.

Quickstart

Install the package using pip

$ pip install git+https://gitlab.sauerburger.com/frank/pylorentz.git

or

$ pip install pylorentz

Properties

The package defines three types of 4-vectors: general purpose vectors, 4-positions and 4-momenta. The working horse of the package are 4-momenta.

>>> from pylorentz import Momentum4
>>> muon = Momentum4.m_eta_phi_pt(0.1057, 4.5, 1.5, 35)
>>> muon.eta
4.5
>>> muon.phi
1.5
>>> muon.p_t
35.0
>>> "%.2f" % muon.p
'1575.49'
>>> "%.2f" % muon.e
'1575.49'

Vectorized Properties

Since version 0.2.0, it is possible to pass numpy arrays to the constructors and operate on multiple vectors at a time.

>>> from pylorentz import Momentum4
>>> import numpy as np
>>> masses = np.array([0.0005, 0.1057, 1.7769])
>>> etas = np.array([1, 2, 3])
>>> phis = np.array([0, 0, 0])
>>> pts = np.array([10, 10, 10])
>>> muon = Momentum4.m_eta_phi_pt(masses, etas, phis, pts)
>>> ["%.2f" % m for m in muon.e]
['15.43', '37.62', '100.69']

Arithmetics

4-vectors support a variety of arithmetic operations. The most important one is the addition of two vectors.

>>> from pylorentz import Momentum4
>>> tau_1 = Momentum4.m_eta_phi_pt(1.777, 4.5, 1.5, 35)
>>> tau_2 = Momentum4.m_eta_phi_pt(1.777, -4.5, 1.5, 35)

We can add the momenta of the two tau leptons and access the properties of the parent particle.

>>> parent = tau_1 + tau_2
>>> "%.2f" % parent.m
'3150.21'
>>> "%.2f" % parent.eta
'0.00'
>>> "%.2f" % parent.phi
'1.50'

Lorentz Boosts

The package also provides methods to perform Lorentz boosts. For example, consider the decay of a Higgs boson to a pair of tau leptons in the rest frame of the Higgs boson. The tau leptons are back-to-back in the y-z-plane.

>>> import math
>>> from pylorentz import Momentum4
>>> m = 125.0
>>> tau_1 = Momentum4.e_m_eta_phi(m / 2, 1.777, 1.5, math.pi / 2)
>>> tau_2 = Momentum4.e_m_eta_phi(m / 2, 1.777, -1.5, -math.pi / 2)

Now let’s assume the Higgs boson itself is not at rest. We can define its momentum and then boost the two tau leptons.

>>> higgs = Momentum4.m_eta_phi_pt(m, 2, 0, 250)
>>> tau_1.boost_particle(higgs)
Momentum4(884.599, 220.498, 26.5578, 856.264)
>>> tau_2.boost_particle(higgs)
Momentum4(64.2195, 29.5021, -26.5578, 50.451)

Metadata

Release files for pylorentz 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylorentz 0.3.3
File Size Uploaded Provenance
pylorentz-0.3.3.tar.gz 12.3 kB Without provenance Details

Release files / pylorentz-0.3.3.tar.gz

Download URL pylorentz-0.3.3.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4dcc3716d1f858e39acd637ff9333352142a9abf968e3451a9759dd66b2c5da6
BLAKE2b-256 checksum
How to use checksums
faa1b041ae7869614f94f832c4d3ef851d3fef35a353b5213326434f660101e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

Security for pylorentz 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page