10 #include "Pythia8/Pythia.h"
11 #include "Pythia8ToHepMC3.h"
14 using namespace HepMC3;
17 int main(
int argc,
char **argv) {
19 std::cout <<
"Usage: " << argv[0] <<
" <pythia_config_file> <output_hepmc3_file>" << std::endl;
23 Pythia8::Pythia pythia;
25 pythia.readFile(argv[1]);
27 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();
28 struct GenRunInfo::ToolInfo generator={std::string(
"Pythia8"),std::to_string(PYTHIA_VERSION).substr(0,5),std::string(
"Used generator")};
29 run->tools().push_back(generator);
31 run->tools().push_back(config);
32 std::vector<std::string> names;
33 for (
int iWeight=0; iWeight < pythia.info.nWeights(); ++iWeight) {
34 std::string s=pythia.info.weightLabel(iWeight);
35 if (!s.length()) s=std::to_string((
long long int)iWeight);
38 if (!names.size()) names.push_back(
"default");
39 run->set_weight_names(names);
42 int nEvent = pythia.mode(
"Main:numberOfEvents");
44 for(
int i = 0; i< nEvent; ++i ) {
45 if( !pythia.next() )
continue;
47 GenEvent hepmc( Units::GEV, Units::MM );
49 pythiaToHepMC.fill_next_event(pythia.event, &hepmc, -1, &pythia.info);
52 std::cout <<
"First event: " << std::endl;
56 file.write_event(hepmc);
Definition of class WriterAscii.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
Stores event-related information.
Definition of static class Print.
int main(int argc, char **argv)
Definition of class GenEvent.
GenEvent I/O serialization for structured text files.