1 // main53.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2013 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.
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
14 using namespace Pythia8;
18 // Generator. Shorthand for the event.
20 Event& event = pythia.event;
22 // Read in commands from external file.
23 pythia.readFile("main53.cmnd");
25 // Extract settings to be used in the main program.
26 int nEvent = pythia.mode("Main:numberOfEvents");
28 // Initialize. Either of two opions, to be picked in main53.cmnd.
29 // 1) Read in external event with incoming photon in the ME,
30 // from pre-generated .lhe file (thanks to SANC and R. Sadykov).
31 // 2) Use internal fermion gamma -> W+- fermion' process.
34 // Histograms for pT distribution in gluon production vertex.
35 Hist pTprim( "pT of photon production, no ISR", 100, 0., 100.);
36 Hist pTwith( "pT of photon production, with ISR", 100, 0., 100.);
39 for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
41 // Generate events. Quit if failure.
46 // Analyze event to find branching where photon is produced.
47 int iGam = (event[3].id() == 22) ? 3 : 4;
48 int iGamMother = iGam;
50 iGamMother = event[iGam].mother1();
51 if (iGamMother < iGam || event[iGamMother].id() != 22) break;
55 // Find and histogram pT in this branching.
56 if (iGamMother < iGam) pTprim.fill( event[iGam].pT() );
59 int size = event.size();
61 while (event[iQ].status() != -43 && iQ < size - 1);
62 if (event[iQ].status() == -43) pTwith.fill( event[iQ].pT() );
68 // Final statistics and histogram output.
70 cout << pTprim << pTwith;