Elena Graverini

Install Pythia

Not all versions of Pythia are compatible with every version of ROOT. In my case, I wanted to use Pythia8 from ROOT’s command line (i.e. its interpreter “cling”, “cint” for older versions). To accomplish this it is necessary to create a dictionary that will serve as an interface between ROOT and Pythia. I only managed to get it working using the pair ROOT 5.99/05 — Pythia8 180.

The steps to get this working are basically three: get pythia, recompile root, build the dictionary.

1) Get Pythia

Download and untar a specific release from http://home.thep.lu.se/~torbjorn/Pythia.html:
wget http://home.thep.lu.se/~torbjorn/pythia8/pythia8180.tgz
tar xvfz pythia8180.tgz
cd pythia8180
Use the -fPIC configure flag only on 64bit systems:
./configure --enable-shared -fPIC
Note: for more recent versions of Pythia (e.g. 8230) -fPIC is replaced by –enable-64bit!
Find out the number N of cores of your machine.
make -j N
Setup the environment:
echo "export PYTHIA8=$PWD" >> $HOME/.bashrc
echo "export PYTHIA8DATA=$PYTHIA8/xmldoc" >> $HOME/.bashrc
sudo ldconfig
source $HOME/.bashrc

2) Recompile ROOT:

Follow the steps on this page to install ROOT 5.99/05.
cd $ROOTSYS
I also had to enable the GSL libraries, so:
./configure --all --with-gsl-incdir="/usr/local/include/gsl" --with-gsl-libdir="/usr/local/lib" --enable-pythia8 --with-pythia8-incdir=$PYTHIA8/include --with-pythia8-libdir=$PYTHIA8/lib
otherwise leave out the gsl configuration flags.
make -j N

3) Build the Pythia8 dictionary:

cd $PYTHIA8
mkdir PythiaDict && cd PythiaDict
Download the following files:
wget https://www.graverini.net/elena/content/repo/pythiaROOT.h
wget https://www.graverini.net/elena/content/repo/pythiaLinkdef.h
Build the dictionary:
rootcint -f pythiaDict.cxx -c -I$PYTHIA8/include pythiaROOT.h pythiaLinkdef.h
g++ -I$PYTHIA8/include `root-config --glibs` `root-config --cflags` -shared -fPIC -o pythiaDict.so pythiaDict.cxx
Now open the folder where you wish to work and create a rootlogon.C file (a macro that will be executed every time you start ROOT):
cd path/to/my/work/folder
gedit rootlogon.C
Enter:

{
    gSystem->Load("$PYTHIA8/lib/libpythia8");
    gSystem->Load("libEG");
    gSystem->Load("libEGPythia8");
    gSystem->Load("$PYTHIA8/PythiaDict/pythiaDict.so");
}

Save and exit.
Now try to use it:
root -l
.x $ROOTSYS/tutorials/pythia/pithia8.C
or
TPythia8 *tpy = new TPythia8()
Pythia8::Pythia *p = tpy->Pythia8()