StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
main25.cc
1 // main25.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2012 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // This is a simple test program.
7 // It illustrates how Les Houches Event File input can be used in Pythia8.
8 // Here the very few events are generated with MadGraph, and illustrate
9 // more complicated colour topologies.
10 
11 #include "Pythia.h"
12 using namespace Pythia8;
13 
14 int main() {
15 
16  // Generator
17  Pythia pythia;
18 
19  // Stick with default values, so do not bother with a separate file
20  // for changes. However, do one change, to show readString in action.
21  pythia.readString("PartonLevel:ISR = off");
22  pythia.readString("PartonLevel:FSR = off");
23  pythia.readString("PartonLevel:MPI = off");
24  pythia.readString("HadronLevel:Hadronize = on");
25 
26  // Initialize Les Houches Event File run.
27  pythia.readString("Beams:frameType = 4");
28  pythia.readString("Beams:LHEF = main25.lhe");
29  pythia.init();
30 
31  // Book histogram.
32  Hist nCharged("charged particle multiplicity",100,-0.5,399.5);
33 
34  // Allow for possibility of a few faulty events.
35  int nAbort = 10;
36  int iAbort = 0;
37 
38  // Begin event loop; generate until none left in input file.
39  for (int iEvent = 0; ; ++iEvent) {
40 
41  // Generate events, and check whether generation failed.
42  if (!pythia.next()) {
43 
44  // If failure because reached end of file then exit event loop.
45  if (pythia.info.atEndOfFile()) break;
46 
47  // First few failures write off as "acceptable" errors, then quit.
48  if (++iAbort < nAbort) continue;
49  break;
50  }
51 
52  // Sum up final charged multiplicity and fill in histogram.
53  int nChg = 0;
54  for (int i = 0; i < pythia.event.size(); ++i)
55  if (pythia.event[i].isFinal() && pythia.event[i].isCharged())
56  ++nChg;
57  nCharged.fill(nChg);
58 
59  // End of event loop.
60  }
61 
62  // Give statistics. Print histogram.
63  pythia.stat();
64  cout << nCharged;
65 
66  // Done.
67  return 0;
68 }