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
contributions by Rene Brun, Andreas Morsch and Axel Naumann.
Another example may be found in the
VINCIA
add-on program for parton showers, but this should also work for
a PYTHIA standalone run.
Histogramming with ROOT
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, or for storing generated
events as ROOT trees. This is illustrated in the rootexamples
subdirectory.
The files there are
README
explains how to link PYTHIA and ROOT, and run the
example main programs.
Makefile
is used to build the two examples below,
and to build a dictionary.
hist.cc
is an example main program how ROOT can be used
for histogramming without any direct link between PYTHIA and ROOT.
tree.cc
is an example main program how PYTHIA events
can be stored as ROOT trees.
pythiaLinkdef.h
is used by Makefile to generate the
dictionary for all PYTHIA classes involved in the IO, as needed for the
tree example above.
pythiaROOT.h
is a small include declaring the
Pythia8
namespace as default.
Interfaces
In more ROOT-centric applications, PYTHIA can be run as a ROOT plug-in.
Here the interface structure becomes very relevant. 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
).
-
TPythia8
is an implementation of the
TGenerator
interface for PYTHIA 8.
It allows you to use PYTHIA within a ROOT macro or as a plug-in
for a general-purpose particle generator based on this interface. The
main methods of the interface are
* TPythia8::GenerateEvent()
which triggers the generation
of the next event, and
* TPythia8::ImportParticles(TClonesArray* particles)
which copies the native PYTHIA stack into a
TClonesArray
of
TParticles
.
In addition, we implemented some methods that are directly related
to corresponding PYTHIA methods:
* ReadString(const char* string) -> readString(...)
* ReadConfigFile(const char* string) -> readFile(...)
* Initialize(int idAin, int idBin, double ecms) -> init(...)
* EventListing() -> event.list()
* PrintStatistic() -> statistics()
These methods provide already the basic PYTHIA functionality
interactively from the ROOT command line. However, this does not mean
that the usage of PYTHIA from within ROOT is restricted to these methods.
In compiled code, one can always obtain a pointer to the
Pythia
instance via
Pythia8::Pythia* pythia8 = TPythia8::Pythia8();
giving access to the full PYTHIA functionality.
-
TPythia8Decayer
is an implementation of the
TVirtualMCDecayer
interface.
It allows you to use PYTHIA as a plug-in decayer for simulation
frameworks based on the Virtual Monte Carlo
(VMC) interface
classes. The main methods of the interface are
* TPythia8Decayer::Init()
for initialisation,
* TPythia8Decayer::Decay(Int_t pdg, TLorentzVector*< p)
to decay a particle with PDG code pdg
and
4-momentum p
, and
* ImportParticles(TClonesArray* particles)
to retrieve the decay products as
TParticles
in the
TClonesArray particles
.
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
- the environment variable
PYTHIA8
must point to the
pythia8150
(or newer) installation directory, and
- the environment variable
PYTHIA8DATA
must be defined
and it must point to $PYTHIA8/xmldoc
.
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