]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PYTHIA8/pythia8145/examples/main43.cc
New pythia8 version
[u/mrichter/AliRoot.git] / PYTHIA8 / pythia8145 / examples / main43.cc
CommitLineData
9419eeef 1// main43.cc is a part of the PYTHIA event generator.
2// Copyright (C) 2008 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 interface an external process with an incoming photon
8// in a hadron beam, using the MRST2004QED PDF set.
9// All input apart from the name of the external LHEF file is specified in the
10// main43.cmnd file.
11
12#include "Pythia.h"
13
14using namespace Pythia8;
15
16int main() {
17
18 // Generator. Shorthand for the event.
19 Pythia pythia;
20 Event& event = pythia.event;
21
22 // Read in commands from external file.
23 pythia.readFile("main43.cmnd");
24
25 // Extract settings to be used in the main program.
26 int nEvent = pythia.mode("Main:numberOfEvents");
27 int nList = pythia.mode("Main:numberToList");
28 int nShow = pythia.mode("Main:timesToShow");
29 bool showCS = pythia.flag("Main:showChangedSettings");
30 bool showAS = pythia.flag("Main:showAllSettings");
31 bool showCPD = pythia.flag("Main:showChangedParticleData");
32 bool showAPD = pythia.flag("Main:showAllParticleData");
33
34 // Initialize. Either of two opions, to be picked in main43.cmnd.
35 // 1) Read in external event with incoming photon in the ME,
36 // from pre-generated .lhe file (thanks to SANC and R. Sadykov).
37 // 2) Use internal fermion gamma -> W+- fermion' process.
38 pythia.init();
39
40 // List changed data.
41 if (showCS) pythia.settings.listChanged();
42 if (showAS) pythia.settings.listAll();
43
44 // List particle data.
45 if (showCPD) pythia.particleData.listChanged();
46 if (showAPD) pythia.particleData.listAll();
47
48 // Histograms for pT distribution in gluon production vertex.
49 Hist pTprim( "pT of photon production, no ISR", 100, 0., 100.);
50 Hist pTwith( "pT of photon production, with ISR", 100, 0., 100.);
51
52 // Begin event loop.
53 int nPace = max(1, nEvent / max(1, nShow) );
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 break;
61 }
62
63 // List first few events, both hard process and complete events.
64 if (iEvent < nList) {
65 pythia.process.list();
66 event.list();
67 }
68
69 // Analyze event to find branching where photon is produced.
70 int iGam = (event[3].id() == 22) ? 3 : 4;
71 int iGamMother = iGam;
72 for ( ; ; ) {
73 iGamMother = event[iGam].mother1();
74 if (iGamMother < iGam || event[iGamMother].id() != 22) break;
75 iGam = iGamMother;
76 }
77
78 // Find and histogram pT in this branching.
79 if (iGamMother < iGam) pTprim.fill( event[iGam].pT() );
80 else {
81 int iQ = iGamMother;
82 int size = event.size();
83 do ++iQ;
84 while (event[iQ].status() != -43 && iQ < size - 1);
85 if (event[iQ].status() == -43) pTwith.fill( event[iQ].pT() );
86 }
87
88 // End of event loop.
89 }
90
91 // Final statistics and histogram output.
92 pythia.statistics();
93 cout << pTprim << pTwith;
94
95 return 0;
96}
97