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