The interface between PYTHIA and NumPy
Project description
numpythia provides an interface between PYTHIA and NumPy allowing you to generate events as NumPy arrays of particle four-momenta. By default numpythia only depends on NumPy and builds internal copies of the PYTHIA and HepMC source code.
Standalone Installation
To simply use the built-in PYTHIA and HepMC:
pip install -v numpythia
And you’re good to go!
Support for building against an external PYTHIA is on the wishlist.
Strict dependencies
Getting started
from numpythia import Pythia, hepmc_write, hepmc_read
from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID
from numpythia.testcmnd import get_cmnd
from numpy.testing import assert_array_equal
pythia = Pythia(get_cmnd('w'), random_state=1)
selection = ((STATUS == 1) & ~HAS_END_VERTEX &
(ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))
# generate events while writing to ascii hepmc
for event in hepmc_write('events.hepmc', pythia(events=1)):
array1 = event.all(selection)
# read the same event back from ascii hepmc
for event in hepmc_read('events.hepmc'):
array2 = event.all(selection)
assert_array_equal(array1, array2)
The dtype of any array of particle information is:
np.dtype([('E', 'f8'), ('px', 'f8'), ('py', 'f8'), ('pz', 'f8'), ('mass', 'f8'),
('prodx', 'f8'), ('prody', 'f8'), ('prodz', 'f8'), ('prodt', 'f8'),
('pdgid', 'i4'), ('status', 'i4')])
Also see pyjet for jet clustering.
Tutorial
PYTHIA settings can be passed in one of three ways: through the **kwargs arguments of the constructor Pythia(…, **kwargs):
pythia = Pythia(..., Beams_eCM=13000.)
Or as a dictionary:
pythia = Pythia(..., params={'Beams:eCM': 13000.})
Or via a Python command file:
pythia = Pythia(config='path/to/config.cmd')
The full list of settings can be found on the PYTHIA homepage.
Note that the “:” in settings names is replaced by a “_” if using kwargs. kwargs take precedence over params and they both take precedence over config. Example config files can be found under the numpythia.testcmnd directory.
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
File details
Details for the file numpythia-1.0.1.tar.gz
.
File metadata
- Download URL: numpythia-1.0.1.tar.gz
- Upload date:
- Size: 6.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3fc4eb56efe713b0f354a6e88c420da6057840c5a66b3755aa2fd00fa3d7001 |
|
MD5 | 015be9eaf4282e9cd04999b1f1e4e62f |
|
BLAKE2b-256 | 1d52dcb5906ea8a318e549e11ccc052cb3866531caf7311257dfdc8104a70b08 |