Settings
class keeps track of all the flags, modes,
parameters and words in the program. As such, it serves the other program
elements from one central repository. Accessing it allows the user to
modify the behaviour of the program. The Settings
class is
purely static, i.e. you can interact with it directly by
Settings::command(argument)
.
However, a settings
object of the Settings
class
is a public member of the Pythia
class, so an alternative
notation would be 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.
bool
.int
.double
. The shorthand notation parm is used in the C++
code and XML tags, so that all four kinds are represented by
four-letter type names.string
. No blanks or double quotation marks (") may
appear inside a word, the former to simplify parsing of an input file
and the latter not to cause conflicts with XML attribute delimiters.
Currently the main application is to store file names.Settings
is associated
with four kinds of information:
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
or a word
(and is not used there), is usually rather
well-defined for a mode
, but less so for a parm
.
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.Settings
class is implemented with the
help of four 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
or <word
are identified, and the information on
such a line is used to define a new flag, mode, parameter or word.
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.
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, unless an optional second argument
false
is used. 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. 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
.
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);Boolean values should here be given as
true
or
false
i.e. there is less flexibility in the lower-level
methods.
At the same level, there are several different methods available.
We here show the ones for mode
, but corresponding methods
exist for flag
, parm
and word
,
with obvious restrictions where min
and max
are not defined. Again name comparisons are case-insensitive.
method
mode( name) method
mode( name, value) method
isMode( name) method
addMode( name, default, min, max) method
forceMode( name, value) method
resetMode( name) flag(name)
, mode(name)
parm(name)
and word(name)
methods are to
be used, see e.g. the main programs in the examples
subdirectory to find out how it works.
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. 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. Again, an optional
second argument false
allows you to switch off warning
messages for unknown variables.
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 from scratch. Such a call might be
required if several Pythia
objects are created in the same run,
and requested to have different values - by default the init()
call is only made the first time. However, a more economical solution
is then offered by resetAll()
, which sets all variables 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.
pythia.settings.writeFile(fileName);This file could then directly be read in by
readFile(fileName)
in a subsequent (identical) run.
A second argument true
would print all settings, not
only the changed ones. Further, the first argument can be replaced by
(a reference to) an ostream
, by default cout
.