Pythia class should
be used in the user-supplied main program, further outlined in the
following. Since the nature of the run is defined at the initialization
stage, this is where most of the PYTHIA user code has to be written.
So as not to confuse the reader unduly, the description of initialization
options has been subdivided into what would normally be used and what is
intended for more special applications.
At the bottom of this webpage is a complete survey of all public
Pythia methods and data members, in a more formal style
than the task-oriented descriptions found in the preceding sections.
This offers complementary information.
#include "Pythia8/Pythia.h"
To simplify typing, it also makes sense to declare
using namespace Pythia8;
Pythia pythia;
It is this object that we will use from now on. Normally a run
will only contain one Pythia object. (But you can
use several Pythia objects, which then will be
independent of each other.)Pythia will be on the
cout stream, but a few methods do
allow output to alternative streams or files.
Pythia constructor. The default values can then be
changed, primarily by one of the two ways below, or by a combination
of them.
a) You can use the
pythia.readString(string);
method repeatedly to do a change of a property at a time.
The information in the string is case-insensitive, but upper- and
lowercase can be combined for clarity. The rules are thatpythia.settings.readString(string);pythia.particleData.readString(string);
pythia.readString("TimeShower:pTmin = 1.0");
pythia.readString("111:mayDecay = false");
The readString(string) method is intended primarily for
a few changes. It can also be useful if you want to construct a
parser for input files that contain commands both to PYTHIA and to
other libraries.
pythia.readFile(fileName);
Each line in this file with be processes by the
readString(string) method introduced above. You can thus
freely mix comment lines and lines handed on to Settings
or to ParticleData.readString(string), and can also avoid having to
recompile and relink your main program between runs.istream, by
default cin, rather than from a file. This may be convenient
if information is generated on-the-fly, within the same run.
Changes are made sequentially in the order the commands are encountered
during execution, meaning that if a parameter is changed several times
it is the last one that counts. The two special
Tune:ee and
Tune:pp
modes are expanded to change several settings in one go, but these obey
the same ordering rules.
pythia.init();Settings
and ParticleData
databases. Specifically the setup of incoming beams and energies
is governed by the the beam parameters from the
Beams
group of variables. If you don't change any of those you will
default to proton-proton collisions at 14 TeV, i.e. the nominal LHC
values.
pythia.settings.listChanged();
pythia.settings.listAll();
pythia.particleData.listChanged();
pythia.particleData.listAll();
next() method,
pythia.next();
This method takes no arguments; everything has already been specified.
It does return a bool value, however, false when the
generation failed. This can be a "programmed death" when the
supply of input parton-level configurations on file is exhausted.
It can alternatively signal a failure of Pythia to
generate an event, or unphysical features in the event record at the
end of the generation step. It makes sense to allow a few false
values before a run is aborted, so long as the related faulty
events are skipped.
event
object, of type Event,
which is a public member of pythia. You therefore have
access to all the tools described on the pages under the "Study Output"
header in the index. For instance, an event can be listed with
pythia.event.list(), the identity of the i'th
particle is given by
pythia.event[i].id(), and so on.process, also of type Event.info, which offers
a set of one-of-a kind pieces of information about the most recent
event.
pythia.stat();
to get some run statistics, on cross sections and the number of errors
and warnings encountered.
examples subdirectory. However, in the
general case, you must provide the path of the xmldoc
directory, where default settings and particle data are found.
This can be done in several ways.
PYTHIA8DATA to
contain the location of the xmldoc directory. In the
csh and tcsh shells this could e.g. be
setenv PYTHIA8DATA /home/myname/pythia82xx/share/Pythia8/xmldoc
while in other shells it could be
export PYTHIA8DATA=/home/myname/pythia82xx/share/Pythia8/xmldoc
where xx is the subversion number..cshrc and .bashrc files, respectively,
if you want a more permanent assignment.
Pythia
constructor, e.g.
Pythia pythia("/home/myname/pythia82xx/share/Pythia8/xmldoc");
where again xx is the subversion number.PYTHIA8DATA is set it takes precedence, else
the path in the constructor is used, else one defaults to the
../share/Pythia8/xmldoc directory.
Pythia(Settings& settingsIn, ParticleData& particleDataIn);
Pythia(istream& settingsStrings, istream& particleDataStrings);
pythia.init() call.
setPDFPtr(...) method
pythia.setPDFptr( pdfAPtr, pdfBPtr);
where pdfAPtr and pdfBPtr are pointers to
two Pythia PDF
objects. Note that pdfAPtr and pdfBPtr
cannot point to the same object; even if the PDF set is the same,
two copies are needed to keep track of two separate sets of x
and density values.
pythia.setPDFptr( pdfAPtr, pdfBPtr, pdfHardAPtr, pdfHardBPtr);
allows you to specify those separately, and then the first two sets
would only be used for the showers and for multiparton interactions.setLHAupPtr(...)
method
pythia.setLHAupPtr( lhaUpPtr);
where the lhaUpPtr derives from the
LHAup base class.
setDecayPtr(...)
method
pythia.setDecayPtr( decayHandlePtr, particles);
where the decayHandlePtr derives from the
DecayHandler base
class and particles is a vector of particle codes to be
handled.
setRndmEnginePtr(...) method
pythia.setRndmEnginePtr( rndmEnginePtr);
where rndmEnginePtr derives from the
RndmEngine base class.
The Pythia default random number generator is perfectly
good, so this is only intended for consistency in bigger frameworks.
pythia.setUserHooksPtr( userHooksPtr);
where userHooksPtr derives from the
UserHooks base class.
pythia.setMergingHooksPtr( mergingHooksPtr);
where mergingHooksPtr derives from the
MergingHooks base class.
pythia.setBeamShapePtr( beamShapePtr);
where beamShapePtr derives from the
BeamShape base class.
pythia.addSigmaPtr( sigmaPtr );
or, optionally,
pythia.addSigmaPtr( sigmaPtr, phaseSpacePtr );
where sigmaPtr is a shared pointer of type
SigmaProcess and phaseSpacePtr is a shared
pointer of type PhaseSpace. When only the cross-section
expression is provided, the built-in phase-space selection machinery
will be used. Then sigmaPtr must be an instance of a
class derived from one of the Sigma1Process,
Sigma2Process and Sigma3Process classes for
1-, 2- and 3- particle production, in their turn derived from
SigmaProcess.
When you supply your own phase-space generator there is no fundamental
limit on the complexity of the process. This call can be used
repeatedly to hand in several different processes, mixing ones with
and without their own phase-space generators. To reset the user provided
cross sections to a single cross section, the
setSigmaPtr method can be called, using the same
arguments as addSigmaPtr.
pythia.addResonancePtr( resonancePtr);
where resonancePtr is a shared pointer of type
ResonanceWidths, and is an instance of a class derived
from the
ResonanceWidths base
class. In addition you need to add the particle to the normal
particle and decay database. This
procedure can be used repeatedly to hand in several different
resonances. To reset the user provided resonance widths to a single
pointer, the method setResonancePtr can be used instead,
with the same arguments as addResonancePtr.
pythia.setShowerModelPtr( showerModelPtr);
where the showerModelPtr is a shared
ShowerModel pointer which stores the following shared
pointers: timesPtr and timesDecPtr of the
class TimeShower, spacePtr of the class
SpaceShower, mergingPtr of the class
Merging, and mergingHooksPtr of the class
MergingHooks. It is also possible to get back a pointer
to the parton shower machinery and perform diagnostics.
pythia.getShowerModelPtr();
pythia.setHeavyIonsPtr( heavyIonsPtr);
Maybe more useful is the possibility to get back a pointer to the
generator used, e.g. to probe various quantities that are not
available with the normal Pythia methods:
pythia.getHeavyIonsPtr();
Pythia
object. The key example would be the simultaneous generation of signal
and pileup events, see main19.cc. The two objects are then
set up and initialized separately, and generate events completely
independently of each other. It is only afterwards that the event records
are combined into one single super-event per beam crossing.
pythia object for each subrun, in which case they are
completely separate. You can also use the same pythia object,
only doing a new init() call for each subrun. In that
case, the settings and particle databases remain as they were in the
previous subrun, only affected by the specific changes you introduced in
the meantime. You can put those changes in the main program, with
pythia.readString(string), using your own logic to decide
which ones to execute in which subrun. A corresponding possibility
exists with pythia.readFile(fileName, subrun) (or an
istream instead of a fileName), which as second
argument can take a non-negative subrun number. Then only those
sections of the file before any Main:subrun = ... line
or with matching subrun number will be read. That is, the
file could have a structure like
( lines always read, i.e. "default values" always (re)set )
Main:subrun = 1
( lines only read with readFile(fileName, 1) )
Main:subrun = 2
( lines only read with readFile(fileName, 2) )
Both of these possibilities are illustrated in main08.cc.
Beams:LHEF.
However, in that case you will do a complete re-initialization each time
around. If you want to avoid this, note that the flag
Beams:newLHEFsameInit = true can be set for the second and
subsequent subruns. Then the new file will be simulated with the same
initialization data as already set in a previous
pythia.init() call. The burden rests on you to ensure
that this is indeed correct, e.g. that the two event samples have not
been generated for different beam energies. Also note that cross
sections for processes will be based on the information in the
first-read file, when the full initialization is performed.
Pythia
methods and data members.
Pythia event generators,
and sets initial default values, notably for all settings and
particle data. You may use several Pythia instances
in the same run; only when you want to access external static
libraries could this cause problems. (This includes in particular
Fortran libraries such as LHAPDF5.)
argument xmlDir (default = ../xmldoc) : allows you to choose
from which directory the default settings and particle data values
are read in. If the PYTHIA8DATA environment variable
has been set it takes precedence. Else this optional argument allows
you to choose another directory location than the default one. Note
that it is only the directory location you can change, its contents
must be the ones of the xmldoc directory in the
standard distribution.
argument printBanner (default = on) : can be set
false to stop the program from printing a banner.
The banner contains useful information, so this option is only
intended for runs with multiple Pythia instances,
where output needs to be restricted.
Pythia::Pythia(Settings& settingsIn, ParticleData& particleDataIn, bool printBanner = true) Pythia event generators,
and sets initial default values, notably for all settings and
particle data. This option is intended for runs with multiple
Pythia instances, where only the first one needs to read the
xmldoc files, while subsequent ones can "inherit"
this information.
argument printBanner (default = on) : can be set
false to stop the program from printing a banner.
The banner contains useful information, so this option is only
intended for runs with multiple Pythia instances,
where output needs to be restricted.
Pythia::Pythia( istream& settingsStrings, istream& particleDataStrings, bool printBanner = true) Pythia event generators,
and sets initial default values, notably for all settings and
particle data. This option is intended for runs with multiple
Pythia instances, where input streams can avoid file read congestion.
argument printBanner (default = on) : can be set
false to stop the program from printing a banner.
The banner contains useful information, so this option is only
intended for runs with multiple Pythia instances,
where output needs to be restricted.
Pythia::~Pythia argument line :
the string to be interpreted as an instruction.
argument warn (default = on) :
write a warning message or not whenever the instruction does not make
sense, e.g. if the variable does not exist in the databases.
readString method. All four forms of the
readFile command share code for actually reading a file.
argument fileName :
the file from which instructions are read.
argument inStream :
an istream from which instructions are read.
argument warn (default = on) :
write a warning message or not whenever the instruction does not make
sense, e.g. if the variable does not exist in the databases. In the
command forms where warn is omitted it is true.
argument subrun :
allows you have several optional sets of commands within the same file.
Only those sections of the file before any Main:subrun = ...
line or following such a line with matching subrun number will be read.
The subrun number should not be negative; negative codes like
SUBRUNDEFAULT corresponds to no specific subrun.
PDF base class are described
here.
argument pdfAPtr, pdfBPtr :
pointers to two PDF-derived objects, one for each of
the incoming beams. The two objects have to be instantiated by you
in your program. Even if the two beam particles are the same
(protons, say) two separate instances are required, since current
information is cached in the objects. If both arguments are zero
then any previous linkage to external PDF's is disconnected,
see further Note 2 below.
argument pdfHardAPtr, pdfHardBPtr (default = 0) :
pointers to two further PDF-derived objects, one for each
of the incoming beams. Normally only the first two arguments above would
be used, and then the same PDF sets would be invoked everywhere. If you
provide these two further pointers then two different sets of PDF's are
used. This second set is then exclusively for the generation of the hard
process from the process matrix elements library. The first set above
is for everything else, notably parton showers and multiparton interactions.
argument pdfPomAPtr, pdfPomBPtr (default = 0) :
pointers to two further PDF-derived objects, one for each
of the incoming beams. These define the pomeron PDFs used in hard diffraction.
argument pdfGamAPtr, pdfGamBPtr (default = 0) :
pointers to two further PDF-derived objects, one for each
of the incoming beams. These define the photon PDFs when photons are
emitted from lepton beams. With resolved photon beams some additional
methods are required for initial state radiation and multiparton interactions
and to sample valence content.
argument pdfHardGamAPtr, pdfHardGamBPtr (default = 0) :
pointers to two further PDF-derived objects, one for each
of the incoming beams. As above, but now these are used for hard-process
generation only, the parton showers and multiparton interactions uses the
pdfGamAPtr and pdfGamBPtr PDFs. Unlike above,
no additional methods are needed for these.
argument pdfUnresAPtr, pdfUnresBPtr (default = 0) :
pointers to two further PDF-derived objects, one for each
of the incoming beams. Additional PDF pointers when the beam particle
has also unresolved PDFs in addition to usual resolved one. Currently
used only when mixing direct and resolved photon-initiated processes.
argument pdfUnresGamAPtr, pdfUnresGamBPtr (default = 0) :
pointers to two further PDF-derived objects, one for each
of the incoming beams. Additional PDF pointers when having resolved and
unresolved photons coming from lepton beams. Currently used only when mixing
direct and resolved photon-initiated processes in lepton-lepton or
lepton-hadron collisions.
setPDFPtr with new arguments before each
Pythia::init() call. To revert from external PDF's
to the normal internal PDF selection you must call
setPDFPtr(0, 0) before Pythia::init().
bool Pythia::setPhotonFluxPtr( PDF* photonFluxAIn, PDF* photonFluxBIn) PDF base class are described
here.
argument photonFluxAIn, photonFluxBIn :
pointers to two PDF-derived objects, one for each of
the incoming beams. The two objects have to be instantiated by you
in your program.
bool Pythia::setLHAupPtr( LHAup* lhaUpPtrIn) Beams:frameType = 5
has been set.
argument lhaUpPtrIn :
pointer to a LHAup-derived object.
DecayHandler base class are described
here. Note that you can only
provide one external object, but this object in its turn could
very well hand on different particles to separate decay libraries.
argument decayHandlePtr :
pointer to a DecayHandler-derived object. This object
must be instantiated by you in your program.
argument handledParticles : vector with the PDG identity codes
of the particles that should be handled by the external decay package.
You should only give the particle (positive) codes; the respective
antiparticle is always included as well.
RndmEngine base class are described
here.
argument rndmEnginePtr :
pointer to a RndmEngine-derived object. This object
must be instantiated by you in your program.
UserHooks base class are described
here. You can only hand in one such
pointer, but this may be to a class that implements several of the
different allowed possibilities.
argument userHooksPtr :
pointer to a userHooks-derived object. This object
must be instantiated by you in your program.
setUserHooksPtr above for further information.
BeamShape base class are described
here.
argument BeamShapePtr :
pointer to a BeamShape-derived object. This object
must be instantiated by you in your program.
Pythia library itself. The rules for constructing your
own class from the SigmaProcess base class are described
here. Calling this method
removes any previously user provided processes. To add multiple
processes, use addSigmaPtr.
argument sigmaPtr :
shared pointer to a SigmaProcess-derived object.
argument phaseSpacePtr :
shared pointer to a PhaseSpace-derived object. When not
provided the internal phase-space selection machinery will be
used. Then sigmaPtr should be an instance of a class
derived from one of the Sigma1Process,
Sigma2Process and Sigma3Process classes for
1-, 2- and 3- particle production, in their turn derived from
SigmaProcess.
setSigmaPtr above for further information.
Pythia library itself. This allows the decay of new
resonances to be handled internally, when combined with new particle
data. Note that the decay of normal hadrons cannot be modeled here;
this is for New Physics resonances. The rules for constructing your
own class from the ResonanceWidths base class are
described here. Calling
this method removes any previously user provided resonances. To add as
many new resonances as you wish, instead call
addResonancePtr repeatedly.
argument resonancePtr :
shared pointer to a ResonanceWidths-derived object.
setResonancePtr above for further information.
ShowerModel
class is described here. This
model, which includes TimeShower and
SpaceShower derived objects, must be instantiated by you
in your program.
argument showerModelPtr :
shared pointer to a ShowerModel-derived object. This
includes a decay time shower, time shower, space shower, merging
pointer, and merging user hooks.
Pythia machinery for its tasks,
see further here.
argument heavyIonsPtr :
pointer to a HeavyIons-derived object for doing
Heavy Ions collisions.
init
method is available for this stage.
bool Pythia::init() next() method is the main one to generate events.
In this section we also put a few other specialized methods that
may be useful in some circumstances.
bool Pythia::next() Info::atEndOfFile()
method.
bool Pythia::next(int procType) procType, it possible to force a specific
process type, assuming that you start out e.g. from SoftQCD:all
= on. The possible interaction procTypes are (1)
inelastic nondiffractive, (2) elastic, (3, 4) single diffractive where
either the first or second hadron is broken up, (5) double
diffractive, and (6) central diffraction. This matches the order of
the SoftQCD process codes 101 - 106.LowEnergyQCD
processes are used, then also the options (7) excitation, (8)
annihilation and (9) resonant can be used. Then all the input numbers
match the order of the LowEnergQCD codes 151 - 159. In
the higher-energy description process types 7 - 9 default back to the
0 mixed option.
bool Pythia::setKinematics(double eCM) Beams:allowVariableEnergy change the beam energy.
bool Pythia::setBeamIDs( int idAin, int idBin) idA can be changed to any hadron, while
idB must be a proton or a neutron when using this
feature. This is useful for example in hadronic cascades in a
medium. It is here assumed that only the SoftQCD (and
LowEnergyQCD if relevant) hadron-nucleon processes are
being used.
int Pythia::forceTimeShower( int iBeg, int iEnd, double pTmax, int nBranchMax = 0) event event record. This could be used for externally
provided simple events, or even parts of events, for which
a complete generation is not foreseen. Since the mother source of
the parton system is not known, one cannot expect as good accuracy
as in a normal generation. When two different timelike shower
instances are set up, it is the one used for showering in resonance
decays that is used here. The forceTimeShower method
can be used in conjunction with the forceHadronLevel
one below. Further comments are found
here.
argument iBeg, iEnd : the first and last entry of the event
record to be affected by the call.
argument pTmax : the maximum pT scale of emissions.
Additionally, as always, the scale variable of each parton
sets the maximum pT scale of branchings of this parton.
Recall that this scale defaults to 0 if not set, so that no radiation
can occur.
argument nBranchMax (default = 0) : when positive, it sets the
maximum number of branchings that are allowed to occur in the shower,
i.e. the shower may stop evolving before reaching the lower cutoff.
The argument has no effect when zero or negative, i.e. then the shower
will continue to the lower cutoff.
argument findJunctions (default = on) :
normally this routine will search through the event record and try to
figure out if any colour junctions are present. If so, the colour
topology of such junctions must be sorted out. In tricky cases this
might fail, and then hadronization will not work. A user who is
aware of this and knows the intended colour flow can set up the
junction information (if any) in the event record, and then call
forceHadronLevel(false) so as not to have this information
overwritten. (If the event record contains no unhadronized partons
then no junction search will be performed in any case.)
i of the event record,
when possible. Sequential decays are not performed, but have to be taken
care of successively, if so desired.
bool Pythia::forceRHadronDecays() procTypes are
(1) inelastic nondiffractive, (2) elastic, (3, 4) single diffractive
where either first or second hadron is broken up, (5) double diffractive,
(7) excitation, (8) annihilation and (9) resonant. It is also possible to
specify the formation of a specific resonance by setting
procType to the id of that particle. No perturbative stage
is applied in either case, as relevant at low energies. It can be used
e.g. to model Hadronic Rescattering
in the final state, where partial cross sections are first calculated
to provide the relevant mix of different collision types. This method
does not itself decay unstable hadrons, but that could be achieved e.g.
with a Pythia::moreDecays() call.
double Pythia::getSigmaTotal() argument id1, id2 :
the identity codes of the two colliding hadrons. If unspecified,
the ids are taken from the beam configuration of the
Pythia object.
argument eCM12 :
the collision center-of-mass energy. If unspecified, the beam energy
is taken from the beam configuration of the Pythia object.
argument m1, m2 :
the masses of the two incoming hadrons. If unspecified, the particles are
assumed to be on-shell.
argument mixLoHi :
Gives a choice of cross section description.
getSigmaTotal ones above, but
offers the total cross section split into interaction procType,
(1) inelastic nondiffractive, (2) elastic, (3, 4) single diffractive
where either first or second hadron is broken up, (5) double diffractive,
(7) excitation, (8) annihilation and (9) resonant. You can also get the
same total cross sections as in getSigmaTotal for
procType = 0, but with a larger time consumption if this is
the only number you want.
void Pythia::LHAeventList() LHAup::listEvent(...).
(Other listings are available via the class members below, so this
listing is a special case that would not fit elsewhere.)
bool Pythia::LHAeventSkip(int nSkip) LHAup::skipEvent(nSkip).
Mainly intended for debug purposes, e.g. when an event at a known
location in a Les Houches Event File is causing problems.
argument nSkip :
number of events to skip.
next() above.
Pythia::readFile(...) method.
There is no strict need for a user to interact with the
Settings database in any other way. However, as an option,
some settings variables have been left free for the user to set in
such a file, and then use in the main program to directly affect the
performance of that program, see
here. A typical example would
be the number of events to generate. For such applications the
following shortcuts to some Settings methods may be
convenient.
bool Pythia::flag(string key) Settings database.
argument key :
the name of the variable to be read.
int Pythia::mode(string key) Settings database.
argument key :
the name of the variable to be read.
double Pythia::parm(string key) Settings
database.
argument key :
the name of the variable to be read.
string Pythia::word(string key) Settings database.
argument key :
the name of the variable to be read.
Pythia contains an number of parton density sets
internally, plus an interface to LHAPDF (5 or 6). With the method below,
this machinery is also made available for external usage.
PDF* getPDFPtr(int id, int sequence = 1) argument id :
the identity code of the incoming particle.
argument sequence :
should normally be 1, but 2 can be used for protons to let the PDF
selection be determined by the special settings for hard processes
(PDF:useHard etc.).
Pythia class contains a few public data members,
several of which play a central role. We list them here, with
links to the places where they are further described.
Event Pythia::process