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
).
-
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
pythia8100
(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
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
ex1.C
is the small main program writing the Tree.
goex1
is a small script that
a) generates the dictionary for all PYTHIA classes involved in the IO
(first line; note that you only need to execute it once); and
b) links the ex1
executable with the relevant libs.
pythiaLinkdef.h
is the input file indicating to rootcint
which PYTHIA classes to process.
pythiaROOT.h
is a small include declaring Pythia8
namespace as default.