<chapter name="Sample Main Programs"> 
 
<h2>Sample Main Programs</h2> 
 
Descriptions of available classes, methods and settings are all 
very good and useful. Ultimately they are necessary for you to 
be able to fine-tune your runs to the task at hand. To get going, 
however, nothing helps like having explicit examples to study. 
This is what is provided in the <code>examples</code> subdirectory, 
along with instructions how they should be run: 
<ul> 
 
<li><code>main00.cc</code> : does not exist, but it has been defined 
in the <code>Makefile</code>, so this name could be used for a simple 
first test run. 
 
<li><code>main01.cc</code> : a simple study of the charged multiplicity 
for jet events at the LHC. (Brief example fitting on one slide.)</li> 
 
<li><code>main02.cc</code> : a simple study of the <ei>pT</ei> spectrum 
of Z bosons at the Tevatron. (Brief example fitting on one slide.)</li> 
 
<li><code>main03.cc</code> : a simple study of several different kinds 
of events, with the choice to be made in the <code>main03.cmnd</code> 
"cards file".</li> 
 
<li><code>main04.cc</code> : tests of cross sections, multiplicities and 
average transverse momenta for elastic, diffractive and nondiffractive 
topologies, using <code>main04.cmnd</code> to pick processes.</li> 
 
<li><code>main05.cc</code> : generation of QCD jet events at the LHC, 
with jet analysis using the <code>SlowJet</code> inclusive anti-<ei>kT</ei> 
sequential-recombination finder and the <code>CellJet</code> 
cone-jet finder.</li> 
 
<li><code>main06.cc</code> : generation of LEP1 hadronic events, i.e. 
<ei>e^+e^- &rarr; gamma*/Z^0 &rarr; q qbar</ei>, with charged multiplicity, 
sphericity, thrust and jet analysis.</li> 
 
<li><code>main07.cc</code> : set up a fictitious production process 
to a generic resonance, where you easily can compose your own list 
of (two-body) decay modes to a variety of final states. Also traces 
decay chains down to truly stable particles: gamma, e+-, p/pbar and 
neutrinos. Suitable for astroparticle applications, like neutralino 
pair annihilation, where cross sections are calculated separately 
in another program.</li> 
 
<li><code>main08.cc</code> : generation of the QCD jet cross section 
biased towards higher pT values, by two different techniques. 
Firstly, by splitting the run into subruns, each in its own <ei>pT</ei> 
bin, and adding the results properly reweighted. Two suboptions, with 
limits set either in the main program or by subrun specification in the 
<code>main08.cmnd</code> file. Secondly, by a continuous reweighting 
with a <ei>pT^4</ei> bias in the selection, compensated by a 
<ei>1/pT^4</ei> event weight. Also inclusion of soft processes is 
illustrated, with subruns and weighted events.</li> 
 
<li><code>main09.cc</code> : generation of two predetermined hard 
interactions in each event.</li> 
 
<li><code>main10.cc</code> : illustration how userHooks can be used 
interact directly with the event-generation process.</li> 
 
<li><code>main11.cc</code> : a study of top events, fed in from the 
Les Houches Event File <code>ttbar.lhe</code>, here generated by 
PYTHIA 6.4. This file currently only contains 100 events 
so as not to make the distributed PYTHIA package too big, and so serves 
mainly as a demonstration of the principles involved. </li> 
 
<li><code>main12.cc</code> : a more sophisticated variant of 
<code>main11.cc</code>, where two Les Houches Event Files 
(<code>ttbar.lhe</code> and <code>ttbar2.lhe</code>) successively 
are used as input. Also illustrating some other aspects, like the 
capability to mix in internally generated events.</li> 
 
<li><code>main13.cc</code> : a streamlined version of 
<code>main12.cc</code>, where two Les Houches Event Files 
(<code>ttbar.lhe</code> and <code>ttbar2.lhe</code>) successively 
are used as input in <code>main13.cmnd</code> file.</li> 
 
<li><code>main14.cc</code> : a systematic comparison of several 
cross section values with their corresponding values in PYTHIA 6.4, 
the latter available as a table in the code.</li> 
 
<li><code>main15.cc</code> : loop over several tries, either to redo 
B decays only or to redo the complete hadronization chain of an event. 
Since much of the generation process is only made once this is a way 
to increase efficiency.</li> 
 
<li><code>main16.cc</code> : put all user analysis code into a class 
of its own, separate from the main program; provide the "cards file" 
name as a command-line argument. Also exemplifies how Higgs mass, 
width and branching ratios can be set by hand.</li> 
 
<li><code>main17.cc</code> : shows (a) how to use UserHooks to 
regularize onium cross section for pT &rarr; 0, and (b) how decays 
could be handled externally.</li> 
 
<li><code>main18.cc</code> : shows how to write an event filter class, 
where you keep a vector of pointers to the subset of particles you 
want to study further. The event record itself remains unchanged.</li> 
 
<li><code>main19.cc</code> : use several instances of Pythia, one for 
signal events and others for a variable number of pileup and "beam-gas" 
events, combined into one common event record.</li> 
 
<li><code>main20.cc</code> : shows how PYTHIA 8 can write a Les Houches 
Event File, using facilities potentially useful also for other programs 
to write an LHEF.</li> 
 
<li><code>main21.cc</code> : an example how a single particle or various 
parton-level configurations can be input directly for hadronization, 
without being tied to the full process-generation machinery, e.g. to 
study the hadronization of junction topologies. Can also be used for 
single-resonance decays, with showers.</li> 
 
<li><code>main22.cc</code> : shows how an external resonance can be 
implemented as a new class derived from a PYTHIA base class, and be 
used in an external process, both of them handed in for generation 
as with normal internal classes.</li> 
 
<li><code>main23.cc</code> : shows how an external beam momentum spread 
and vertex location generator can be implemented as a new class derived 
from a PYTHIA base class, and then handed in for internal use. 
Also how to use an external random-number generator and an external 
parton distribution set.</li> 
 
<li><code>main24.cc</code> : tests of internally implemented cross sections 
for Supersymmetric particle production, with SUSY spectrum defined in 
<code>cmssm.spc</code> and settings in <code>main24.cmnd</code>. For 
illustration, an alternative example spectrum is also 
available, <code>sps1aWithDecays.spc</code>, which contains a decay 
table in SLHA format.</li> 
 
<li><code>main25.cc</code> : input RPV-SUSY events from an LHEF file that 
contains an SLHA spectrum inside its header. The event file, 
<code>main25.lhe</code>, contains a sample events that 
illustrate how to arrange color tags in the presence of the 
color-space epsilon tensors that accompany baryon number violating 
event topologies. </li> 
 
<li><code>main26.cc</code> : test program for processes in scenarios 
with large extra dimensions or unparticles. </li> 
 
<li><code>main27.cc</code> : production of Kaluza-Klein <ei>gamma/Z</ei> 
states in TeV-sized extra dimensions. </li> 
 
<li><code>main28.cc</code> : production of long-lived R-hadrons, that 
are forced to decay at a separate vertices and possibly with changed 
momenta.</li> 
 
<li><code>main31.cc</code> : exemplifies an improved matching of 
parton showers to LHEF-style input based on the 
<aloc href="POWHEGMerging">POWHEG approach</aloc>. 
The <code>main31.cmnd</code> allows to switch between several 
different matching options. It also allows to select input process, 
in this case either for the POWHEG-hvq program applied to top 
pair production <ref>Cor10</ref> or for QCD 2+3-jet events. The small 
samples of input events are stored in the <code>powheg-hvq.lhe</code> 
and <code>powheg-dijets.lhe</code> files, respectively. 
</li> 
 
<li><code>main32.cc</code> : exemplifies MLM merging, either in the 
ALPGEN variant or in the Madgraph one, and with input events either 
from ALPGEN or from Madgraph, with relevant control cards stored in 
<code>main32.cmnd</code>. See <aloc href="JetMatching">Jet Matching</aloc> 
for further details. Traditionally the ALPGEN output is 
split into one file with events and another with parameters and cross 
sections (unlike in LHEF). Here a sample of <ei>W + 3 jets</ei> events 
is stored in <code>main32.unw</code> and the parameters to go with it 
in <code>main32_unw.par</code>. Madgraph events are taken from the 
<code>w+_production_lhc_2.lhe</code> file in this case. 
</li> 
 
<li><code>main41.cc</code> : similar to <code>main01</code>, except that 
the event record is output in the HepMC event record format. Requires that 
HepMC is properly linked. Note that the <code>hepmcout41.dat</code> output 
file can become quite big; so no example is included in this 
distribution.</li> 
 
<li><code>main42.cc</code> : a streamlined version for the generation 
of events that are then stored in HepMC format, without any event 
analysis. That is, all physics studies will have to be done afterwards. 
The name of the input "cards file" (e.g. <code>main42.cmnd</code>) 
and output HepMC event file (e.g. <code>hepmcout42.dat</code>) are to 
be provided as command-line arguments. Requires that HepMC is properly 
linked. Note that the HepMC output file can become quite big; so no 
example is included in this distribution.</li> 
 
<li><code>main46.cc</code> : illustrates how to write a ProMC file with 
PYTHIA events. Note that this example cannot (yet) be built by the PYTHIA 
Makefile, but a relevant Makefile is available on the ProMC webpage 
<code>http://atlaswww.hep.anl.gov/asc/promc/</code>.</li> 
 
<li><code>main51.cc</code> : a test of the shape of parton densities, 
as a check prior to using a given PDF set in a generator.  Requires 
that LHAPDF is properly linked.</li> 
 
<li><code>main52.cc</code> : compares the charged multiplicity 
distribution, and a few other minimum-bias physics aspects, between 
default PYTHIA PDF and another one. Requires that LHAPDF is properly 
linked.</li> 
 
<li><code>main53.cc</code> : tests the possibility to do backwards 
evolution from an incoming photon at the hard interaction. Requires 
that you link to a LHAPDF set that includes the photon PDF.</li> 
 
<li><code>main54.cc</code> : compares the internal and LHAPDF 
implementations of the NNPDF 2.3 QCD+QED sets, for results and for 
timing. Requires that LHAPDF is properly linked.</li> 
 
<li><code>main61.cc</code> : a streamlined version for the generation 
of events that are then stored in HepMC format, without any event 
analysis. That is, just like <code>main42.cc</code>, with the difference 
that <code>main61.cc</code> can be used in conjunction with LHAPDF. 
The name of the input "cards file" (e.g. <code>main61.cmnd</code>) 
and output HepMC event file (e.g. <code>hepmcout61.dat</code>) are to 
be provided as command-line arguments. Requires that HepMC and LHAPDF 
are properly linked. Note that the HepMC output file can become quite 
big; so no example is included in this distribution.</li> 
 
<li><code>main62.cc</code> : a further extension of <code>main61.cc</code>, 
where subruns are used to process several consecutive LHEF, 
as in <code>main13.cc</code>, with information stored e.g in 
<code>main62.cmnd</code>. Other comments as for <code>main61.cc</code>.</li> 
 
<li><code>main71.cc</code> : an example how the FastJet jet finding 
package can be linked to allow an analysis of the final state, 
in this case for a study of W + jet production.</li> 
 
<li><code>main72.cc</code> : a comparison of SlowJet and FastJet 
jet finding, showing that they find the same jets if run under 
identical conditions, in this case for QCD jets.</li> 
 
<li><code>main80.cc</code> : do CKKW-L merging with a merging scale 
defined in <ei>kT</ei>. Input is provided by the <code>main80.cmnd</code> 
file and input LHE files. Very basic and pedagogical setup, suitable 
for tutorials.</li> 
 
<li><code>main81.cc</code> : do CKKW-L merging with a merging scale 
defined in <ei>kT</ei>. Input is provided by the <code>main81.cmnd</code> 
file and the three data files <code>w+_production_lhc_0.lhe</code>, 
<code>w+_production_lhc_1.lhe</code> and <code>w+_production_lhc_2.lhe</code>. 
</li> 
 
<li><code>main82.cc</code> : do CKKW-L merging with a user-defined 
merging scale function. Input is provided by the <code>main82.cmnd</code> 
file and the three data files <code>w+_production_lhc_0.lhe</code>, 
<code>w+_production_lhc_1.lhe</code> and <code>w+_production_lhc_2.lhe</code>. 
</li> 
 
<li><code>main83.cc</code> : as <code>main82.cc</code> but with an 
additional cut on the lowest multiplicity allowed for the reclustered 
state. The same input as for <code>main82.cc</code> can be used. 
</li> 
 
<li><code>main84.cc</code> : do CKKW-L merging with output in such a way 
that it can be used in subsequent RIVET analyses. Input is provided by 
the <code>main84.cmnd</code> file and the three data files 
<code>w+_production_lhc_0.lhe</code>, <code>w+_production_lhc_1.lhe</code> 
and <code>w+_production_lhc_2.lhe</code>. 
</li> 
 
<li><code>main85.cc</code> : do CKKW-L merging, with HepMC event output. Input 
settings are provided by the <code>main85.cmnd</code> file. This example 
program allows the use of input Les Houches events that are regularised with 
only very minimal cuts, and on which Pythia itself should enforce the more 
restrictive merging scale cut. The example program can be used with the input 
files <code>w_production_tree_0.lhe</code>, 
<code>w_production_tree_1.lhe</code> and <code>w_production_tree_2.lhe</code>. 
</li> 
 
<li><code>main86.cc</code> : do unitarised ME+PS (UMEPS) merging, with HepMC 
event output. Input settings are provided by the <code>main86.cmnd</code> 
file. This example program allows the consistent use of input Les Houches 
events that are regularised with only very minimal cuts, similar to 
<code>main85.cc</code>. The example program can be used with the input files 
<code>w_production_tree_0.lhe</code>, <code>w_production_tree_1.lhe</code> 
and <code>w_production_tree_2.lhe</code>. 
The program will produce positively and negatively weighted events. 
See <aloc href="UMEPSMerging">UMEPS Merging</aloc> for further details. 
</li> 
 
<li><code>main87.cc</code> : do NL<sup>3</sup> NLO merging, with inclusive 
NLO input, and with HepMC event output. Input settings are provided by 
the <code>main87.cmnd</code> file. This example program allows the consistent 
use of input Les Houches events that are regularised with only very minimal 
cuts, similar to <code>main85.cc</code>. The example program can be 
used with the tree-level input files <code>w_production_tree_0.lhe</code>, 
<code>w_production_tree_1.lhe</code>, <code>w_production_tree_2.lhe</code> and 
the inclusive POWHEG input files <code>w_production_powheg_0.lhe</code>, 
<code>w_production_powheg_1.lhe</code>. 
The program will produce positively and negatively weighted events. 
See <aloc href="NLOMerging">NLO Merging</aloc> (NL<sup>3</sup> section) for 
further details. 
</li> 
 
<li><code>main88.cc</code> : do unitarised NLO+PS (UNLOPS) merging, with 
inclusive NLO input, and with HepMC event output. Input settings are provided 
by the <code>main88.cmnd</code> file. This example program allows the 
consistent use of input Les Houches events that are regularised with only very 
minimal cuts, similar to <code>main85.cc</code>. The example program can be 
used with the tree-level input files <code>w_production_tree_0.lhe</code>, 
<code>w_production_tree_1.lhe</code>, <code>w_production_tree_2.lhe</code> and 
the inclusive POWHEG input files <code>w_production_powheg_0.lhe</code>, 
<code>w_production_powheg_1.lhe</code>. 
The program will produce positively and negatively weighted events. 
See <aloc href="NLOMerging">NLO Merging</aloc> (UNLOPS section) for further 
details. 
</li> 
 
</ul> 
 
In addition two main program illustrating the use of ROOT are available 
in the <code>rootexamples</code> subdirectory: 
  
<ul> 
 
<li><code>hist.cc</code> : shows how ROOT can be used for histogramming 
in a program that for the rest is structured like a normal PYTHIA run. 
</li> 
 
<li><code>tree.cc</code> : shows how PYTHIA events can be stored as 
ROOT trees.</li> 
 
</ul> 
 
This subdirectory also contains a special Makefile and related 
documentation. 
 
 
</chapter> 
 
<!-- Copyright (C) 2014 Torbjorn Sjostrand --> 
