The Settings Scheme

The Settings class keeps track of all the flags, modes and parameters in the program. As such, it serves the other program elements from one central repository. 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.

Concepts

We distiguish three kinds of user-modifiable variables, by the way they have to be stored:
  1. Flags are on/off switches, and are stored as bool.
  2. Modes corresponds to a finite enumeration of separate options, and are stored as int.
  3. Parameters take a continuum of values, and are stored as double.
One could imagine also strings, but so far there has been no need.

In general, each variable stored in Settings is associated with four kinds of information:

Technically, the Settings class is implemented with the help of three separate maps, one for each kind of variable, with the variable name used as key.

Operation

The normal flow of setting value is:
  1. When a Pythia object pythia is created, the member pythia.settings is asked to scan the files listed in the Index.xml file in the doc subdirectory.
  2. In all of the files scanned, lines beginning with <flag>, <mode> or <parameter> are identified, and the information on such a line is used to define a new flag, mode or parameter. To exemplify, consider a line
    <parameter 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.
    Important: the values in the .xml files should not be changed, except by the PYTHIA authors. Any changes should be done with the help of the methods described below.
  3. Between the creation of the Pythia object and the init call for it, you may use the methods of the Settings class to modify some of the default values. Several different methods can be used for this.

    a) Inside your main program you can directly set values with

        pythia.settings.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.settings.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. 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).
    The Pythia class contains a readString method that hands on to this method, or to corresponding methods in ParticleData or Pythia6, and therefore may offer the most convenient form:
        pythia.readString("TimeShower:pTmin = 1.0"); 
    

    b) Underlying this are the settings-type-sensitive commands in Settings, that are split by names containing flag, mode or parameter. Thus, the example now reads

        pythia.settings.parameter("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.
    There are several different further methods, like

    method name="mode( name)"
    gives the current value,

    method name="mode( name, value)"
    sets the current value,

    method name="isMode( name)"
    tells whether a mode has been defined or not,

    method name="addMode( name, default, min, max)"
    defines a new mode,

    method name="forceMode( name, value)"
    sets the value, also when outside the recommended bounds (and it is completely up to you to face the consequences),

    method name="resetMode( name)"
    resets the current value to the default one.

    Corresponding methods exist for flags and parameters. Again name comparisons are case-insensitive.

    Normally the user should have no need for these methods. The main exception is if some of the variables defined on Main Program Parameters page are used to set run-specific information (like the CM energy or the number of events to generate) in an external file (see 3c below) and these variables are then read into the main program. Then the flag( name), mode( name) and parameter( name) methods are to be used, see main01.cc as an example how it could work.

    c) 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.0
    
    Each line is process as described for the string in 3a). Since names that do not match an existing variable are ignored, you can easily comment out lines. The recommended way would be to add a special character like # or ! in the first column. The file can be read by the
        pythia.settings.readFile("filename") 
    
    method, alternatively by the
        pythia.readFile("filename") 
    
    method. The latter has the advantage that it allows you to freely mix commands to the Settings, ParticleData and Pythia6 classes, and so is preferable. Again, an optional second argument false allows you to switch off warning messages for unknown variables.
  4. In the Pythia init call, many of the various other program elements are initialized, making use of the values in the database. Once initialized, the common Settings database may not be consulted again. It is therefore not productive to do further changes in mid-run.

    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.

  5. You may at any time obtain a listing of all variables in the database by calling
        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.