StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
main20.cc
1 // main20.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. It shows how PYTHIA 8 can write
7 // a Les Houches Event File based on its process-level events.
8 
9 #include "Pythia.h"
10 using namespace Pythia8;
11 int main() {
12 
13  // Generator.
14  Pythia pythia;
15 
16  // Process selection. Minimal masses for gamma*/Z and W+-.
17  pythia.readString("WeakDoubleBoson:all = on");
18  pythia.readString("23:mMin = 50.");
19  pythia.readString("24:mMin = 50.");
20 
21  // Switch off generation of steps subsequent to the process level one.
22  // (These will not be stored anyway, so only steal time.)
23  pythia.readString("PartonLevel:all = off");
24 
25  // Create an LHAup object that can access relevant information in pythia.
26  LHAupFromPYTHIA8 myLHA(&pythia.process, &pythia.info);
27 
28  // Open a file on which LHEF events should be stored, and write header.
29  myLHA.openLHEF("weakbosons.lhe");
30 
31  // LHC 8 TeV initialization.
32  pythia.readString("Beams:eCM = 8000.");
33  pythia.init();
34 
35  // Store initialization info in the LHAup object.
36  myLHA.setInit();
37 
38  // Write out this initialization info on the file.
39  myLHA.initLHEF();
40 
41  // Loop over events.
42  for (int i = 0; i < 100; ++i) {
43 
44  // Generate an event.
45  pythia.next();
46 
47  // Store event info in the LHAup object.
48  myLHA.setEvent();
49 
50  // Write out this event info on the file.
51  myLHA.eventLHEF();
52  }
53 
54  // Statistics: full printout.
55  pythia.stat();
56 
57  // Update the cross section info based on Monte Carlo integration during run.
58  myLHA.updateSigma();
59 
60  // Write endtag. Overwrite initialization info with new cross sections.
61  myLHA.closeLHEF(true);
62 
63  // Done.
64  return 0;
65 }