Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (44 sloc) 2.23 KB


A Python wrapper for the HepMC3 C++ library.

PyPI version Build Status

Another wrapper is pyhepmc. Why should you use this one?

pyhepmc-ng is easy to install

The command pip install pyhepmc-ng just works! You only need a compiler that supports C++14, everything else is handled by pip.

Under the hood, the bindings are build with the excellent pybind11 library. pybind11 is automatically installed as a requirement by pip. You don't need an external installation of the HepMC3 library, either. A copy of this light-weight library is included.

pyhepmc-ng is actively developed

pyhepmc-ng is part of the Scikit-HEP project, which aims to provide all tools needed by particle physicists to do data analysis in Python.

pyhepmc-ng is unit tested

Everything in pyhepmc-ng is unit tested.

pyhepmc-ng supports Pythonic code

pyhepmc-ng is a hand-crafted mapping of C++ code to Python. It supports Python idioms where appropriate.

  • C++ methods which act like properties are represented as properties, e.g. GenParticle::set_status and GenParticle::status are mapped to a single GenParticle.status field in Python
  • Tuples and lists are implicitly convertible to FourVectors
  • ReaderAscii and WriterAscii support the context manager protocol

For developers

If you want to play with the source code, clone this repository and start hacking.

Local installation for testing

python build_ext -i

If you are on Linux or OSX, you can alternatively do (and save a bit of typing)


User-wide installation

python install --user

Running the tests requires pytest. Do

pytest tests

or simply

make test


pyhepmc-ng is covered by the BSD 3-clause license, but the license only applies to the binding code. The HepMC3 code is covered by the GPL-v3 license.

The BSD 3-clause license text can be found in the LICENSE file.

The HepMC3 code is covered by the GPL-v3 license, which can be found in src/HepMC3/LICENSE.

You can’t perform that action at this time.