]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PYTHIA8/pythia8145/examples/main22.cc
Use Output directive instead of the old OutputFile and OUtputArchive. Save fileinfo...
[u/mrichter/AliRoot.git] / PYTHIA8 / pythia8145 / examples / main22.cc
CommitLineData
9419eeef 1// main22.cc is a part of the PYTHIA event generator.
2// Copyright (C) 2010 Peter Skands, 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 to run SUSY processes in Pythia8.
8// All input is specified in the main22.cmnd file.
9
10#include "Pythia.h"
11
12using namespace Pythia8;
13
14int main() {
15
16 // Generator. Shorthand for the event.
17 Pythia pythia;
18 Event& event = pythia.event;
19
20 // Read in commands from external file.
21 pythia.readFile("main22.cmnd");
22
23 // Extract settings to be used in the main program.
24 int nEvent = pythia.mode("Main:numberOfEvents");
25 int nList = pythia.mode("Main:numberToList");
26 int nShow = pythia.mode("Main:timesToShow");
27 int nAbort = pythia.mode("Main:timesAllowErrors");
28 bool showCS = pythia.flag("Main:showChangedSettings");
29 bool showAS = pythia.flag("Main:showAllSettings");
30 bool showCPD = pythia.flag("Main:showChangedParticleData");
31 bool showAPD = pythia.flag("Main:showAllParticleData");
32 double eCM = pythia.parm("Beams:eCM");
33
34 // Initialize. Beam parameters set in .cmnd file.
35 pythia.init();
36
37 // List changed data.
38 if (showCS) pythia.settings.listChanged();
39 if (showAS) pythia.settings.listAll();
40
41 // List particle data.
42 if (showCPD) pythia.particleData.listChanged();
43 if (showAPD) pythia.particleData.listAll();
44
45 // Histograms.
46 double epTol = 1e-6 * eCM;
47 Hist epCons("deviation from energy-momentum conservation",100,0.,epTol);
48 Hist nFinal("final particle multiplicity",100,-0.5,799.5);
49 Hist dnparticledy("dn/dy for particles",100,-10.,10.);
50
51 // Begin event loop.
52 int nPace = max(1, nEvent / max(1, nShow) );
53 int iAbort = 0;
54 for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
55 if (nShow > 0 && iEvent%nPace == 0)
56 cout << " Now begin event " << iEvent << endl;
57
58 // Generate events. Quit if failure.
59 if (!pythia.next()) {
60 if (++iAbort < nAbort) continue;
61 cout << " Event generation aborted prematurely, owing to error!\n";
62 break;
63 }
64
65 // List first few events, both hard process and complete events.
66 if (iEvent < nList) {
67 pythia.process.list();
68 event.list();
69 }
70
71 // Loop over final particles in the event.
72 int nFin = 0;
73 Vec4 pSum;
74 for (int i = 0; i < event.size(); ++i) if (event[i].isFinal()) {
75 nFin++;
76 pSum += event[i].p();
77 dnparticledy.fill(event[i].y());
78 }
79
80 // Check and print event with too big energy-momentum deviation.
81 nFinal.fill(nFin);
82 double epDev = abs(pSum.e() - eCM) + abs(pSum.px()) + abs(pSum.py())
83 + abs(pSum.pz());
84 epCons.fill(epDev);
85 if (epDev > epTol) {
86 cout << " Warning! Event with epDev = " << scientific
87 << setprecision(4) << epDev << " now listed:";
88 event.list();
89 }
90
91 // End of event loop.
92 }
93
94 // Final statistics and histogram output.
95 pythia.statistics();
96 cout << epCons << nFinal << dnparticledy;
97
98 return 0;
99}
100