## Sample Main Programs

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 `examples` subdirectory, along with instructions how they should be run:

- `main00.cc` : does not exist, but it has been defined in the `Makefile`, so this name could be used for a simple first test run.
- `main01.cc` : a simple study of the charged multiplicity for jet events at the LHC. (Brief example fitting on one slide.)
- `main02.cc` : a simple study of the pT spectrum of Z bosons at the Tevatron. (Brief example fitting on one slide.)
- `main03.cc` : a simple study of several different kinds of events, with the choice to be made in the `main03.cmnd` "cards file".
- `main04.cc` : tests of cross sections, multiplicities and average transverse momenta for elastic, diffractive and nondiffractive topologies, using `main04.cmnd` to pick processes.
- `main05.cc` : generation of QCD jet events at the LHC, with jet analysis using the `SlowJet` inclusive anti-kT sequential-recombination finder and the `CellJet` cone-jet finder.
- `main06.cc` : generation of LEP1 hadronic events, i.e. e^+e^- → gamma*/Z^0 → q qbar, with charged multiplicity, sphericity, thrust and jet analysis.
- `main07.cc` : 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.
- `main08.cc` : 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 pT bin, and adding the results properly reweighted. Two suboptions, with limits set either in the main program or by subrun specification in the `main08.cmnd` file. Secondly, by a continuous reweighting with a pT^4 bias in the selection, compensated by a 1/pT^4 event weight. Also inclusion of soft processes is illustrated, with subruns and weighted events.
- `main09.cc` : generation of two predetermined hard interactions in each event.
- `main10.cc` : illustration how userHooks can be used interact directly with the event-generation process.
- `main11.cc` : a study of top events, fed in from the Les Houches Event File `ttbar.lhe`, 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.
- `main12.cc` : a more sophisticated variant of `main11.cc`, where two Les Houches Event Files (`ttbar.lhe` and `ttbar2.lhe`) successively are used as input. Also illustrating some other aspects, like the capability to mix in internally generated events.
- `main13.cc` : a streamlined version of `main12.cc`, where two Les Houches Event Files (`ttbar.lhe` and `ttbar2.lhe`) successively are used as input in `main13.cmnd` file.
- `main14.cc` : 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.
- `main15.cc` : 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.
- `main16.cc` : 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.
- `main17.cc` : shows (a) how to use UserHooks to regularize onium cross section for pT → 0, and (b) how decays could be handled externally.
- `main18.cc` : 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.
- `main19.cc` : 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.
- `main20.cc` : shows how PYTHIA 8 can write a Les Houches Event File, using facilities potentially useful also for other programs to write an LHEF.
- `main21.cc` : 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.
- `main22.cc` : 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.
- `main23.cc` : 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.
- `main24.cc` : tests of internally implemented cross sections for Supersymmetric particle production, with SUSY spectrum defined in `cmssm.spc` and settings in `main24.cmnd`. For illustration, an alternative example spectrum is also available, `sps1aWithDecays.spc`, which contains a decay table in SLHA format.
- `main25.cc` : input RPV-SUSY events from an LHEF file that contains an SLHA spectrum inside its header. The event file, `main25.lhe`, 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.
- `main26.cc` : test program for processes in scenarios with large extra dimensions or unparticles.
- `main27.cc` : production of Kaluza-Klein gamma/Z states in TeV-sized extra dimensions.
- `main28.cc` : production of long-lived R-hadrons, that are forced to decay at a separate vertices and possibly with changed momenta.
- `main31.cc` : exemplifies an improved matching of parton showers to LHEF-style input based on the POWHEG approach. The `main31.cmnd` 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 [Cor10] or for QCD 2+3-jet events. The small samples of input events are stored in the `powheg-hvq.lhe` and `powheg-dijets.lhe` files, respectively.
- `main32.cc` : 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 `main32.cmnd`. See Jet Matching 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 W + 3 jets events is stored in `main32.unw` and the parameters to go with it in `main32_unw.par`. Madgraph events are taken from the `w+_production_lhc_2.lhe` file in this case.
- `main41.cc` : similar to `main01`, except that the event record is output in the HepMC event record format. Requires that HepMC is properly linked. Note that the `hepmcout41.dat` output file can become quite big; so no example is included in this distribution.
- `main42.cc` : 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. `main42.cmnd`) and output HepMC event file (e.g. `hepmcout42.dat`) 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.
- `main46.cc` : 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 `http://atlaswww.hep.anl.gov/asc/promc/`.
- `main51.cc` : 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.
- `main52.cc` : 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.
- `main53.cc` : 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.
- `main54.cc` : 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.
- `main61.cc` : a streamlined version for the generation of events that are then stored in HepMC format, without any event analysis. That is, just like `main42.cc`, with the difference that `main61.cc` can be used in conjunction with LHAPDF. The name of the input "cards file" (e.g. `main61.cmnd`) and output HepMC event file (e.g. `hepmcout61.dat`) 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.
- `main62.cc` : a further extension of `main61.cc`, where subruns are used to process several consecutive LHEF, as in `main13.cc`, with information stored e.g in `main62.cmnd`. Other comments as for `main61.cc`.
- `main71.cc` : 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.
- `main72.cc` : 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.
- `main80.cc` : do CKKW-L merging with a merging scale defined in kT. Input is provided by the `main80.cmnd` file and input LHE files. Very basic and pedagogical setup, suitable for tutorials.
- `main81.cc` : do CKKW-L merging with a merging scale defined in kT. Input is provided by the `main81.cmnd` file and the three data files `w+_production_lhc_0.lhe`, `w+_production_lhc_1.lhe` and `w+_production_lhc_2.lhe`.
- `main82.cc` : do CKKW-L merging with a user-defined merging scale function. Input is provided by the `main82.cmnd` file and the three data files `w+_production_lhc_0.lhe`, `w+_production_lhc_1.lhe` and `w+_production_lhc_2.lhe`.
- `main83.cc` : as `main82.cc` but with an additional cut on the lowest multiplicity allowed for the reclustered state. The same input as for `main82.cc` can be used.
- `main84.cc` : do CKKW-L merging with output in such a way that it can be used in subsequent RIVET analyses. Input is provided by the `main84.cmnd` file and the three data files `w+_production_lhc_0.lhe`, `w+_production_lhc_1.lhe` and `w+_production_lhc_2.lhe`.
- `main85.cc` : do CKKW-L merging, with HepMC event output. Input settings are provided by the `main85.cmnd` 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 `w_production_tree_0.lhe`, `w_production_tree_1.lhe` and `w_production_tree_2.lhe`.
- `main86.cc` : do unitarised ME+PS (UMEPS) merging, with HepMC event output. Input settings are provided by the `main86.cmnd` file. This example program allows the consistent use of input Les Houches events that are regularised with only very minimal cuts, similar to `main85.cc`. The example program can be used with the input files `w_production_tree_0.lhe`, `w_production_tree_1.lhe` and `w_production_tree_2.lhe`. The program will produce positively and negatively weighted events. See UMEPS Merging for further details.
- `main87.cc` : do NL3 NLO merging, with inclusive NLO input, and with HepMC event output. Input settings are provided by the `main87.cmnd` file. This example program allows the consistent use of input Les Houches events that are regularised with only very minimal cuts, similar to `main85.cc`. The example program can be used with the tree-level input files `w_production_tree_0.lhe`, `w_production_tree_1.lhe`, `w_production_tree_2.lhe` and the inclusive POWHEG input files `w_production_powheg_0.lhe`, `w_production_powheg_1.lhe`. The program will produce positively and negatively weighted events. See NLO Merging (NL3 section) for further details.
- `main88.cc` : do unitarised NLO+PS (UNLOPS) merging, with inclusive NLO input, and with HepMC event output. Input settings are provided by the `main88.cmnd` file. This example program allows the consistent use of input Les Houches events that are regularised with only very minimal cuts, similar to `main85.cc`. The example program can be used with the tree-level input files `w_production_tree_0.lhe`, `w_production_tree_1.lhe`, `w_production_tree_2.lhe` and the inclusive POWHEG input files `w_production_powheg_0.lhe`, `w_production_powheg_1.lhe`. The program will produce positively and negatively weighted events. See NLO Merging (UNLOPS section) for further details.

In addition two main program illustrating the use of ROOT are available in the `rootexamples` subdirectory:

- `hist.cc` : shows how ROOT can be used for histogramming in a program that for the rest is structured like a normal PYTHIA run.
- `tree.cc` : shows how PYTHIA events can be stored as ROOT trees.

This subdirectory also contains a special Makefile and related documentation.