Thank you so much for your answer @sbinet
I have the root file (small) on my work computer but I cannot reach now.
In an hour, I will post the root file here and will inform you.
ah… sorry, my tool isn’t (yet) able to read that kind of ROOT file.
sorry.
but here is the code to convert a Pythia Event into a HepMC2 file:
// main41.cc is a part of the PYTHIA event generator.
// Copyright (C) 2017 Torbjorn Sjostrand.
// PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
// Please respect the MCnet Guidelines, see GUIDELINES for details.
// Author: Mikhail Kirsanov, Mikhail.Kirsanov@cern.ch, based on main01.cc.
// This program illustrates how HepMC can be interfaced to Pythia8.
// It studies the charged multiplicity distribution at the LHC.
// HepMC events are output to the hepmcout41.dat file.
// WARNING: typically one needs 25 MB/100 events at the LHC.
// Therefore large event samples may be impractical.
#include "Pythia8/Pythia.h"
#include "Pythia8Plugins/HepMC2.h"
using namespace Pythia8;
int main() {
// Interface for conversion from Pythia8::Event to HepMC event.
HepMC::Pythia8ToHepMC ToHepMC;
// Specify file where HepMC events will be stored.
HepMC::IO_GenEvent ascii_io("hepmcout41.dat", std::ios::out);
// Generator. Process selection. LHC initialization. Histogram.
Pythia pythia;
pythia.readString("Beams:eCM = 8000.");
pythia.readString("HardQCD:all = on");
pythia.readString("PhaseSpace:pTHatMin = 20.");
pythia.init();
Hist mult("charged multiplicity", 100, -0.5, 799.5);
// Begin event loop. Generate event. Skip if error.
for (int iEvent = 0; iEvent < 100; ++iEvent) {
if (!pythia.next()) continue;
// Find number of all final charged particles and fill histogram.
int nCharged = 0;
for (int i = 0; i < pythia.event.size(); ++i)
if (pythia.event[i].isFinal() && pythia.event[i].isCharged())
++nCharged;
mult.fill( nCharged );
// Construct new empty HepMC event and fill it.
// Units will be as chosen for HepMC build; but can be changed
// by arguments, e.g. GenEvt( HepMC::Units::GEV, HepMC::Units::MM)
HepMC::GenEvent* hepmcevt = new HepMC::GenEvent();
ToHepMC.fill_next_event( pythia, hepmcevt );
// Write the HepMC event to file. Done with it.
ascii_io << hepmcevt;
delete hepmcevt;
// End of event loop. Statistics. Histogram.
}
pythia.stat();
cout << mult;
// Done.
return 0;
}
Thank you for your help @sbinet
despite the compiling the Pythia with hepmc still main41 does not work.
I checked all the header files needed.
But unfortunately it’s not working.
Than, I decided to use pythia8 examples (main41 & main42). Because, these examples are about hepmc file format.
I compiled pythia8 with hepmc. Everything seems well when I try to work with main41 examples gives header file errors.
this: fatal error: ‘Pythia8/Pythia.h’ file not found
But I am pretty sure it’s not about the header file because header files reachable from macro.
include paths is true !
as a result,
It’s not important to use “pythiaExample.c” or main41.cc I just need to generate Pythia events than use delphes.
pythiaexample.c gives root file but I need something like lhef, hep or hepmc output.
It would be great to learn how can I do this.