source: HiSusy/trunk/Pythia8/pythia8170/htmldoc/SettingsScheme.html @ 1

Last change on this file since 1 was 1, checked in by zerwas, 11 years ago

first import of structure, PYTHIA8 and DELPHES

File size: 17.9 KB
Line 
1<html>
2<head>
3<title>The Settings Scheme</title>
4<link rel="stylesheet" type="text/css" href="pythia.css"/>
5<link rel="shortcut icon" href="pythia32.gif"/>
6</head>
7<body>
8
9<h2>The Settings Scheme</h2>
10
11The <code>Settings</code> class keeps track of all the flags, modes,
12parameters and words used during the event generation. As such, it
13serves all the <code>Pythia</code> program elements from one central
14repository. Accessing it allows the user to modify the generator
15behaviour.
16
17<p/>
18Each <code>Pythia</code> object has a public member <code>settings</code> 
19of the <code>Settings</code> class. Therefore you access the
20settings methods as <code>pythia.settings.command(argument)</code>,
21assuming that <code>pythia</code> is an instance of the <code>Pythia</code> 
22class. Further, for the most frequent user tasks, <code>Pythia</code> 
23methods have been defined, so that <code>pythia.command(argument)</code> 
24would work, see further below.
25
26<p/>
27The central section on this page is the Operation one. The preceding
28concepts section is there mainly to introduce the basic structure and
29the set of properties that can be accessed. The subsequent sections
30provide a complete listing of the existing public methods, which most
31users probably will have little interaction with.
32
33<h3>Concepts</h3>
34
35We distinguish four kinds of user-modifiable variables, by the way
36they have to be stored:
37<ol>
38<li>Flags are on/off switches, and are stored as <code>bool</code>.</li>
39<li>Modes corresponds to a finite enumeration of separate options,
40   and are stored as <code>int</code>.</li>
41<li>Parameters take a continuum of values, and are stored as
42<code>double</code>. The shorthand notation parm is used in the C++
43code and XML tags, so that all four kinds are represented by
44four-letter type names.</li>
45<li>Words are simple character strings and are stored as
46<code>string</code>. No blanks or double quotation marks (&quot;) may
47appear inside a word, the former to simplify parsing of an input file
48and the latter not to cause conflicts with XML attribute delimiters.
49Currently the main application is to store file names.</li>
50</ol>
51
52<p/>
53In general, each variable stored in <code>Settings</code> is associated
54with four kinds of information:
55<ul>
56<li>The variable name, of the form <code>class:name</code> 
57(or <code>file:name</code>, usually these agree), e.g.
58<code>TimeShower:pTmin</code>. The class/file part usually identifies
59the <code>.xml</code> file where the variable is defined, and the part of
60the program where it is used, but such a connection cannot be strictly
61upheld, since e.g. the same variable may be used in a few different
62cases (even if most of them are not).</li> 
63<li>The default value, set in the original declaration, and intended
64to represent a reasonable choice.</li> 
65<li>The current value, which differs from the default when the user so
66requests.</li>
67<li>An allowed range of values, represented by meaningful
68minimum and maximum values. This has no sense for a <code>flag</code> 
69or a <code>word</code> (and is not used there), is usually rather
70well-defined for a <code>mode</code>, but less so for a <code>parm</code>.
71Often the allowed range exaggerates the degree of our current knowledge,
72so as not to restrict too much what the user can do. One may choose
73not to set the lower or upper limit, in which case the range is
74open-ended.</li>   
75</ul>
76
77<p/>
78Technically, the <code>Settings</code> class is implemented with the
79help of four separate maps, one for each kind of variable, with the
80variable <code>name</code> used as key.
81
82<h3>Operation</h3>
83   
84The normal flow of setting values is:
85
86<ol>
87
88<p/> <li>
89When a <code>Pythia</code> object <code>pythia </code>is created,
90the member <code>pythia.settings</code> is asked to scan the files
91listed in the <code>Index.xml</code> file in the <code>xmldoc</code> 
92subdirectory.
93
94<p/>
95In all of the files scanned, lines beginning with
96<code>&lt;flag</code>, <code>&lt;mode</code>, <code>&lt;parm</code> 
97or <code>&lt;word</code> are identified, and the information on
98such a line is used to define a new flag, mode, parameter or word.
99To exemplify, consider a line
100<pre>
101&lt;parm name="TimeShower:pTmin" default="0.5" min="0.1" max="2.0">
102</pre> 
103which appears in the <code>TimeShower.xml</code> file, and there
104defines a parameter <code>TimeShower:pTmin</code> with default value
1050.5 GeV and allowed variation in the range 0.1 - 2.0 GeV. The min
106and max values are optional.
107<br/><b>Important:</b> the values in the <code>.xml</code> files should
108not be changed, except by the PYTHIA authors. Any changes should be
109done with the help of the methods described below.
110</li>
111
112<p/> <li>
113Between the creation of the <code>Pythia</code> object and the
114<code>init</code> call for it, you may use several alternative
115methods to modify some of the default values. The same variable
116can be changed several times. If so, it is the last read value
117that counts. The two special
118<code><a href="Tunes.html" target="page">Tune:ee</a></code> and
119<code><a href="Tunes.html" target="page">Tune:pp</a></code> 
120modes are expanded to change several settings in one go, but these obey
121the same ordering rules.
122
123<p/> 
124a) Inside your main program you can directly set values with
125<pre>
126    pythia.readString(string)
127</pre>
128where both the variable name and the value are contained inside
129the character string, separated by blanks and/or a =, e.g.
130<pre>
131    pythia.readString("TimeShower:pTmin = 1.0");
132</pre>
133The match of the name to the database is case-insensitive. Names
134that do not match an existing variable are ignored. A warning is
135printed, however. Strings beginning with a non-alphanumeric character,
136like # or !, are assumed to be comments and are not processed at all.
137Values below the minimum or above the maximum are set at
138the respective border. For <code>bool</code> values, the following
139notation may be used interchangeably:
140<code>true = on = yes = ok = 1</code>, while everything else gives
141<code>false</code> (including but not limited to
142<code>false</code>, <code>off</code>, <code>no</code> and 0).<br/> 
143
144<p/> 
145b) The <code>Pythia</code> <code>readString(string)</code> method
146actually does not do changes itself, but sends on the string either
147to the <code>Settings</code> class or to <code>ParticleData</code>.
148The former holds if the string begins with a letter, the latter
149if it begins with a digit. If desired, it is possible to communicate
150directly with the corresponding <code>Settings</code> method:
151<pre>
152    pythia.settings.readString("TimeShower:pTmin = 1.0");
153</pre>
154In this case, changes intended for <code>ParticleData</code> 
155would not be understood.
156
157<p/> 
158c) Underlying the <code>settings.readString(string)</code> method are
159the settings-type-sensitive commands in the <code>Settings</code>, that
160are split by names containing <code>flag</code>, <code>mode</code>,
161<code>parm</code> or <code>word</code>. Thus, the example now reads
162<pre>
163    pythia.settings.parm("TimeShower:pTmin", 1.0);
164</pre>
165Such a form could be convenient e.g. if a parameter is calculated
166at the beginning of the main program, and thus is available as a
167variable rather than as a character string.
168Note that Boolean values must here be given as <code>true</code> or
169<code>false</code> i.e. there is less flexibility than with the
170previous methods.
171
172<p/> 
173At the same level, there are several different methods available.
174These are included in the full description below, but normally the user
175should have no need for them.
176
177<p/>
178d) A simpler and more useful way is to collect all your changes
179in a separate file, with one line per change, e.g.
180<pre>
181    TimeShower:pTmin = 1.0
182</pre>
183Each line is read in as a string and processed with the methods already
184introduced.
185
186The file can be read by the
187<pre>
188    pythia.readFile(fileName);
189</pre>
190method (or an <code>istream</code> instead of a <code>fileName</code>).
191The file can freely mix commands to the <code>Settings</code> and
192<code>ParticleData</code> classes, and so is preferable. Lines with
193settings are handled by calls to the
194<code>pythia.settings.readString(string)</code> method.
195</li>
196
197<p/> <li>
198In the <code>pythia.init(...)</code> call, many of the various other program 
199elements are initialized, making use of the current values in the database.
200Once initialized, the common <code>Settings</code> database is likely not
201consulted again by these routines. It is therefore not productive to do
202further changes in mid-run: at best nothing changes, at worst you may
203set up inconsistencies.
204
205<p/>
206A routine <code>reInit(fileName)</code> is provided, and can be used to
207zero all the maps and reinitialize them from scratch. Such a call might be
208useful if several subruns are to be made with widely different parameter
209sets - normally the maps are only built from scratch once, namely when the
210<code>Pythia()</code> object is created. A more economical alternative is
211offered by <code>resetAll()</code>, however, which sets all variables back
212to their default values.
213</li> 
214
215<p/> <li>
216You may at any time obtain a listing of all variables in the
217database by calling 
218<pre>
219    pythia.settings.listAll();
220</pre>
221The listing is strictly alphabetical, which at least means that names
222from the same file are kept together, but otherwise may not be so
223well-structured: important and unimportant ones will appear mixed.
224A more relevant alternative is
225<pre>
226    pythia.settings.listChanged();
227</pre>
228where you will only get those variables that differ from their
229defaults. Or you can use
230<pre>
231    pythia.settings.list("string");
232</pre>
233where only those variables with names that contain the string
234(case-insensitive match) are listed. Thus, with a string
235<code>shower</code>, the shower-related variables would be shown.
236</li>
237
238<p/> <li>
239The above listings are in a tabular form that cannot be read
240back in. Assuming you want to save all changed settings (maybe because
241you read in changes from several files), you can do that by calling
242<pre>
243    pythia.settings.writeFile(fileName);
244</pre>
245This file could then directly be read in by
246<code>readFile(fileName)</code> in a subsequent (identical) run.
247Some variants of this command are listed below.
248</li>
249</ol>
250
251<h3>Methods</h3>
252
253The complete list of methods and arguments is as follows. Most of the
254ones of interest to the user have already been mentioned above.
255Others can be used, but the same functionality is better achieved
256by higher-level routines. Some are part of the internal machinery,
257and should not be touched by user.
258
259<p/>
260Note that there is no <code>Settings::readFile(...)</code> method.
261The intention is that you should use <code>Pythia::readFile(...)</code>.
262It parses and decides which individual lines should be sent on to
263<code>Settings::readString(...)</code>.
264
265<a name="method1"></a>
266<p/><strong>Settings::Settings() &nbsp;</strong> <br/>
267the constructor, which takes no arguments. Internal.
268 
269
270<a name="method2"></a>
271<p/><strong>bool Settings::initPtr(Info* infoPtrIn) &nbsp;</strong> <br/>
272initialize pointer to error-message database. Internal.
273 
274
275<a name="method3"></a>
276<p/><strong>bool Settings::init(string startFile = &quot;../xmldoc/Index.xml&quot;, bool append = false, ostream& os = cout) &nbsp;</strong> <br/>
277read in the settings database.
278<br/><code>argument</code><strong> startFile </strong> (<code>default = <strong>&quot;../xmldoc/Index.xml&quot;</strong></code>) :   
279read in the settings from all the files listed in this file, and
280assumed to be located in the same subdirectory.
281 
282<br/><code>argument</code><strong> append </strong> (<code>default = <strong>false</strong></code>) :   
283By default nothing is done if the method has already been called once.
284If true the further settings read in are added to the current database.
285 
286<br/><code>argument</code><strong> os </strong> (<code>default = <strong>cout</strong></code>) :
287stream for error printout. 
288 
289<br/><b>Note:</b> The method returns false if it fails.
290 
291
292<a name="method4"></a>
293<p/><strong>bool Settings::reInit(string startFile = &quot;../xmldoc/Index.xml&quot;, ostream& os = cout) &nbsp;</strong> <br/>
294overwrite the existing database.
295<br/><code>argument</code><strong> startFile </strong> (<code>default = <strong>&quot;../xmldoc/Index.xml&quot;</strong></code>) :   
296read in the settings from all the files listed in this file, and
297assumed to be located in the same subdirectory.
298 
299<br/><code>argument</code><strong> os </strong> (<code>default = <strong>cout</strong></code>) :
300stream for error printout. 
301 
302<br/><b>Note:</b> The method returns false if it fails.
303 
304
305<a name="method5"></a>
306<p/><strong>bool Settings::readString(string line, bool warn = true, ostream& os = cout) &nbsp;</strong> <br/>
307read in a string, and change the relevant quantity in the database.
308It is normally used indirectly, via
309<code>Pythia::readString(...)</code> and
310<code>Pythia::readFile(...)</code>.
311<br/><code>argument</code><strong> line </strong>  :
312the string to be interpreted as an instruction.
313 
314<br/><code>argument</code><strong> warn </strong> (<code>default = <strong>true</strong></code>) :
315write a warning message or not whenever the instruction does not make
316sense, e.g. if the variable does not exist in the databases.
317 
318<br/><code>argument</code><strong> os </strong> (<code>default = <strong>cout</strong></code>) :
319stream for error printout. 
320 
321<br/><b>Note:</b> the method returns false if it fails to
322make sense out of the input string.
323 
324
325<a name="method6"></a>
326<p/><strong>bool Settings::writeFile(string toFile, bool writeAll = false) &nbsp;</strong> <br/>
327 
328<strong>bool Settings::writeFile(ostream& os = cout, bool writeAll = false) &nbsp;</strong> <br/>
329write current settings to a file or to an <code>ostream</code>.
330<br/><code>argument</code><strong> toFile, os </strong>  :
331file or stream on which settings are written. 
332 
333<br/><code>argument</code><strong> writeAll </strong> (<code>default = <strong>false</strong></code>) :
334normally only settings that have been changed are written,
335but if true then all settings are output.
336 
337<br/><b>Note:</b> the method returns false if it fails.
338 
339
340<a name="method7"></a>
341<p/><strong>void Settings::listAll(ostream& os = cout) &nbsp;</strong> <br/>
342 
343<strong>void Settings::listChanged(ostream& os = cout) &nbsp;</strong> <br/>
344 
345<strong>void Settings::list(string match, ostream& os = cout) &nbsp;</strong> <br/>
346list all or changed settings, or a group of them.
347<br/><code>argument</code><strong> match </strong>  :
348list all those settings where the name contains
349the <code>match</code> (sub)string (case-insensitive).
350 
351<br/><code>argument</code><strong> os </strong> (<code>default = <strong>cout</strong></code>) :
352output stream for the listing.
353 
354 
355
356<a name="method8"></a>
357<p/><strong>void Settings::resetAll() &nbsp;</strong> <br/>
358reset all current values to their defaults.
359 
360
361<a name="method9"></a>
362<p/><strong>bool Settings::isFlag(string key) &nbsp;</strong> <br/>
363 
364<strong>bool Settings::isMode(string key) &nbsp;</strong> <br/>
365 
366<strong>bool Settings::isParm(string key) &nbsp;</strong> <br/>
367 
368<strong>bool Settings::isWord(string key) &nbsp;</strong> <br/>
369return true if an entry of the given name and kind
370exists, else false.
371 
372
373<a name="method10"></a>
374<p/><strong>void Settings::addFlag(string key, bool default) &nbsp;</strong> <br/>
375 
376<strong>void Settings::addMode(string key, int default, bool hasMin, bool hasMax, int min, int max) &nbsp;</strong> <br/>
377 
378<strong>void Settings::addParm(string key, double default, bool hasMin, bool hasMax, double min, double max) &nbsp;</strong> <br/>
379 
380<strong>void Settings::addWord(string key, string default) &nbsp;</strong> <br/>
381add an entry of the respective kind to the database. The name and default
382value always has to be supplied, for <code>Mode</code> and
383<code>Word</code> additionally if lower and/or upper limits are to be
384imposed and, if so, what those limit are.
385 
386
387<a name="method11"></a>
388<p/><strong>bool Settings::flag(string key) &nbsp;</strong> <br/>
389 
390<strong>int Settings::mode(string key) &nbsp;</strong> <br/>
391 
392<strong>double Settings::parm(string key) &nbsp;</strong> <br/>
393 
394<strong>string Settings::word(string key) &nbsp;</strong> <br/>
395return the current value of the respective setting. If the name
396does not exist in the database, a value <code>false</code>,
397<code>0</code>, <code>0.</code> and <code>&quot; &quot;</code> 
398is returned, respectively.
399 
400
401<a name="method12"></a>
402<p/><strong>map<string, Flag> Settings::getFlagMap(string match) &nbsp;</strong> <br/>
403 
404<strong>map<string, Mode> Settings::getModeMap(string match) &nbsp;</strong> <br/>
405 
406<strong>map<string, Parm> Settings::getParmMap(string match) &nbsp;</strong> <br/>
407 
408<strong>map<string, Word> Settings::getWordMap(string match) &nbsp;</strong> <br/>
409return a map of all settings of the respective type that contain the
410string "match" in its name.
411 
412
413<a name="method13"></a>
414<p/><strong>void Settings::flag(string key, bool now) &nbsp;</strong> <br/>
415 
416<strong>void Settings::mode(string key, int now) &nbsp;</strong> <br/>
417 
418<strong>void Settings::parm(string key, double now) &nbsp;</strong> <br/>
419 
420<strong>void Settings::word(string key, string now) &nbsp;</strong> <br/>
421change the current value of the respective setting to the provided
422new value. If lower or upper limits have been set, input values
423outside the allowed range are reinterpreted as being a the nearest
424limit.
425 
426
427<a name="method14"></a>
428<p/><strong>void Settings::forceMode(string key, int now) &nbsp;</strong> <br/>
429 
430<strong>void Settings::forceParm(string key, double now) &nbsp;</strong> <br/>
431as above, but do not check lower and upper limits, so that the current
432value can be put outside the intended borders.
433 
434
435<a name="method15"></a>
436<p/><strong>void Settings::resetFlag(string key) &nbsp;</strong> <br/>
437 
438<strong>void Settings::resetMode(string key) &nbsp;</strong> <br/>
439 
440<strong>void Settings::resetParm(string key) &nbsp;</strong> <br/>
441 
442<strong>void Settings::resetWord(string key) &nbsp;</strong> <br/>
443reset the current value to the default one.
444 
445
446</body>
447</html>
448
449<!-- Copyright (C) 2012 Torbjorn Sjostrand -->
Note: See TracBrowser for help on using the repository browser.