ROOT usage

Many PYTHIA users wish to use ROOT to produce histograms, or even to run PYTHIA as a plugin to ROOT. This is possible. It is not a task supported by the PYTHIA team, however. All issues involving ROOT usage should be directed to the ROOT team, or to the local support team of your collaboration. Below some helpful hints have been collected. The text is based on a contribution by Andreas Morsch, and the second example is provided by Rene Brun. Another example may be found in the VINCIA add-on program for parton showers, but this should also work for a PYTHIA standalone run.

Interfaces

ROOT provides two simple interfaces (wrappers) for PYTHIA 8. Both are located in the
    yourROOTinstallationPath/montecarlo/pythia8
directory. (Type which root if you want to find out where ROOT has been installed. It will print yourROOTinstallationPath/bin/root).

Installation of ROOT with PYTHIA 8 support

In order to use PYTHIA 8 with ROOT you need a ROOT version that has been installed from source. The reason is that the interfaces depend on PYTHIA header files that are not distributed with ROOT. Installing ROOT is not more difficult than the PYTHIA installation.

Define an environment variable for the path to your pythia8 installation directory

    export PYTHIA8=YourPathToPythia8
Before compiling ROOT configure ROOT running the yourROOTinstallationPath/configure command including the following options:
    --enable-pythia8 
    --with-pythia8-incdir=$PYTHIA8/include 
    --with-pythia8-libdir=$PYTHIA8/lib
In case ROOT has already been compiled before, it will only recompile the pythia8 module and build the library libEGPythia8.

An example

A basic example for generating minimum-bias events with PYTHIA 8 inside a ROOT macro, and filling some histograms with the kinematics of the final-state particles is provided in
    yourROOTinstallationDirectory/tutorials/pythia/pythia8.C
Note that before executing this script

Looking at the example code you will see that it is necessary to load three libraries before running the actual code:

    gSystem->Load("$PYTHIA8/lib/libpythia8"); // Pythia 8
    gSystem->Load("libEG"); // The library with the TGenerator interface
    gSystem->Load("libEGPythia8"); // The TPythia8 implementation

A second example

It is not necessary to run PYTHIA as a ROOT plug-in. One can also perform the generation and analysis of events in a completely standalone fashion, and only use ROOT for the histogramming step. One example, with a lightly modified version of main01.cc, is available in the rootexample subdirectory.

Here