<chapter name="Main-Program and Related Settings"> 
 
<h2>Main-Program and Related Settings</h2> 
 
<h3>Introduction</h3> 
 
The main program is up to the user to write. However, 
<aloc href="SampleMainPrograms">sample main programs</aloc> 
are provided. In one such class of programs, key settings of the run 
are read in from a "cards file". For experimental collaborations 
this is actually the most common way to run a program like PYTHIA. 
The commands in such a file may be of two types<br/> 
(a) instructions directly to <code>Pythia</code>, like which 
processes to generate, and<br/> 
(b) instructions to the main program for what it should do, 
like how many events to generate, and how many events should 
be listed.<br/> 
In principle these two kinds could be kept completely separate. 
However, to make life simpler, a few useful main-program 
settings are defined on this page, so that they are recognized by 
the <code>Settings</code> machinery. They can thus be put among 
the other cards without distinction. It is up to you to decide which 
ones, if any, you actually want to use when you write your main program. 
 
<p/> 
To further reduce the necessary amount of main-program code, some of 
the tasks that you can steer from your main program can also be done 
internally. This in particular relates to some information printing. 
To give an example, <code>pythia.event.list()</code> can be inserted 
to print an event, i.e. all the particles belonging to it. Given the 
length of these listings one would list only a few events at the 
beginning of the run, to get some feeling for the character of events. 
This could be achieved e.g. with a main-program statement<br/> 
<code>   if (iEvent &lt; 3) pythia.event.list()</code><br/> 
to list the first three events in a loop over <code>iEvent</code>, 
after <code>pythia.next()</code> has been used to generate the next 
event. Alternatively a <code>Next:numberShowEvent = 3</code> 
setting, e.g. in a command file, would achieve the same, by an 
internal call at the end of <code>pythia.next()</code>. 
 
<p/> 
The settings names on this page thus fall into four main groups 
<ul> 
<li><code>Init:...</code> denote actions that automatically may be 
taken during the <code>pythia.init()</code> call.</li> 
<li><code>Next:...</code> denote actions that automatically may be 
taken during the <code>pythia.next()</code> call.</li> 
<li><code>Stat:...</code> denote actions that automatically may be 
taken during the <code>pythia.stat()</code> call.</li> 
<li><code>Main:...</code> denote actions that you yourself 
have the freedom to make use of in your main program.</li> 
</ul> 
 
<h3>Initialization settings</h3> 
 
<flag name="Init:showProcesses" default="on"> 
Print a list of all processes that will be simulated, with 
their estimated cross section maxima, as used for the 
subsequent Monte Carlo selection. Also print corresponding 
Les Houches initialization data, where relevant. 
</flag> 
 
<flag name="Init:showMultipartonInteractions" default="on"> 
Print initialization information for the multiparton interactions 
machinery. 
</flag> 
 
<flag name="Init:showChangedSettings" default="on"> 
Print a list of the changed flag/mode/parameter/word settings. 
</flag> 
 
<flag name="Init:showAllSettings" default="off"> 
Print a list of all flag/mode/parameter/word settings. 
Warning: this will be a long list. 
</flag> 
 
<flag name="Init:showChangedParticleData" default="on"> 
Print a list of particle and decay data for those particles 
that were changed (one way or another). 
</flag> 
 
<flag name="Init:showChangedResonanceData" default="off"> 
In the previous listing also include the resonances that are 
initialized at the beginning of a run and thus get new particle 
data, even if these may well agree with the default ones. 
Warning: this will be a rather long list. 
</flag> 
 
<flag name="Init:showAllParticleData" default="off"> 
Print a list of all particle and decay data. 
Warning: this will be a long list. 
</flag> 
 
<modeopen name="Init:showOneParticleData" default="0" min="0"> 
Print particle and decay data for the particle with this particular 
identity code. Default means that no particle is printed. 
</modeopen> 
 
<h3>Event-generation settings</h3> 
 
<modeopen name="Next:numberCount" default="1000" min="0"> 
Print a line telling how many events have been generated so far, once 
every <code>numberCount</code> events. If set zero then no lines are 
ever printed. 
<br/>In <code>include/Pythia8Plugins/ProgressLog.h</code> an alternative 
method is implemented that intermittently prints out run progress 
information, reports on CPU usage and estimates when the run will end. 
It is used in the <code>main111.cc</code> example. 
</modeopen> 
 
<modeopen name="Next:numberShowLHA" default="1" min="0"> 
The number of events to list the Les Houches input information for, 
where relevant. 
</modeopen> 
 
<modeopen name="Next:numberShowInfo" default="1" min="0"> 
The number of events to list the <code>Info</code> information for, 
where relevant. 
</modeopen> 
 
<modeopen name="Next:numberShowProcess" default="1" min="0"> 
The number of events to list the <code>process</code> record for, 
where relevant. 
</modeopen> 
 
<modeopen name="Next:numberShowEvent" default="1" min="0"> 
The number of events to list the <code>event</code> record for, 
where relevant. 
</modeopen> 
 
<flag name="Next:showScaleAndVertex" default="off"> 
In addition to the normal information in the listing of the 
<code>process</code> and <code>event</code> records, a second line 
per particle provides information on the production scale, 
particle polarization and production vertex. 
</flag> 
 
<flag name="Next:showMothersAndDaughters" default="off"> 
In addition to the normal information in the listing of the 
<code>process</code> and <code>event</code> records, further lines 
list all the mothers and daughters of each particle. 
</flag> 
 
<h3>Statistics</h3> 
 
<flag name="Stat:showProcessLevel" default="on"> 
Print the available statistics on number of generated events and 
cross sections, where relevant. 
</flag> 
 
<flag name="Stat:showPartonLevel" default="off"> 
Print the available statistics on number and types of multiparton 
interactions, where relevant. 
</flag> 
 
<flag name="Stat:showErrors" default="on"> 
Print the available statistics on number and types of 
aborts, errors and warnings. 
</flag> 
 
<flag name="Stat:reset" default="off"> 
Reset the statistics of the above three kinds. The default is that 
all stored statistics information is unaffected by the 
<code>pythia.stat()</code> call. Counters are automatically reset 
in each new <code>pythia.init()</code> call, however, so the only time 
the reset option makes a difference is if <code>stat()</code> 
is called several times in a (sub)run. 
</flag> 
 
<h3>Main-program settings</h3> 
 
The settings in this section <i>must</i> be under the control of the 
user, i.e. there are no internal equivalents. The first one is especially 
important and would be a standard feature of any separate command file. 
 
<modeopen name="Main:numberOfEvents" default="1000" min="0"> 
The number of events to be generated. 
</modeopen> 
 
<modeopen name="Main:numberOfTriedEvents" default="0" min="0"> 
The number of events to be tried during generation. Any number smaller 
than one means that the setting will be ignored. 
</modeopen> 
 
<modeopen name="Main:numberOfSelectedEvents" default="0" min="0"> 
The number of events to be selected during generation. Any number smaller than 
one means that the setting will be ignored. 
</modeopen> 
 
<modeopen name="Main:numberOfAcceptedEvents" default="0" min="0"> 
The number of events to be accepted during generation. Any number smaller than 
one means that the setting will be ignored. 
</modeopen> 
 
<modeopen name="Main:timesAllowErrors" default="10" min = "0"> 
Allow this many times that <code>pythia.next()</code> returns false, 
i.e. that an event is flawed, before aborting the run. 
</modeopen> 
 
<p/> 
The <code>Main:...</code> options works like this. Once you have used 
the <code>pythia.readFile(fileName)</code> method to read in the cards 
file, where the values have been set, you can interrogate the 
<code>Settings</code> database to make the values available in your 
main program. A slight complication is that you need to use a different 
<code>Settings</code> method for each of the four possible return types 
that you want to extract. To save some typing the same method names are 
found directly in the <code>Pythia</code> class, and these just send on 
to the <code>Settings</code> ones to do the job, e.g.<br/> 
<code>   int nEvent = pythia.mode("Main:numberOfEvents"); </code> 
 
<p/> 
The area of subruns is covered separately below. A few spares are also 
defined after that, for unforeseen applications. 
 
<h3>Subruns</h3> 
 
You can use <aloc href="ProgramFlow">subruns</aloc> to carry out 
several tasks in the same run. In that case you will need repeated 
instances of the first setting below in your command file, and could 
additionally use the second and third as well. 
 
<modeopen name="Main:subrun" default="-999" min="0"> 
The number of the current subrun, a non-negative integer, put as 
first line in a section of lines to be read for this particular subrun. 
</modeopen> 
 
<flag name="Main:LHEFskipInit" default="off"> 
If you read several Les Houches Event Files that you want to see 
considered as one single combined event sample you can set this flag 
<code>on</code> after the first subrun to skip (most of) the 
(re-)initialization step. 
</flag> 
 
<modeopen name="Main:numberOfSubruns" default="0" min = "0"> 
The number of subruns you intend to use in your current run. 
Unlike the two settings above, <code>Pythia</code> itself will not 
interpret this number, but you could e.g. have a loop in your main 
program to loop over subruns from 0 through 
<code>numberOfSubruns - 1</code>. 
</modeopen> 
 
<h3>Spares</h3> 
 
For currently unforeseen purposes, a few dummy settings are made 
available here. The user can set the desired value in a "cards file" 
and then use that value in the main program as desired. 
 
<flag name="Main:spareFlag1" default="off"> 
</flag> 
 
<flag name="Main:spareFlag2" default="off"> 
</flag> 
 
<flag name="Main:spareFlag3" default="off"> 
</flag> 
 
<modeopen name="Main:spareMode1" default="0"> 
</modeopen> 
 
<modeopen name="Main:spareMode2" default="0"> 
</modeopen> 
 
<modeopen name="Main:spareMode3" default="0"> 
</modeopen> 
 
<parm name="Main:spareParm1" default="0."> 
</parm> 
 
<parm name="Main:spareParm2" default="0."> 
</parm> 
 
<parm name="Main:spareParm3" default="0."> 
</parm> 
 
<word name="Main:spareWord1" default="void"> 
</word> 
 
<word name="Main:spareWord2" default="void"> 
</word> 
 
<word name="Main:spareWord3" default="void"> 
</word> 
 
</chapter> 
 
<!-- Copyright (C) 2020 Torbjorn Sjostrand --> 
