source: HiSusy/trunk/Pythia8/pythia8170/xmldoc/ProgramFlow.xml @ 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: 46.1 KB
Line 
1<chapter name="Program Flow">
2
3<h2>Program Flow</h2>
4
5Recall that, to first order, the event generation process can be
6subdivided into three stages:
7<ol>
8<li>Initializaion.</li>
9<li>The event loop.</li>
10<li>Finishing.</li>
11</ol>
12This is reflected in how the top-level <code>Pythia</code> class should
13be used in the user-supplied main program, further outlined in the
14following. Since the nature of the run is defined at the initialization
15stage, this is where most of the PYTHIA user code has to be written.
16So as not to confuse the reader unduly, the description of initialization
17options has been subdivided into what would normally be used and what is
18intended for more special applications.
19
20<p/>
21At the bottom of this webpge is a complete survey of all public
22<code>Pythia</code> methods and data members, in a more formal style
23than the task-oriented descriptions found in the preceding sections.
24This offers complementary information. 
25   
26<h3>Initialization - normal usage</h3>
27
28<ol>
29
30<li>
31Already at the top of the main program file, you need to include the proper
32header file
33<pre>
34    #include "Pythia.h"
35</pre>
36To simplify typing, it also makes sense to declare
37<pre>
38    using namespace Pythia8;
39</pre>
40</li>
41
42<p/>
43<li>
44The first step is to create a generator object,
45e.g. with
46<pre>
47     Pythia pythia;
48</pre>
49It is this object that we will use from now on. Normally a run
50will only contain one <code>Pythia</code> object. (But you can
51use several <code>Pythia</code> objects, which then will be
52independent of each other.)<br/>
53By default all output from <code>Pythia</code> will be on the
54<code>cout</code> stream, but the <code>list</code> methods below do
55allow output to alternative streams or files.
56</li> 
57
58<p/>
59<li> 
60You next want to set up the character of the run.
61The pages under the "Setup Run Tasks" heading in the index
62describe all the options available (with some very few exceptions,
63found on the other pages). 
64The default values and your modifications are stored in two databases,
65one for <aloc href="SettingsScheme">generic settings</aloc>
66and one for <aloc href="ParticleDataScheme">particle data</aloc>.
67Both of these are initialized with their default values by the
68<code>Pythia</code> constructor. The default values can then be
69changed, primarily by one of the two ways below, or by a combination
70of them.
71
72<p/>
73a) You can use the
74<pre>
75    pythia.readString(string);
76</pre>
77method repeatedly to do a change of a property at a time.
78The information in the string is case-insensitive, but upper- and
79lowercase can be combined for clarity. The rules are that<br/>
80(i) if the first nonblank character of the string is a letter
81it is assumed to contain a setting, and is sent on to
82<code>pythia.settings.readString(string)</code>;<br/> 
83(ii) if instead the string begins with a digit it is assumed to
84contain particle data updates, and so sent on to
85<code>pythia.particleData.readString(string)</code>;<br/>
86(iii) if none of the above, the string is assumed to be a comment,
87i.e. nothing will be done.<br/>
88In the former two cases, a warning is issued whenever a string
89cannot be recognized (maybe because of a spelling mistake).<br/>
90Some examples would be
91<pre>
92    pythia.readString("TimeShower:pTmin = 1.0");
93    pythia.readString("111:mayDecay = false");
94</pre>
95The <code>readString(string)</code> method is intended primarily for
96a few changes. It can also be useful if you want to construct a
97parser for input files that contain commands both to PYTHIA and to
98other libraries.<br/>
99
100<p/>
101b) You can read in a file containing a list of those variables
102you want to see changed, with a
103<pre>
104    pythia.readFile(fileName);
105</pre>
106Each line in this file with be processes by the
107<code>readString(string)</code> method introduced above. You can thus
108freely mix comment lines and lines handed on to <code>Settings</code> 
109or to <code>ParticleData</code>.<br/>
110This approach is better suited for more extensive changes than a direct
111usage of <code>readString(string)</code>, and can also avoid having to
112recompile and relink your main program between runs.<br/>
113It is also possible to read input from an <code>istream</code>, by
114default <code>cin</code>, rather than from a file. This may be convenient
115if information is generated on-the-fly, within the same run.
116
117<p/>
118Changes are made sequentially in the order the commands are encountered
119during execution, meaning that if a parameter is changed several times
120it is the last one that counts. The two special
121<code><aloc href="Tunes">Tune:ee</aloc></code> and
122<code><aloc href="Tunes">Tune:pp</aloc></code> 
123modes are expanded to change several settings in one go, but these obey
124the same ordering rules.
125<br/> 
126</li>
127
128<p/>
129<li>
130Next comes the initialization stage, where all
131remaining details of the generation are to be specified.
132There is one standard method to use for this
133
134<p/>
135<code>pythia.init();</code><br/>
136with no arguments will read all relevant information from the
137<code><aloc href="SettingsScheme">Settings</aloc></code>
138and <code><aloc href="ParticleDataScheme">ParticleData</aloc></code> 
139databases. Specifically the setup of incoming beams and energies
140is governed by the the beam parameters from the
141<code><aloc href="BeamParameters">Beams</aloc></code> 
142group of variables. If you don't change any of those you will
143default to proton-proton collisions at 14 TeV, i.e. the nominal LHC
144values.
145
146<p/> 
147A few alternative forms are available, where the arguments of the
148<code>init(...)</code> call can be used to set the beam parameters.
149These alternatives are now deprecated, and will bew removed for
150PYTHIA 8.2. 
151
152<p/>
153a) <code>pythia.init( idA, idB, eCM);</code><br/>
154lets you specify the identities and the CM energy of the two incoming
155beam particles, with A (B) assumed moving in the <ei>+z (-z)</ei> 
156direction.
157
158<p/>
159b) <code>pythia.init( idA, idB, eA, eB);</code><br/>
160is similar, but the two beam energies can be different, so the
161collisions do not occur in the CM frame. If one of the beam energies
162is below the particle mass you obtain a fixed-target topology.
163
164<p/>
165c) <code>pythia.init( idA, idB, pxA, pyA, pzA, pxB, pyB, pzB);</code><br/>
166is similar, but here you provide the three-momenta
167<ei>(p_x, p_y, p_z)</ei> of the two incoming particles,
168to allow for arbitrary beam directions.
169
170<p/>
171d) <code>pythia.init(fileName);</code> <br/> 
172assumes a file in the <aloc href="LesHouchesAccord">Les Houches
173Event File</aloc> format is provided.
174
175<p/>
176e) <code>pythia.init( LHAup*);</code> <br/>
177assumes <aloc href="LesHouchesAccord">Les Houches Accord</aloc> 
178initialization and event information is available in an <code>LHAup</code> 
179class object, and that a pointer to this object is handed in.
180
181<p/>
182<li>
183If you want to have a list of the generator and particle data used,
184either only what has been changed or everything, you can use
185<pre>
186    pythia.settings.listChanged();
187    pythia.settings.listAll();
188    pythia.particleData.listChanged();
189    pythia.particleData.listAll();
190</pre>
191</li>
192
193</ol>
194
195<h3>The event loop</h3>
196
197<ol>
198
199<li>
200Inside the event generation loop you generate the
201next event using the <code>next()</code> method,
202<pre>
203    pythia.next();
204</pre>
205This method takes no arguments; everything has already been specified.
206It does return a bool value, however, <code>false</code> when the
207generation failed. This can be a "programmed death" when the
208supply of input parton-level configurations on file is exhausted.
209It can alternatively signal a failure of <code>Pythia</code> to
210generate an event, or unphysical features in the event record at the
211end of the generation step. It makes sense to allow a few <code>false</code> 
212values before a run is aborted, so long as the related faulty
213events are skipped.
214</li> 
215 
216<p/>
217<li>
218The generated event is now stored in the <code>event</code> 
219object, of type <code><aloc href="EventRecord">Event</aloc></code>,
220which is a public member of <code>pythia</code>. You therefore have
221access to all the tools described on the pages under the "Study Output"
222header in the index. For instance, an event can be listed with
223<code>pythia.event.list()</code>, the identity of the <ei>i</ei>'th
224<aloc href="ParticleProperties">particle</aloc> is given by
225<code>pythia.event[i].id()</code>, and so on.<br/> 
226The hard process - roughly the information normally stored in the
227Les Houches Accord event record - is available as a second object,
228<code>process</code>, also of type <code>Event</code>.<br/> 
229A third useful public object is
230<code><aloc href="EventInformation">info</aloc></code>, which offers
231a set of one-of-a kind pieces of information about the most recent
232event.
233</li> 
234
235</ol>
236
237<h3>Finishing</h3>
238
239<ol>
240
241<li>At the end of the generation process, you can call
242<pre>
243    pythia.stat();
244</pre>
245to get some run statistics, on cross sections and the number of errors
246and warnings encountered. The alternative
247<code>pythia.statistics(...);</code> is equivalent but deprecated.
248</li> 
249
250</ol>
251
252<h3>Advanced usage, mainly for initialization</h3>
253
254A) Necessary data are automatically loaded when you use the
255default PYTHIA installation directory structure and run the main
256programs in the <code>examples</code> subdirectory. However, in the
257general case, you must provide the path of the <code>xmldoc</code> 
258directory, where default settings and particle data are found.
259This can be done in two ways.
260
261<ol>
262
263<li>
264You can set the environment variable <code>PYTHIA8DATA</code> to
265contain the location of the <code>xmldoc</code> directory. In the
266<code>csh</code> and <code>tcsh</code> shells this could e.g. be
267<pre>
268     setenv PYTHIA8DATA /home/myname/pythia81xx/xmldoc
269</pre>
270while in other shells it could be
271<pre>
272     export PYTHIA8DATA=/home/myname/pythia81xx/xmldoc
273</pre>
274where xx is the subversion number.<br/>
275Recall that environment variables set locally are only defined in the
276current instance of the shell. The above lines should go into your
277<code>.cshrc</code> and <code>.bashrc</code> files, respectively,
278if you want a more permanant assignment.
279</li>
280
281<p/>
282<li>
283You can provide the path as argument to the <code>Pythia</code>
284constructor, e.g.
285<pre>
286     Pythia pythia("/home/myname/pythia81xx/xmldoc");
287</pre>
288</li>
289</ol>
290where again xx is the subversion number.<br/>
291When <code>PYTHIA8DATA</code> is set it takes precedence, else
292the path in the constructor is used, else one defaults to the
293<code>../xmldoc</code> directory.
294
295<p/>
296B) You can override the default behaviour of PYTHIA not only by the
297settings and particle data, but also by replacing some of the
298PYTHIA standard routines by ones of your own. Of course, this is only
299possible if your routines fit into the general PYTHIA framework.
300Therefore they must be coded according to the the rules relevant
301in each case, as a derived class of a PYTHIA base class, and a pointer
302to such an object must be handed in by one of the methods below.
303These calls must be made before the <code>pythia.init(...)</code> call.
304
305<ol>
306
307<li>
308If you are not satisfied with the list of parton density functions that
309are implemented internally or available via the LHAPDF interface
310(see the <aloc href="PDFSelection">PDF Selection</aloc> page), you
311can suppy your own by a call to the <code>setPDFPtr(...)</code> method
312<pre>
313      pythia.setPDFptr( pdfAPtr, pdfBPtr);
314</pre>
315where <code>pdfAPtr</code> and <code>pdfBPtr</code> are pointers to
316two <code>Pythia</code> <aloc href="PartonDistributions">PDF
317objects</aloc>. Note that <code>pdfAPtr</code> and <code>pdfBPtr</code> 
318cannot point to the same object; even if the PDF set is the same,
319two copies are needed to keep track of two separate sets of <ei>x</ei>
320and density values.<br/>
321If you further wish to use separate PDF's for the hard process of an
322event than the ones being used for everything else, the extended form
323<pre>
324      pythia.setPDFptr( pdfAPtr, pdfBPtr, pdfHardAPtr, pdfHardBPtr);
325</pre>
326allows you to specify those separately, and then the first two sets
327would only be used for the showers and for multiparton interactions.
328</li>
329
330<p/>
331<li>
332If you want to link to an external generator that feeds in events
333in the LHA format, you can call the <code>setLHAupPtr(...)</code>
334method
335<pre>
336      pythia.setLHAupPtr( lhaUpPtr);
337</pre>
338where the  <code>lhaUpPtr</code> derives from the
339<aloc href="LesHouchesAccord">LHAup</aloc> base class.
340</li>
341
342<p/>
343<li>
344If you want to perform some particle decays with an
345external generator, you can call the <code>setDecayPtr(...)</code> 
346method
347<pre>
348      pythia.setDecayPtr( decayHandlePtr, particles);
349</pre>
350where the <code>decayHandlePtr</code> derives from the
351<code><aloc href="ExternalDecays">DecayHandler</aloc></code> base
352class and <code>particles</code> is a vector of particle codes to be
353handled.
354</li>
355
356<p/>
357<li>
358If you want to use an external random number generator,
359you can call the <code>setRndmEnginePtr(...)</code> method
360<pre>
361      pythia.setRndmEnginePtr( rndmEnginePtr);
362</pre>
363where <code>rndmEnginePtr</code> derives from the
364<code><aloc href="RandomNumbers">RndmEngine</aloc></code> base class.
365The <code>Pythia</code> default random number generator is perfectly
366good, so this is only intended for consistency in bigger frameworks.
367</li>
368
369<p/>
370<li>
371If you want to interrupt the evolution at various stages,
372to interrogate the event and possibly veto it, or you want to
373reweight the cross section, you can use   
374<pre>
375      pythia.setUserHooksPtr( userHooksPtr);
376</pre>
377where <code>userHooksPtr</code> derives from the
378<code><aloc href="UserHooks">UserHooks</aloc></code> base class.
379</li>
380
381<p/>
382<li>
383If you want to use your own merging scale definition for
384matrix element + parton shower merging, you can call   
385<pre>
386      pythia.setMergingHooksPtr( mergingHooksPtr);
387</pre>
388where <code>mergingHooksPtr</code> derives from the
389<code><aloc href="MatrixElementMerging">MergingHooks</aloc></code> base class.
390</li>
391
392<p/>
393<li>
394If you want to use your own parametrization of beam momentum spread and
395interaction vertex, rather than the provided simple Gaussian
396parametrization (off by default), you can call
397<pre>
398      pythia.setBeamShapePtr( beamShapePtr);
399</pre>
400where <code>beamShapePtr</code> derives from the
401<code><aloc href="BeamShape">BeamShape</aloc></code> base class.
402</li>
403
404<p/>
405<li>
406If you want to implement a cross section of your own, but still make use
407of the built-in phase space selection machinery, you can use
408<pre>
409      pythia.setSigmaPtr( sigmaPtr);
410</pre>
411where <code>sigmaPtr</code> of type <code>SigmaProcess*</code> is an
412instance of a class derived from one of the <code>Sigma1Process</code>,
413<code>Sigma2Process</code> and  <code>Sigma3Process</code> base classes
414in their turn derived from
415<code><aloc href="SemiInternalProcesses">SigmaProcess</aloc></code>.
416This call can be used repeatedly to hand in several different processes.
417</li>
418
419<p/>
420<li>
421If your cross section contains the production of a new resonance
422with known analytical expression for all the relevant partial widths,
423you can make this resonance available to the program with
424<pre>
425      pythia.setResonancePtr( resonancePtr);
426</pre>
427where <code>resonancePtr</code> of type <code>ResonanceWidths*</code> 
428is an instance of a class derived from the
429<code><aloc href="SemiInternalResonances">ResonanceWidths</aloc></code> 
430base class. In addition you need to add the particle to the normal
431<aloc href="ParticleDataScheme">particle and decay database</aloc>.
432This procedure can be used repeatedly to hand in several different
433resonances.
434</li>
435
436<p/>
437<li>
438If you are a real expert and want to <aloc href="ImplementNewShowers">replace
439the PYTHIA initial- and final-state showers</aloc>, you can use
440<pre>
441      pythia.setShowerPtr( timesDecPtr, timesPtr, spacePtr);
442</pre>
443where <code>timesDecPtr</code> and <code>timesPtr</code>
444derive from the <code>TimeShower</code> base class, and
445<code>spacePtr</code> from <code>SpaceShower</code>.
446</li>
447
448</ol>
449
450<p/>
451C) Some comments on collecting several tasks in the same run.
452<ol>
453
454<li>
455PYTHIA has not been written for threadsafe execution on multicore
456processors. If you want to use all cores,
457the most efficient way presumably is to start correspondingly many jobs,
458with different random number seeds, and add the statistics at the end.
459However, note that several instances  can be set up in the same main
460program, since instances are completely independent of each other,
461so each instance could be run inside a separate thread.
462</li>
463
464<p/>
465<li>
466In some cases it is convenient to use more than one <code>Pythia</code> 
467object. The key example would be the simultaneous generation of signal
468and pileup events, see <code>main19.cc</code>. The two objects are then
469set up and initialized separately, and generate events completely
470independently of each other. It is only afterwards that the event records
471are combined into one single super-event per beam crossing.
472</li>
473
474<p/>
475<li>
476When time is not an issue, it may be that you want to perform several
477separate subruns sequentially inside a run, e.g. to combine results for
478several kinematical regions or to compare results for some different
479tunes of the underlying event. One way to go is to create (and destroy)
480one <code>pythia</code> object for each subrun, in which case they are
481completely separate. You can also use the same <code>pythia</code> object,
482only doing a new <code>init(...)</code> call for each subrun. In that
483case, the settings and particle databases remain as they were in the 
484previous subrun, only affected by the specific changes you introduced in
485the meantime. You can put those changes in the main program, with
486<code>pythia.readString(string)</code>, using your own logic to decide
487which ones to execute in which subrun. A corresponding possibility
488exists with <code>pythia.readFile(fileName, subrun)</code> (or an
489<code>istream</code> instead of a <code>fileName</code>), which as second
490argument can take a non-negative subrun number. Then only those
491sections of the file before any <code>Main:subrun = ...</code> line
492or with matching <code>subrun</code> number will be read. That is, the
493file could have a structure like
494<pre>
495    ( lines always read, i.e. "default values" always (re)set )
496    Main:subrun = 1
497    ( lines only read with readFile(fileName, 1) )
498    Main:subrun = 2
499    ( lines only read with readFile(fileName, 2) )
500</pre>
501Both of these possibilities are illustrated in <code>main08.cc</code>.
502</li>
503
504<p/>
505<li>
506When working with Les Houches Event Files, it may well be that your
507intended input event sample is spread over several files, that you all
508want to turn into complete events in one and the same run. There is no
509problem with looping over several subruns, where each new subrun
510is initialized with a new file, with name set in <code>Beams:LHEF</code>.
511However, in that case you will do a complete re-initialization each time
512around. If you want to avoid this, note that the flag
513<code>Beams:newLHEFsameInit = true</code> can be set for the second and
514subsequent subruns. Then the new file will be simulated with the same
515initialization data as already set in a previous
516<code>pythia.init()</code> call. The burden rests on you to ensure
517that this is indeed correct, e.g. that the two event samples have not
518been generated for different beam energies. Also note that cross
519sections for processes will be based on the information in the
520first-read file, when the full initialization is performed.
521</li>
522
523</ol>
524
525<h2>The Pythia Class</h2>
526
527Here follows the complete survey of all public <code>Pythia</code> 
528methods and data members.   
529
530<h3>Constructor and destructor</h3>
531
532<method name="Pythia::Pythia(string xmlDir = &quot;../xmldoc&quot;)">
533creates an instance of the <code>Pythia</code> event generators,
534and sets initial default values, notably for all settings and
535particle data. You may use several <code>Pythia</code> instances
536in the same run; only when you want to access external static
537libraries could this cause problems. (This includes in particular
538Fortran libraries such as <aloc href="PDFSelection">LHAPDF</aloc>.)
539<argument name="xmlDir" default="../xmldoc">allows you to choose
540from which directory the default settings and particle data values
541are read in. If the <code>PYTHIA8DATA</code> environment variable
542has been set it takes precedence. Else this optional argument allows
543you to choose another directory location than the default one. Note
544that it is only the directory location you can change, its contents
545must be the ones of the <code>xmldoc</code> directory in the
546standard distribution.
547</argument>
548</method>
549
550<method name="Pythia::~Pythia">
551the destructor deletes the objects created by the constructor.
552
553<h3>Set up run</h3>
554
555<method name="bool Pythia::readString(string line, bool warn = true)">
556reads in a single string, that is interpreted as an instruction to
557modify the value of a <aloc href="SettingsScheme">setting</aloc> or
558<aloc href="ParticleDataScheme">particle data</aloc>, as already described
559above.
560<argument name="line">
561the string to be interpreted as an instruction.
562</argument>
563<argument name="warn" default="true">
564write a warning message or not whenever the instruction does not make
565sense, e.g. if the variable does not exist in the databases.
566</argument>
567<note>Note:</note> the method returns false if it fails to
568make sense out of the string.
569</method>
570
571<method name="bool Pythia::readFile(string fileName, bool warn = true,
572int subrun = SUBRUNDEFAULT)">
573</method>
574<methodmore name="bool Pythia::readFile(string fileName,
575int subrun = SUBRUNDEFAULT)">
576</methodmore>
577<methodmore name="bool Pythia::readFile(istream& inStream = cin, 
578bool warn = true, int subrun = SUBRUNDEFAULT)">
579</methodmore>
580<methodmore name="bool Pythia::readFile(istream& inStream = cin,
581int subrun = SUBRUNDEFAULT)">
582reads in a whole file, where each line is interpreted as an instruction
583to modify the value of a <aloc href="SettingsScheme">setting</aloc> or
584<aloc href="ParticleDataScheme">particle data</aloc>, cf. the above
585<code>readString</code> method. All four forms of the
586<code>readFile</code> command share code for actually reading a file.
587<argument name="fileName">
588the file from which instructions are read.
589</argument>
590<argument name="inStream">
591an istream from which instructions are read.
592</argument>
593<argument name="warn" default="true">
594write a warning message or not whenever the instruction does not make
595sense, e.g. if the variable does not exist in the databases. In the
596command forms where <code>warn</code> is omitted it is true.
597</argument>
598<argument name="subrun">
599allows you have several optional sets of commands within the same file.
600Only those sections of the file before any <code>Main:subrun = ...</code> 
601line or following such a line with matching subrun number will be read.
602The subrun number should not be negative; negative codes like
603<code>SUBRUNDEFAULT</code> corresponds to no specific subrun.
604</argument>
605<note>Note:</note> the method returns false if it fails to
606make sense out of any one line.
607</methodmore>
608
609<method name="bool Pythia::setPDFPtr( PDF* pdfAPtr, PDF* pdfBPtr,
610PDF* pdfHardAPtr = 0, PDF* pdfHardBPtr = 0)">
611offers the possibility to link in external PDF sets for usage inside
612the program. The rules for constructing your own class from
613the <code>PDF</code> base class are described
614<aloc href="PartonDistributions">here</aloc>.
615<argument name="pdfAPtr, pdfBPtr"> 
616pointers to two <code>PDF</code>-derived objects, one for each of
617the incoming beams. The two objects have to be instantiated by you
618in your program. Even if the two beam particles are the same
619(protons, say) two separate instances are required, since current
620information is cached in the objects. If both arguments are zero
621then any previous linkage to external PDF's is disconnected,
622see further Note 2 below.
623</argument>
624<argument name="pdfHardAPtr, pdfHardBPtr" default="0"> 
625pointers to two further <code>PDF</code>-derived objects, one for each
626of the incoming beams. Normally only the first two arguments above would
627be used, and then the same PDF sets would be invoked everywhere. If you
628provide these two further pointers then two different sets of PDF's are
629used. This second set is then exclusively for the generation of the hard
630process from the process matrix elements library. The first set above
631is for everything else, notably parton showers and multiparton interactions.
632</argument>
633<note>Note 1:</note> The method returns false if the input is obviously
634incorrect, e.g. if two (nonzero) pointers agree.
635<note>Note 2:</note> If you want to combine several subruns you can
636call <code>setPDFPtr</code> with new arguments before each
637<code>Pythia::init(...)</code> call. To revert from external PDF's
638to the normal internal PDF selection you must call
639<code>setPDFPtr(0, 0)</code> before <code>Pythia::init(...)</code>.
640</method>
641
642<method name="bool Pythia::setLHAupPtr( LHAup* lhaUpPtrIn)">
643offers linkage to an external generator that feeds in events
644in the LHA format, see
645<aloc href="LesHouchesAccord">Les Houches Accord</aloc>,
646assuming that
647<code><aloc href="BeamParameters">Beams:frameType = 5</aloc></code>
648has been set.
649<argument name="lhaUpPtrIn"> 
650pointer to a <code>LHAup</code>-derived object.
651</argument>
652<note>Note:</note> The method currently always returns true.
653</method>
654
655<method name="bool Pythia::setDecayPtr( DecayHandler* decayHandlePtr,
656vector&lt;int&gt; handledParticles)">
657offers the possibility to link to an external program that can do some
658of the particle decays, instad of using the internal decay machinery.
659With particles we here mean the normal hadrons and leptons, not
660top quarks, electroweak bosons or new particles in BSM scenarios.
661The rules for constructing your own class from the
662<code>DecayHandler</code> base class are described
663<aloc href="ExternalDecays">here</aloc>. Note that you can only
664provide one external object, but this object in its turn could
665very well hand on different particles to separate decay libraries.
666<argument name="decayHandlePtr"> 
667pointer to a <code>DecayHandler</code>-derived object. This object
668must be instantiated by you in your program.
669</argument>
670<argument name="handledParticles"> vector with the PDG identity codes
671of the particles that should be handled by the external decay package.
672You should only give the particle (positive) codes; the respective
673antiparticle is always included as well.
674</argument>
675<note>Note:</note> The method currently always returns true.
676</method>
677
678<method name="bool Pythia::setRndmEnginePtr( RndmEngine* rndmEnginePtr)">
679offers the possibility to link to an external random number generator.
680The rules for constructing your own class from the
681<code>RndmEngine</code> base class are described
682<aloc href="RandomNumbers">here</aloc>
683<argument name="rndmEnginePtr"> 
684pointer to a <code>RndmEngine</code>-derived object. This object
685must be instantiated by you in your program.
686</argument>
687<note>Note:</note> The method returns true if the pointer is different
688from 0.
689</method>
690
691<method name="bool Pythia::setUserHooksPtr( UserHooks* userHooksPtr)">
692offers the possibility to interact with the generation process at
693a few different specified points, e.g. to reject undesirable events
694at an early stage to save computer time. The rules for constructing
695your own class from the <code>UserHooks</code> base class are described
696<aloc href="UserHooks">here</aloc>. You can only hand in one such
697pointer, but this may be to a class that implements several of the
698different allowed possibilities.
699<argument name="userHooksPtr"> 
700pointer to a <code>userHooks</code>-derived object. This object
701must be instantiated by you in your program.
702</argument>
703<note>Note:</note> The method currently always returns true.
704</method>
705
706<method name="bool Pythia::setBeamShapePtr( BeamShape* beamShapePtr)">
707offers the possibility to provide your own shape of the momentum and
708space-time spread of the incoming beams. The rules for constructing
709your own class from the <code>BeamShape</code> base class are described
710<aloc href="BeamShape">here</aloc>.
711<argument name="BeamShapePtr"> 
712pointer to a <code>BeamShape</code>-derived object. This object
713must be instantiated by you in your program.
714</argument>
715<note>Note:</note> The method currently always returns true.
716</method>
717
718<method name="bool Pythia::setSigmaPtr( SigmaProcess* sigmaPtr)">
719offers the possibility to link your own implementation of a process
720and its cross section, to make it a part of the normal process
721generation machinery, without having to recompile the
722<code>Pythia</code> library itself.  The rules for constructing your
723own class from the <code>SigmaProcess</code> base class are described
724<aloc href="SemiInternalProcesses">here</aloc>. You may call this
725routine repeatedly, to add as many new processes as you wish.
726<argument name="sigmaPtr"> 
727pointer to a <code>SigmaProcess</code>-derived object. This object
728must be instantiated by you in your program.
729</argument>
730<note>Note:</note> The method currently always returns true.
731</method>
732
733<method name="bool Pythia::setResonancePtr( ResonanceWidths* resonancePtr)">
734offers the possibility to link your own implementation of the
735calculation of partial resonance widths, to make it a part of the
736normal process generation machinery, without having to recompile the
737<code>Pythia</code> library itself.  This allows the decay of new
738resonances to be handled internally, when combined with new particle
739data. Note that the decay of normal hadrons cannot be modelled here;
740this is for New Physics resonances. The rules for constructing your
741own class from the <code>ResonanceWidths</code> base class are described
742<aloc href="SemiInternalResonances">here</aloc>. You may call this
743routine repeatedly, to add as many new resonances as you wish.
744<argument name="resonancePtr"> 
745pointer to a <code>ResonanceWidths</code>-derived object. This object
746must be instantiated by you in your program.
747</argument>
748<note>Note:</note> The method currently always returns true.
749</method>
750
751<method name="bool Pythia::setShowerPtr( TimeShower* timesDecPtr,
752TimeShower* timesPtr = 0, SpaceShower* spacePtr = 0)">
753offers the possibility to link your own parton shower routines as
754replacements for the default ones. This is much more complicated
755since the showers are so central and are so interlinked with other
756parts of the program. Therefore it is also possible to do the
757replacement in stages, from the more independent to the more
758intertwined. The rules for constructing your own classes from the
759<code>TimeShower</code> and <code>SpaceShower</code>base classes
760are described <aloc href="ImplementNewShowers">here</aloc>. These
761objects must be instantiated by you in your program.
762<argument name="timesDecPtr"> 
763pointer to a <code>TimeShower</code>-derived object for doing
764timelike shower evolution in resonance decays, e.g. of a
765<ei>Z^0</ei>. This is decoupled from beam remnants and parton
766distributions, and is therefore the simplest kind of shower
767to write. If you provide a value 0 then the internal shower
768routine will be used.
769</argument>
770<argument name="timesPtr" default="0"> 
771pointer to a <code>TimeShower</code>-derived object for doing
772all other timelike shower evolution, which is normally interleaved
773with multiparton interactions and spacelike showers, introducing
774both further physics and further technical issues. If you retain
775the default value 0 then the internal shower routine will be used.
776You are allowed to use the same pointer as above for the
777<code>timesDecPtr</code> if the same shower can fulfill both tasks.
778</argument>
779<argument name="spacePtr" default="0"> 
780pointer to a <code>SpaceShower</code>-derived object for doing
781all spacelike shower evolution, which is normally interleaved
782with multiparton interactions and timelike showers. If you retain
783the default value 0 then the internal shower routine will be used.
784</argument>
785<note>Note:</note> The method currently always returns true.
786</method>
787
788<h3>Initialize</h3>
789
790At the initialization stage all the information provided above is
791processed, and the stage is set up for the subsequent generation
792of events. Currently several alterative forms of the <code>init</code> 
793method are available for this stage, but only the first one is
794recommended.
795
796<method name="bool Pythia::init()">
797initialize for collisions, in any of the five separate possibilities
798below. In this option the beams are not specified by input arguments,
799but instead by the settings in the
800<aloc href="BeamParameters">Beam Parameters</aloc> section.
801This allows the beams to be specified in the same file as other
802run instructions. The default settings give pp collisions at 14 TeV.
803<note>Note:</note> The method returns false if the
804initialization fails. It is then not possible to generate any
805events.
806</method>
807
808<method name="bool Pythia::init( int idA, int idB, double eCM)">
809initialize for collisions in the center-of-mass frame, with the
810beams moving in the <ei>+-z</ei> directions.
811<argument name="idA, idB"> 
812particle identity code for the two incoming beams.
813</argument>
814<argument name="eCM"> 
815the CM energy of the collisions.
816</argument>
817<note>Notes:</note> Deprecated. The method returns false if the
818initialization fails. It is then not possible to generate any
819events.
820</method>
821
822<method name="bool Pythia::init( int idA, int idB, double eA, double eB)">
823initialize for collisions with back-to-back beams,
824moving in the <ei>+-z</ei> directions, but with different energies.
825<argument name="idA, idB"> 
826particle identity code for the two incoming beams.
827</argument>
828<argument name="eA, eB"> 
829the energies of the two beams. If an energy is set to be below
830the mass of the respective beam particle that particle is taken to
831be at rest. This offers a simple possibility to simulate
832fixed-target collisions.
833</argument>
834<note>Notes:</note> Deprecated. The method returns false if the
835initialization fails. It is then not possible to generate any
836events.
837</method>
838
839<method name="bool Pythia::init( int idA, int idB, double pxA,
840double pyA, double pzA, double pxB, double pyB, double pzB)">
841initialize for collisions with arbitrary beam directions.
842<argument name="idA, idB"> 
843particle identity code for the two incoming beams.
844</argument>
845<argument name="pxA, pyA, pzA"> 
846the three-momntum vector <ei>(p_x, p_y, p_z)</ei> of the first
847incoming beam.
848</argument>
849<argument name="pxB, pyB, pzB"> 
850the three-momntum vector <ei>(p_x, p_y, p_z)</ei> of the second
851incoming beam.
852</argument>
853<note>Notes:</note> Deprecated. The method returns false if the
854initialization fails. It is then not possible to generate any
855events.
856</method>
857
858<method name="bool Pythia::init( string LesHouchesEventFile,
859bool skipInit = false)">
860initialize for hard-process collisions fed in from an external file
861with events, written according to the
862<aloc href="LesHouchesAccord">Les Houches Event File</aloc> 
863standard. 
864<argument name="LesHouchesEventFile"> 
865the file name (including path, where required) where the
866events are stored, including relevant information on beam
867identities and energies.
868</argument>
869<argument name="skipInit" default="false"> 
870By default this method does a complete reinitialization of the
871generation process. If you set this argument to true then
872no reinitialization will occur, only the pointer to the event
873file is updated. This may come in handy if the full event sample
874is split across several files generated under the same conditions
875(except random numbers, of course). You then do the first
876initialization with the default, and all subsequent ones with
877true. Note that things may go wrong if the files are not created
878under the same conditions.
879</argument>
880<note>Notes:</note> Deprecated. The method returns false if the
881initialization fails. It is then not possible to generate any
882events.
883</method>
884
885<method name="bool Pythia::init( LHAup* lhaUpPtr)">
886initialize for hard-process collisions fed in from an external
887source of events, consistent with the Les Houches Accord standard.
888The rules for constructing your own class from the <code>LHAup</code> 
889base class are described <aloc href="LesHouchesAccord">here</aloc>.
890This class is also required to provide the beam parameters.
891<argument name="lhaUpPtr"> 
892pointer to a <code>LHAup</code>-derived object. This object
893must be instantiated by you in your program.
894</argument>
895<note>Notes:</note> Deprecated. The method returns false if the
896initialization fails. It is then not possible to generate any
897events.
898</method>
899
900<h3>Generate events</h3>
901
902The <code>next()</code> method is the main one to generate events.
903In this section we also put a few other specialized methods that
904may be useful in some circumstances.
905
906<method name="bool Pythia::next()">
907generate the next event. No input parameters are required; all
908instructions have already been set up in the initialization stage.
909<note>Note:</note> The method returns false if the event generation
910fails. The event record is then not consistent and should not be
911studied. When reading in hard collisions from a Les Houches Event File
912the problem may be that the end of the file has been reached. This
913can be checked with the
914<code><aloc href="EventInformation">Info::atEndOfFile()</aloc></code> 
915method.
916</method>
917
918<method name="int Pythia::forceTimeShower( int iBeg, int iEnd,
919double pTmax, int nBranchMax = 0)">
920perform a final-state shower evolution on partons in the
921<code>event</code> event record. This could be used for externally
922provided simple events, or even parts of events, for which
923a complete generation is not foreseen. Since the mother source of
924the parton system is not known, one cannot expect as good accuracy
925as in a normal generation. When two different timelike shower
926instances are set up, it is the one used for showering in resonance
927decays that is used here. The <code>forceTimeShower</code> method
928can be used in conjunction with the <code>forceHadronLevel</code> 
929one below. Further comments are found
930<aloc href="HadronLevelStandalone">here</aloc>
931<argument name="iBeg, iEnd"> the first and last entry of the event
932record to be affected by the call.
933</argument>
934<argument name="pTmax"> the maximum <ei>pT</ei> scale of emissions.
935Additionally, as always, the <code>scale</code> variable of each parton
936sets the maximum <ei>pT</ei> scale of branchings of this parton.
937Recall that this scale defaults to 0 if not set, so that no radiation
938can occur.
939</argument>
940<argument name="nBranchMax" default = "0"> when positive, it sets the
941maximum number of branchings that are allowed to occur in the shower,
942i.e. the shower may stop evolving before reaching the lower cutoff.
943The argument has no effect when zero or negative, i.e. then the shower
944will continue to the lower cutoff.
945</argument>
946<note>Note:</note> The method returns the number of branchings that
947has been generated.
948</method>
949
950<method name="bool Pythia::forceHadronLevel(bool findJunctions = true)">
951hadronize the existing event record, i.e. perform string fragmentation
952and particle decays. There are two main applications. Firstly,
953you can use the same parton-level content as a basis for repeated
954hadronization attempts, in schemes intended to save computer time.
955Secondly, you may have an external program that can simulate the full
956partonic level of the event - hard process, parton showers, multiparton
957interactions, beam remnants, colour flow, and so on - but not
958hadronization. Further details are found
959<aloc href="HadronLevelStandalone">here</aloc>
960<argument name="findJunctions" default = "true"> 
961normally this routine will search through the event record and try to
962figure out if any colour junctions are present. If so, the colour
963topology of such junctions must be sorted out. In tricky cases this
964might fail, and then hadronization will not work. A user who is
965aware of this and knows the intended colour flow can set up the
966junction information in the event record, and then call
967<code>forceHadronLevel(false)</code> so as not to have this information
968overwritten. </argument>
969<note>Note:</note> The method returns false if the hadronization
970fails. The event record is then not consistent and should not be
971studied.
972</method>
973
974<method name="bool Pythia::moreDecays()">
975perform decays of all particles in the event record that have not been
976decayed but should have been done so. This can be used e.g. for
977repeated decay attempts, in schemes intended to save computer time.
978Further details are found <aloc href="HadronLevelStandalone">here</aloc>
979<note>Note:</note> The method returns false if the decays fail. The
980event record is then not consistent and should not be studied.
981</method>
982
983<method name="bool Pythia::forceRHadronDecays()">
984perform decays of R-hadrons that were previously considered stable.
985This could be if an R-hadron is sufficiently long-lived that
986it may interact in the detector between production and decay, so that
987its four-momentum is changed. Further details are found
988<aloc href="RHadrons">here</aloc>
989<note>Note:</note> The method returns false if the decays fail. The
990event record is then not consistent and should not be studied.
991</method>
992
993<method name="void Pythia::LHAeventList(ostream& os = cout)">
994list the Les Houches Accord information on the current event, see
995<code><aloc href="LesHouchesAccord">LHAup::listEvent(...)</aloc></code>.
996(Other listings are available via the class members below, so this
997listing is a special case that would not fit elsewhere.)
998<argument name="os" default = "cout"> 
999output stream where the listing occurs.
1000</argument>
1001</method>
1002
1003<method name="bool Pythia::LHAeventSkip(int nSkip)">
1004skip ahead a number of events in the Les Houches generation
1005sequence, without doing anything further with them, see
1006<code><aloc href="LesHouchesAccord">LHAup::skipEvent(nSkip)</aloc></code>.
1007Mainly intended for debug purposes, e.g. when an event at a known
1008location in a Les Houches Event File is causing problems.
1009<argument name="nSkip"> 
1010number of events to skip.
1011</argument>
1012<note>Note:</note> The method returns false if the operation fails,
1013specifically if the end of a LHEF has been reached, cf.
1014<code>next()</code> above.
1015</method>
1016
1017<h3>Finalize</h3>
1018
1019There is no required finalization step; you can stop generating events
1020when and how you want. It is still recommended that you make it a
1021routine to call the following method at the end. A second method provides
1022a deprecated alternative.
1023
1024<method name="void Pythia::stat()">
1025list statistics on the event generation, specifically total and partial
1026cross sections and the number of different errors. For more details see
1027<aloc href="EventStatistics">here</aloc> and for available options
1028<aloc href="MainProgramSettings">here</aloc>.
1029</method>
1030
1031<method name="void Pythia::statistics(bool all = false, bool reset = false)">
1032list statistics on the event generation, specifically total and partial
1033cross sections and the number of different errors. For more details see
1034<aloc href="EventStatistics">here</aloc>.
1035<argument name="all" default="false"> 
1036if true also statistics on multiparton interactions is shown, by default not.
1037</argument>
1038<argument name="reset" default="false"> if true then all counters,
1039e.g on events generated and errors experienced, are reset to zero
1040 whenever the routine is called. The default instead is that
1041all stored statistics information is unaffected by the call. Counters
1042are automatically reset in each new <code>Pythia::init(...)</code> 
1043call, however, so the only time the <code>reset</code> option makes a
1044difference is if <code>statistics(...)</code> is called several times
1045in a (sub)run.
1046</argument>
1047<note>Note:</note> Deprecated.
1048</method>
1049
1050<h3>Interrogate settings</h3>
1051
1052Normally settings are used in the setup and initialization stages
1053to determine the character of a run, e.g. read from a file with the
1054above-described <code>Pythia::readFile(...)</code> method.
1055There is no strict need for a user to interact with the
1056<code>Settings</code> database in any other way. However, as an option,
1057some settings variables have been left free for the user to set in
1058such a file, and then use in the main program to directly affect the
1059performance of that program, see
1060<aloc href="MainProgramSettings">here</aloc>. A typical example would
1061be the number of events to generate. For such applications the
1062following shortcuts to some <code>Settings</code> methods may be
1063convenient.
1064
1065<method name="bool Pythia::flag(string key)">
1066read in a boolean variable from the <code>Settings</code> database.
1067<argument name="key"> 
1068the name of the variable to be read.
1069</argument>
1070</method>
1071 
1072<method name="int Pythia::mode(string key)">
1073read in an integer variable from the <code>Settings</code> database.
1074<argument name="key"> 
1075the name of the variable to be read.
1076</argument>
1077</method>
1078 
1079<method name="double Pythia::parm(string key)">
1080read in a double-precision variable from the <code>Settings</code> 
1081database.
1082<argument name="key"> 
1083the name of the variable to be read.
1084</argument>
1085</method>
1086 
1087<method name="string Pythia::word(string key)">
1088read in a string variable from the <code>Settings</code> database.
1089<argument name="key"> 
1090the name of the variable to be read.
1091</argument>
1092</method>
1093 
1094<h3>Data members</h3>
1095
1096The <code>Pythia</code> class contains a few public data members,
1097several of which play a central role. We list them here, with
1098links to the places where they are further described.
1099 
1100<method name="Event Pythia::process">
1101the hard-process event record, see <aloc href="EventRecord">here</aloc>
1102for further details.
1103</method>
1104 
1105<method name="Event Pythia::event">
1106the complete event record, see <aloc href="EventRecord">here</aloc>
1107for further details.
1108</method>
1109 
1110<method name="Info Pythia::info">
1111further information on the event-generation process, see
1112<aloc href="EventInformation">here</aloc> for further details.
1113</method>
1114 
1115<method name="Settings Pythia::settings">
1116the settings database, see <aloc href="SettingsScheme">here</aloc>
1117for further details.
1118</method>
1119 
1120<method name="ParticleData Pythia::particleData">
1121the particle properties and decay tables database, see
1122<aloc href="ParticleDataScheme">here</aloc> for further details.
1123</method>
1124 
1125<method name="Rndm Pythia::rndm">
1126the random number generator, see <aloc href="RandomNumberSeed">here</aloc>
1127and <aloc href="RandomNumbers">here</aloc> for further details.
1128</method>
1129 
1130<method name="CoupSM Pythia::coupSM">
1131Standard Model couplings and mixing matrices, see
1132<aloc href="StandardModelParameters">here</aloc> for further details.
1133</method>
1134 
1135<method name="SusyLesHouches Pythia::slha">
1136parameters and particle data in the context of supersymmetric models,
1137see <aloc href="SUSYLesHouchesAccord">here</aloc> for further details.
1138</method>
1139 
1140<method name="PartonSystems Pythia::partonSystems">
1141a grouping of the partons in the event record by subsystem,
1142see <aloc href="AdvancedUsage">here</aloc> for further details.
1143</method>
1144   
1145</chapter>
1146
1147<!-- Copyright (C) 2012 Torbjorn Sjostrand -->
Note: See TracBrowser for help on using the repository browser.