]>
Commit | Line | Data |
---|---|---|
c6b60c38 | 1 | // main25.cc is a part of the PYTHIA event generator. |
2 | // Copyright (C) 2013 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 | cout << endl << "Begin event # " << iEvent << endl; | |
41 | ||
42 | // Generate events, and check whether generation failed. | |
43 | if (!pythia.next()) { | |
44 | ||
45 | // If failure because reached end of file then exit event loop. | |
46 | if (pythia.info.atEndOfFile()) break; | |
47 | ||
48 | // First few failures write off as "acceptable" errors, then quit. | |
49 | if (++iAbort < nAbort) continue; | |
50 | break; | |
51 | } | |
52 | ||
53 | // Sum up final charged multiplicity and fill in histogram. | |
54 | int nChg = 0; | |
55 | for (int i = 0; i < pythia.event.size(); ++i) | |
56 | if (pythia.event[i].isFinal() && pythia.event[i].isCharged()) | |
57 | ++nChg; | |
58 | nCharged.fill(nChg); | |
59 | ||
60 | // End of event loop. | |
61 | } | |
62 | ||
63 | // Give statistics. Print histogram. | |
64 | pythia.stat(); | |
65 | cout << nCharged; | |
66 | ||
67 | // Done. | |
68 | return 0; | |
69 | } |