10 #include "Pythia8/Pythia.h"
11 #ifdef HEPMC3_USE_INTERFACE_FROM_PYTHIA8
12 #include "Pythia8Plugins/HepMC3.h"
14 #include "Pythia8ToHepMC3.h"
20 int main(
int argc,
char **argv) {
22 std::cout <<
"Usage: " << argv[0] <<
" <pythia_config_file> <output_hepmc3_file>" << std::endl;
26 Pythia8::Pythia pythia;
28 pythia.readFile(argv[1]);
30 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();
31 struct GenRunInfo::ToolInfo generator={std::string(
"Pythia8"),std::to_string(PYTHIA_VERSION).substr(0,5),std::string(
"Used generator")};
32 run->
tools().push_back(generator);
34 run->
tools().push_back(config);
35 std::vector<std::string> names;
36 for (
int iWeight=0; iWeight < pythia.info.nWeights(); ++iWeight) {
37 std::string s=pythia.info.weightLabel(iWeight);
38 if (!s.length()) s=std::to_string((
long long int)iWeight);
41 if (!names.size()) names.push_back(
"default");
45 int nEvent = pythia.mode(
"Main:numberOfEvents");
47 for(
int i = 0; i< nEvent; ++i ) {
48 if( !pythia.next() )
continue;
50 GenEvent hepmc( Units::GEV, Units::MM );
52 pythiaToHepMC.fill_next_event(pythia.event, &hepmc, -1, &pythia.info);
55 std::cout <<
"First event: " << std::endl;
59 file.write_event(hepmc);