A Python wrapper for the HepMC3 C++ library.
Another wrapper is pyhepmc. Why should you use this one?
pyhepmc-ng is easy to install
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
If you want to play with the source code, clone this repository and start hacking.
Local installation for testing
python setup.py build_ext -i
If you are on Linux or OSX, you can alternatively do (and save a bit of typing)
python setup.py install --user
Running the tests requires
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
The HepMC3 code is covered by the GPL-v3 license, which can be found in