PYTHIA
PYTHIA is a program for the generation of high-energy physics collision events, i.e. for the description of collisions at high energies between electrons, protons, photons and heavy nuclei. It contains theory and models for a number of physics aspects, including hard and soft interactions, parton distributions, initial- and final-state parton showers, multiparton interactions, fragmentation and decay. It is largely based on original research, but also borrows many formulae and other knowledge from the literature. As such it is categorized as a general purpose Monte Carlo event generator.
Installation
The PYTHIA package is natively written in C++, which is the preferred interface. To work with PYTHIA via C++ go to the PYTHIA homepage and follow the instructions outlined there. The Python interface to PYTHIA can be installed directly via pip
. Note that for this PyPI distribution of PYTHIA, the module name has been changed from pythia8
to pythia8mc
as the pythia8
project name was unavailable. Outside of the PyPI distribution, the pythia8
module name is always used.
pip install pythia8mc
The interface is also available via conda
.
conda install -c conda-forge pythia8
It is possible, and in many ways preferable, to build the Python interface directly from the PYTHIA C++ distribution (as well as update the Python bindings) using the configuration script.
wget https://pythia.org/download/pythia83/pythia8XXX.tgz
tar xvfz pythia8XXX.tgz
cd pythia8XXX
./configure --with-python
make
Usage
For a full description of usage, as well as examples, see the accompanying HTML manual for this version of PYTHIA.
The following imports the pythia8mc
module and creates a Pythia
instance.
import pythia8mc
pythia = pythia8mc.Pythia()
PYTHIA must then be configured and initialized, in this example to produce minimum bias events at the LHC.
pythia.readString("SoftQCD:all = on"
pythia.init()
Finally, we can produce an event, and explore the event record.
pythia.next()
for prt in pythia.event: print(prt.name())
Paths
PYTHIA requires the XML files which are used to build the HTML manual to define settings. Additionally, settings files for tunes are also distributed with PYTHIA. For the PyPI distribution, these files can be found along the relative path,
../../../share/Pythia8/xmldoc
with respect to the pythia8mc
module library. By default, this path should be correctly set, but it can be printed as follows.
print(pythia8mc.__file__.rstrip("pythia8mc.so") + "../../../share/Pythia8/xmldoc")
The settings directory can be found in ../settings/
with respect to this folder. However, it is possible to overwrite the XML path by setting the environment variable PYTHIA8DATA
,
export PYTHIA8DATA=<PYTHIA XML path>
or by passing the XML path to the Pythia
constructor.
pythia8mc.Pythia("<PYTHIA XML path>")