A small package to get structured data out of Les Houches Event files
Project description
pylhe: A Lightweight Python interface to Les Houches Event files
Small and thin Python interface to read Les Houches Event (LHE) files
Tested Monte Carlo Generators' LHE output
| Generator | Tested Versions |
|---|---|
| MadGraph5 | 2.0.0, 2.2.1, 3.5.8 |
| POWHEG-BOX-V2 | r4027 |
| Pythia | 6.413, 8.3.14 |
| Sherpa | 3.0.1 |
| Whizard | 3.1.4 |
Note: test files are provided via the scikit-hep-testdata package. Please open an issue of create directly a PR for the inclusion of new files for testing.
Install
To install pylhe from PyPI you can just do
python -m pip install pylhe
The visualization capabilities require the external dependency of Graphviz.
Get started
The example below provides a simple overview.
Full functionality can be inspected from the functions provided in the pylhe module.
For more information about the LHE format, see the LHE format documentation.
Reading
import itertools
# You can use LHE files from scikit-hep-testdata
from skhep_testdata import data_path
import pylhe
lhe_file = data_path("pylhe-testlhef3.lhe")
events = pylhe.LHEFile.fromfile(lhe_file).events
print(f"Number of events: {pylhe.LHEFile.count_events(lhe_file)}")
# Get event 1
event = next(itertools.islice(events, 1, 2))
# A DOT language graph of the event can be inspected as follows
print(event.graph.source)
# The graph is nicely displayed as SVG in Jupyter notebooks
event
# To save a DOT graph render the graph to a supported image format
# (refer to the Graphviz documentation for more)
event.graph.render(filename="test", format="png", cleanup=True)
event.graph.render(filename="test", format="pdf", cleanup=True)
Writing
For a full example see write or filter.
The values in the sketch below are intentionally left empty since they depend on the use-case.
The data structure of pylhe is:
import pylhe
file = pylhe.LHEFile(
init=pylhe.LHEInit(
initInfo=pylhe.LHEInitInfo(
beamA=...,
beamB=...,
energyA=...,
energyB=...,
PDFgroupA=...,
PDFgroupB=...,
PDFsetA=...,
PDFsetB=...,
weightinStrategy=...,
numProcesses=...,
),
procInfo=pylhe.LHEProcInfo(
xSection=...,
error=...,
unitWeight=...,
procId=...,
),
),
events=[
pylhe.LHEEvent(
eventinfo=pylhe.LHEEventInfo(
nparticles=...,
pid=...,
weight=...,
scale=...,
aqed=...,
aqcd=...,
),
particles=[
pylhe.LHEParticle(
id=...,
status=...,
mother1=...,
mother2=...,
color1=...,
color2=...,
px=...,
py=...,
pz=...,
e=...,
m=...,
lifetime=...,
spin=...,
),
],
weights=None,
attributes=None,
optional=None,
),
],
)
# write to file, compressed if gz/gzip suffix
write_lhe_file(file.init, file.events, "myevents.lhe.gz", rwgt=True, weights=False)
Citation
The preferred BibTeX entry for citation of pylhe is
@software{pylhe,
author = {Lukas Heinrich and Matthew Feickert and Eduardo Rodrigues and Alexander Puck Neuwirth},
title = "{pylhe: v1.0.2}",
version = {v1.0.2},
doi = {10.5281/zenodo.1217031},
url = {https://github.com/scikit-hep/pylhe},
}
pylhe has been referenced in:
- Flow Annealed Importance Sampling Bootstrap meets Differentiable Particle Physics (2024)
- Interference effects in resonant di-Higgs production at the LHC in the Higgs singlet extension (2024)
- Search for nearly degenerate higgsinos via photon fusion with the semileptonic channel at the LHC (2024)
- Strategy to measure tau via photon fusion in LHC proton collisions (2024)
- Probing dark photons from a light scalar at Belle II (2024)
- Constraints on the trilinear and quartic Higgs couplings from triple Higgs production at the LHC and beyond (2023)
- BSM reach of four-top production at the LHC (2023)
- Probing compressed higgsinos with forward protons at the LHC (2023)
- FLArE up dark sectors with EM form factors at the LHC Forward Physics Facility (2022)
- Probing Neutrino-Portal Dark Matter at the Forward Physics Facility (2021)
- Looking forward to test the KOTO anomaly with FASER (2020)
- Probing Light Gauge Bosons in Tau Neutrino Experiments (2020)
- Benchmarking simplified template cross sections in WH production (2019)
- MadMiner: Machine learning-based inference for particle physics (2019)
- Search Strategy for Sleptons and Dark Matter Using the LHC as a Photon Collider (2018)
Contributors
We hereby acknowledge the contributors that made this project possible (emoji key):
This project follows the all-contributors specification.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylhe-1.0.2.tar.gz.
File metadata
- Download URL: pylhe-1.0.2.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28d49a82d01af071b5f97024533b89ad055d4374f96af2473f8d409dabbd6462
|
|
| MD5 |
2c830f6a447942b323724b1c98fb967b
|
|
| BLAKE2b-256 |
aaef20b7bae019839ae9cb07b35e624ba4eff033247c5ca9c81b6f650c9036df
|
Provenance
The following attestation bundles were made for pylhe-1.0.2.tar.gz:
Publisher:
publish-package.yml on scikit-hep/pylhe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylhe-1.0.2.tar.gz -
Subject digest:
28d49a82d01af071b5f97024533b89ad055d4374f96af2473f8d409dabbd6462 - Sigstore transparency entry: 764328909
- Sigstore integration time:
-
Permalink:
scikit-hep/pylhe@740ab69b8fea82bdd9df6ad6cec879cb697875d9 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/scikit-hep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@740ab69b8fea82bdd9df6ad6cec879cb697875d9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pylhe-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pylhe-1.0.2-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acc0e74fc58ef967402f8f39eea9353761dd32f34365163f4f1a8a8c80acd40d
|
|
| MD5 |
77d98be657320fec73ee4cc50a4f884e
|
|
| BLAKE2b-256 |
81fa60af542e82803216e2ec89ad5cc6bf73c35e0afcf07af24a530f7e94651d
|
Provenance
The following attestation bundles were made for pylhe-1.0.2-py3-none-any.whl:
Publisher:
publish-package.yml on scikit-hep/pylhe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylhe-1.0.2-py3-none-any.whl -
Subject digest:
acc0e74fc58ef967402f8f39eea9353761dd32f34365163f4f1a8a8c80acd40d - Sigstore transparency entry: 764328913
- Sigstore integration time:
-
Permalink:
scikit-hep/pylhe@740ab69b8fea82bdd9df6ad6cec879cb697875d9 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/scikit-hep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@740ab69b8fea82bdd9df6ad6cec879cb697875d9 -
Trigger Event:
release
-
Statement type: