## 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 by splitting the run into subruns, each in its own pT bin, and adding the results properly reweighted. Two options, with limits set either in the main program or by subrun specification in the `main08.cmnd` file.
- `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.
- `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.
- `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 SYSY 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 `
  `. 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.
- `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.
- `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.
- `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.
- `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`.
- `main91.cc` : exemplifies how you can link in runtime generation of hard processes from PYTHIA 6, using the Les Houches Accord facilities. This example is deprecated, since PYTHIA 8 by now contains essentially all hard processes found in PYTHIA 6.

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.
- `hist.cc` : shows how PYTHIA events can be stored as ROOT trees.

This subdirectory also contains a special Makefile and related documentation.