Skip to main content

Hadronic Interaction Model interface in Python

Project description


Cosmic ray and HadROnic interactiOn MOnte-carlo frontend

This package provides a simple and generic user interface to popular event generators used in cosmic ray and high-energy particle physics. By removing the need for complicated Fortran-style interfaces, ASCII input cards, and C++ dependencies, the package simplifies the simulation of particle interactions, making it easier and faster for a wider audience to access.

Usage

Python user interface

To simulate interactions with one of the supported event generators, import the package and define the parameters of the collision. Then, create an instance of an event generator, and generate events.

import numpy as np
import chromo

# Define the parameters of the collisions
kinematics = chromo.kinematics.CenterOfMass(
    13 * chromo.constants.TeV,
    "proton", "proton")
# Create an instance of an event generator
generator = chromo.models.Sibyll23d(kinematics)

nevents = 0
average_pt = 0

# Generate 10000 events
for event in generator(10000):
    # Filter event
    event = event.final_state_charged()
    # do something with event.pid, event.eta, event.en, event.pt, etc.
    # these variables are numpy arrays, that can be histogrammed or counted like
    pt = event.pt[np.abs(event.pid) == 211]
    # The list could be empty
    if len(pt) > 0:
        nevents += 1
        average_pt += np.mean(pt)

average_pt = average_pt / nevents
print("Average pT for charged pions {0:4.3f}".format(average_pt))

Further examples, such as this can be found in the examples folder.

Command line user interface (CLI)

Installing chromo also makes a command-line interface available. If your Python runtime environment is properly set up, you can do

 chromo --help

To see the help of the command-line interface. If that does not work, just replace chromo with python -m chromo. The command-line interface was designed to feel familiar for users of CRMC. The CLI can write events in a variety of output formats, as detailed below. HepMC output can be piped into RIVET and many other tools supporting the format.

Output formats

  • HepMC (via pyhepmc, optionally gzip compressed)
  • ROOT (via uproot)
  • SVG images of events (via pyhepmc package)

Supported models and how to cite them

Please note that chromo only provides a user interface for the following models, and does not contain any particle physics models itself. When using any of these models in public-facing work, it is important to properly cite the original model reference by following the links below. Additionally, if you find chromo useful in your work, we would appreciate an acknowledgement, footnote, or link to chromo.

Interaction model Supported proj/targ Comment
DPMJET-III 3.0.7 & PHOJET 1.12-36 hN, γγ, γN, hA, γA, AA
DPMJET-III & PHOJET 19.1 and 19.3 (repo on GitHub) hN, γγ, γN, hA, γA, AA
EPOS-LHC hN, hA, AA
PYTHIA 6.4 hN, ee, γγ, γN
PYTHIA 8.3 (https://pythia.org/) hN, ee, γγ, γN & hA, AA (Argantyr) unavailable on Windows
QGSJet-01 hN, hA, AA
QGSJet-II-03 hN, hA, AA
QGSJet-II-04 hN, hA, AA
SIBYLL-2.1 hN, hA (A<=20)
SIBYLL-2.3d hN, hA (A<=20) incl. legacy versions -2.3/-2.3c
SOPHIA 2.0 γN
UrQMD 3.4 + second citation hN, hA, AA* unavailable on Windows

h = hadron, N = nucleon (p or n), A = nucleus, γ = photon, e = electron/positron

Installation via PyPI

Supported platforms

  • Python 3.8+
  • Linux, Mac OS X (x86 and M1/M2), Windows

The recommended way to install chromo is by using the pre-compiled binary wheel, which is available for most common architectures and Python versions

pip install chromo

Advanced and developer installation instructions can be found here.

Authors

  • Anatoli Fedynitch
  • Hans Dembinski
  • Anton Prosekin
  • Sonia El Hadri
  • Keito Watanabe

LICENSE

The source code of chromo is licensed under the BSD 3-clause license (see LICENSE for detail). The source codes of the event generators are individually licensed under different conditions (see the COPYING files located in the subdirectories).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chromo-0.5.1.tar.gz (71.3 MB view hashes)

Uploaded Source

Built Distributions

chromo-0.5.1-cp312-cp312-win_amd64.whl (19.8 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

chromo-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.8 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

chromo-0.5.1-cp312-cp312-macosx_11_0_arm64.whl (22.8 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromo-0.5.1-cp312-cp312-macosx_10_9_x86_64.whl (25.5 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

chromo-0.5.1-cp311-cp311-win_amd64.whl (19.8 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

chromo-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.8 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

chromo-0.5.1-cp311-cp311-macosx_11_0_arm64.whl (22.8 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromo-0.5.1-cp311-cp311-macosx_10_9_x86_64.whl (25.5 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

chromo-0.5.1-cp310-cp310-win_amd64.whl (19.8 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

chromo-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

chromo-0.5.1-cp310-cp310-macosx_11_0_arm64.whl (22.8 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromo-0.5.1-cp310-cp310-macosx_10_9_x86_64.whl (25.5 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

chromo-0.5.1-cp39-cp39-win_amd64.whl (19.8 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

chromo-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

chromo-0.5.1-cp39-cp39-macosx_11_0_arm64.whl (22.8 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

chromo-0.5.1-cp39-cp39-macosx_10_9_x86_64.whl (25.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page