1 // main41.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.
6 // Author: Mikhail Kirsanov, Mikhail.Kirsanov@cern.ch, based on main01.cc.
7 // This program illustrates how HepMC can be interfaced to Pythia8.
8 // It studies the charged multiplicity distribution at the LHC.
9 // HepMC events are output to the hepmcout41.dat file.
11 // WARNING: typically one needs 25 MB/100 events at the LHC.
12 // Therefore large event samples may be impractical.
15 #include "HepMCInterface.h"
16 #include "HepMC/GenEvent.h"
17 #include "HepMC/IO_GenEvent.h"
19 using namespace Pythia8;
23 // Interface for conversion from Pythia8::Event to HepMC event.
24 HepMC::I_Pythia8 ToHepMC;
26 // Specify file where HepMC events will be stored.
27 HepMC::IO_GenEvent ascii_io("hepmcout41.dat", std::ios::out);
29 // Generator. Process selection. LHC initialization. Histogram.
31 pythia.readString("Beams:eCM = 8000.");
32 pythia.readString("HardQCD:all = on");
33 pythia.readString("PhaseSpace:pTHatMin = 20.");
35 Hist mult("charged multiplicity", 100, -0.5, 799.5);
37 // Begin event loop. Generate event. Skip if error.
38 for (int iEvent = 0; iEvent < 100; ++iEvent) {
39 if (!pythia.next()) continue;
41 // Find number of all final charged particles and fill histogram.
43 for (int i = 0; i < pythia.event.size(); ++i)
44 if (pythia.event[i].isFinal() && pythia.event[i].isCharged())
46 mult.fill( nCharged );
48 // Construct new empty HepMC event and fill it.
49 // Units will be as chosen for HepMC build, but can be changed
50 // by arguments, e.g. GenEvt( HepMC::Units::GEV, HepMC::Units::MM)
51 HepMC::GenEvent* hepmcevt = new HepMC::GenEvent();
52 ToHepMC.fill_next_event( pythia, hepmcevt );
54 // Write the HepMC event to file. Done with it.
58 // End of event loop. Statistics. Histogram.