Settings
class keeps track of all the flags, modes,
parameters and words used during the event generation. As such, it
serves all the Pythia
program elements from one central
repository. Accessing it allows the user to modify the generator
behaviour.
Each Pythia
object has a public member settings
of the Settings
class. Therefore you access the
settings methods as pythia.settings.command(argument)
,
assuming that pythia
is an instance of the Pythia
class. Further, for the most frequent user tasks, Pythia
methods have been defined, so that pythia.command(argument)
would work, see further below.
The central section on this page is the Operation one. The preceding
concepts section is there mainly to introduce the basic structure and
the set of properties that can be accessed. The subsequent sections
provide a complete listing of the existing public methods, which most
users probably will have little interaction with.
bool
.int
.double
. The shorthand notation parm is used in the C++
code and XML tags.string
. No double quotation marks " or braces { }
may appear inside a word, and commas , will take a special role next
so should also be avoided. Normally the input string is expected not to
contain any blanks or equal signs, but if it does it must be enclosed
in braces { }.vector<bool>
. The shorthand notation fvec is used
in the C++ code and XML tags. When the vector is input as a string
it should be given as a comma-separated list, either containing
no blanks or else enclosed in braces { }.vector<int>
. The shorthand notation mvec is used
in the C++ code and XML tags. When the vector is input as a string
it should be given as a comma-separated list, either containing
no blanks or else enclosed in braces { }.vector<double>
.
The shorthand notation pvec is used in the C++ code and XML tag.
When the vector is input as a string it should be given as a comma-separated
list, either containing no blanks or else enclosed in braces { }.vector<string>
. The shorthand notation wvec is used
in the C++ code and XML tags. When the vector is input as a string
it should be given as a comma-separated list, either containing
no blanks or else enclosed in braces { }.{ }
to enclose
words or lists that are allowed to contain blanks and equal signs, and
of commas ,
to separate the fields of the list, in
analogy with how C++ arrays can be initialized. You should not be
using these three characters for any other purposes. Input of a vector
can be split across several lines, until a close brace }
is found that matches the open brace {
. If no such
closing brace is found the program will abort, so beware. The double
quotation mark "
is avoided since it is already used
for other purposes. Also note that all shorthands have been chosen
four letters long. Finally, it is possible to append to vector
settings with the notation += { }
, similar to the
+=
notation used in Python to append lists.
class:name
(or file:name
, usually these agree), e.g.
TimeShower:pTmin
. The class/file part usually identifies
the .xml
file where the variable is defined, and the part of
the program where it is used, but such a connection cannot be strictly
upheld, since e.g. the same variable may be used in a few different
cases (even if most of them are not).flag
,
an fvec
a word
or a wvec
(and is not used there), is
usually rather well-defined for a mode
or mvec
,
but less so for a parm
or pvec
. Often the allowed
range exaggerates the degree of our current knowledge, so as not to restrict
too much what the user can do. One may choose not to set the lower or
upper limit, in which case the range is open-ended.
mode
s only, a further
boolean is stored to tell whether this should be allowed, or whether
out-of-range inputs should be forbidden, to the extent that the whole
PYTHIA initialization would abort. The latter applies to those modes
that have been defined with the modepick
label in the
xmldoc/*.xml
files, and where maximal and minimal values
have been specified. Such labels are used to represent a discrete set
of options, and so any value outside the allowed range is just plain
wrong. Also attempts to change modefix
fixed-value
mode
s lead to aborts. By contrast those defined with
mode
or modeopen
follow the normal rules
of being reset to fall into the allowed range, without any warnings.Settings
class is implemented with the
help of eight separate maps, one for each kind of variable, with the
variable name
used as key.
Pythia
object pythia
is created,
the member pythia.settings
is asked to scan the files
listed in the Index.xml
file in the xmldoc
subdirectory.
In all of the files scanned, lines beginning with
<flag
, <mode
, <parm
,
<word
, <fvec
, <mvec
,
<pvec
or <wvec
are identified, and the
information on such a line is used to define a new flag, mode, parameter,
word, or vector of flags, modes or parameters. To exemplify, consider a line
<parm name="TimeShower:pTmin" default="0.5" min="0.1" max="2.0">which appears in the
TimeShower.xml
file, and there
defines a parameter TimeShower:pTmin
with default value
0.5 GeV and allowed variation in the range 0.1 - 2.0 GeV. The min
and max values are optional.
.xml
files should
not be changed, except by the PYTHIA authors. Any changes should be
done with the help of the methods described below.
Pythia
object and the
init
call for it, you may use several alternative
methods to modify some of the default values. The same variable
can be changed several times. If so, it is the last read value
that counts. The two special
Tune:ee
and
Tune:pp
modes and the
Print:quiet
flag
are expanded to change several settings in one go, but these obey
the same ordering rules.
a) Inside your main program you can directly set values with
pythia.readString(string)where both the variable name and the value are contained inside the character string, separated by blanks and/or a =, e.g.
pythia.readString("TimeShower:pTmin = 1.0");The match of the name to the database is case-insensitive. Names that do not match an existing variable are ignored. A warning is printed, however. Strings beginning with a non-alphanumeric character, like # or !, are assumed to be comments and are not processed at all. Values below the minimum or above the maximum are set at the respective border. In extreme cases, where it is necessary to go outside the allowed range, "
FORCE=
" can replace
the normal "=
" separator to force the requested value,
at own responsibility. For bool
values, the following
notation may be used interchangeably:
true = on = yes = ok = 1
, while everything else gives
false
(including but not limited to
false
, off
, no
and 0).Pythia
readString(string)
method
actually does not do changes itself, but sends on the string either
to the Settings
class or to ParticleData
.
The former holds if the string begins with a letter, the latter
if it begins with a digit. (The exception is if an input list has been
begun by an open brace { but no matching close brace } was present;
then all subsequent non-empty input is directed to Settings
until the close brace is found.) If desired, it is possible to communicate
directly with the corresponding Settings
method:
pythia.settings.readString("TimeShower:pTmin = 1.0");In this case, changes intended for
ParticleData
would not be understood.
c) Underlying the settings.readString(string)
method are
the settings-type-sensitive commands in the Settings
, that
are split by names containing flag
, mode
,
parm
or word
. Thus, the example now reads
pythia.settings.parm("TimeShower:pTmin", 1.0);Such a form could be convenient e.g. if a parameter is calculated at the beginning of the main program, and thus is available as a variable rather than as a character string. Note that Boolean values must here be given as
true
or
false
i.e. there is less flexibility than with the
previous methods.
At the same level, there are several different methods available.
These are included in the full description below, but normally the user
should have no need for them.
d) A simpler and more useful way is to collect all your changes
in a separate file, with one line per change, e.g.
TimeShower:pTmin = 1.0Each line is read in as a string and processed with the methods already introduced. The file can be read by the
pythia.readFile(fileName);method (or an
istream
instead of a
fileName
). The file can freely mix commands to the
Settings
and ParticleData
classes, and so is
preferable. Lines with settings are handled by calls to the
pythia.settings.readString(string)
method. It is possible
to recursively include settings files by the special command
include = fileName
, either in a file or by reading a
string. An attempt will be made to read fileName
, which
can be either an absolute or relative path. If such a file does not
exist as an absolute or relative path, then an attempt is made to read
the file as a relative path from the colon separated list of
directories optionally specified by setting the
PYTHIA8CMND
environment variable, e.g. export
PYTHIA8CMND = PATH1:PATH2:...
. Finally, if the file is not
found along these paths the file is searched for relative to the
directory share/Pythia8/settings
, which itself is defined
relative to the XML path, i.e. xmldoc/../settings
.
A file can make use of two extra features that are not available with the
readString(...)
method. One is the possibility to provide
information for several distinct subruns.
The other is the possibility to comment out a section of lines in the file.
The first line of the commented section should then begin by /*
and the last begin by */
. This is reminiscent of the convention
used in C++ and other languages, but is not as powerful, in that it is not
possible to comment in or out parts of lines. It is only the first two
non-blank characters of a line that are checked for a match, and a line
beginning with */
is counted as part of the commented section.
To avoid mistakes it is best to keep /*
and */
on lines of their own, optionally followed by comments, but not by commands.
pythia.init()
call, many of the various other program
elements are initialized, making use of the current values in the database.
Once initialized, the common Settings
database is likely not
consulted again by these routines. It is therefore not productive to do
further changes in mid-run: at best nothing changes, at worst you may
set up inconsistencies.
A routine reInit(fileName)
is provided, and can be used to
zero all the maps and reinitialize them from scratch. Such a call might be
useful if several subruns are to be made with widely different parameter
sets - normally the maps are only built from scratch once, namely when the
Pythia()
object is created. A more economical alternative is
offered by resetAll()
, however, which sets all variables back
to their default values.
pythia.settings.listAll();The listing is strictly alphabetical, which at least means that names from the same file are kept together, but otherwise may not be so well-structured: important and unimportant ones will appear mixed. A more relevant alternative is
pythia.settings.listChanged();where you will only get those variables that differ from their defaults. Or you can use
pythia.settings.list("string");where only those variables with names that contain the string (case-insensitive match) are listed. Thus, with a string
shower
, the shower-related variables would be shown.
The method pythia.settings.output(key)
can return the
value of a variable as a string, convenient for output. In a
readString
or readFile
command, the
construction key = ?
will echo back the variable
and its value, using this method.
pythia.settings.writeFile(fileName);This file could then directly be read in by
readFile(fileName)
in a subsequent (identical) run.
Some variants of this command are listed below.
Settings::readFile(...)
method.
The intention is that you should use Pythia::readFile(...)
.
It parses and decides which individual lines should be sent on to
Settings::readString(...)
.
Settings::Settings() argument
startFile : argument
append (default = off
) :
By default nothing is done if the method has already been called once.
If true the further settings read in are added to the current database.
argument
startFile : Pythia::readString(...)
and
Pythia::readFile(...)
.
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.
ostream
.
argument
toFile, os :
file or stream on which settings are written.
argument
writeAll (default = off
) :
normally only settings that have been changed are written,
but if true then all settings are output.
argument
match :
list all those settings where the name contains
the match
(sub)string (case-insensitive).
string Settings::output(string key, bool fullLine = true) unknown
is returned.
argument
key :
the name of the settings variable.
argument
fullLine (default = on
) :
If true then a whole "line" is returned, " key = value\n
",
while if false only the value
string.
vector<string> Settings::getReadHistory() readString
commands that
have been processed by the Settings
instance, e.g. for
inspection. Note that readFile
command lines are interpreted
by readString
and thus also are listed, as are the
Settings
commands read by Pythia::readString
and Pythia::readFile
.
vector<string> Settings::getReadHistory(int subrun) readString
commands that
have been processed by Settings
, for a specific subrun
(see the section on Main-Program
Settings). For subrun = -1
, returns the
readString
history common to all subruns. For
subrun >= 0
, returns the history of readString
commands for that specific subrun (omitting the common part).
void Settings::resetAll() Mode
, Parm
,
MVec
and PVec
additionally if lower and/or
upper limits are to be imposed and, if so, what those limit are.
bool Settings::flag(string key) false
,
0
, 0.
, " "
, or a
vector of length 1 and value false
, 0
,
0.
or " "
, respectively, is returned.
bool Settings::flagDefault(string key) false
,
0
, 0.
, " "
, or a
vector of length 1 and value false
, 0
,
0.
or " "
, respectively, is returned.
map<string, Flag> Settings::getFlagMap(string match) force=false
, input values
outside the allowed range are reinterpreted as being at the nearest
limit. If force = true
, upper and lower limits will be
ignored, allowing to force values outside the allowed range (to be
used with caution and at own responsibility!). Any key not found in the
settings database will be ignored, unless force = true
, in
which case the missing key will be added to the database with the
given value.
void Settings::forceMode(string key, int now) force = true
option in the standard methods above.
They are kept for backwards compatibility with version 8.223 and earlier
but will be removed in a future major release.
void Settings::resetFlag(string key) SoftQCD
or LowEnergyQCD
categories, else false. This method does not check whether Les Houches
input is used, so that may have to be done separately. Since the method
contains a hardcoding of what hard process types exist, in order to
detect if any are on, it could be broken by the addition of new internal
processes. It is therefore mainly useful for warning purposes, not for
hard decisions.