Skip to content

Commit

Permalink
complete first implementation for Pythia
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Zerwas committed Jul 9, 2024
1 parent 047265b commit 75f84de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions k4GeneratorsConfig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ set(pythia_sources
)

add_executable(pythiaRunner ${pythia_sources})
target_include_directories(pythiaRunner PRIVATE ${PYTHIA8_INCLUDE_DIR})
target_link_libraries(pythiaRunner PRIVATE ${PYTHIA8_LIBRARY} )
target_include_directories(pythiaRunner PRIVATE ${PYTHIA8_INCLUDE_DIR} ${HEPMC3_INCLUDE_DIR})
target_link_libraries(pythiaRunner PRIVATE ${PYTHIA8_LIBRARY} HepMC3::HepMC3 )

install(TARGETS pythiaRunner
EXPORT k4GeneratorsConfigTargets
Expand Down
14 changes: 7 additions & 7 deletions k4GeneratorsConfig/src/pythiaRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <unistd.h>
#include "Pythia8/Pythia.h"
//#include "Pythia8Plugins/HepMC3.h"
#include "Pythia8Plugins/HepMC3.h"

using namespace Pythia8;

Expand Down Expand Up @@ -64,9 +64,9 @@ int main(int argc, char** argv) {
const bool hepmc = pythia.flag("Main:writeHepMC");
const std::string hepmcFile = pythia.word("Main:HepMCFile");
std::cout << "HEPMC file name is " << hepmcFile << std::endl;
// Pythia8ToHepMC3 ToHepMC;
// if (hepmc)
// ToHepMC.setNewFile(hepmcFile);
Pythia8::Pythia8ToHepMC ToHepMC;
if (hepmc)
ToHepMC.setNewFile(hepmcFile);

// Extract settings to be used in the main program.
int nEvent = pythia.mode("Main:numberOfEvents");
Expand All @@ -83,9 +83,9 @@ int main(int argc, char** argv) {
break;
}
// event was ok, write to hepmc file
// if (hepmc) {
// ToHepMC.writeNextEvent(pythia);
// }
if (hepmc) {
ToHepMC.writeNextEvent(pythia);
}
// End of event loop.
}

Expand Down
5 changes: 3 additions & 2 deletions python/Generators/Pythia.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def write_run(self):

if "hepmc" in self.procinfo.get("output_format"):
self.add_run_option("Main:WriteHepMC", "on")
self.add_run_option("Main:HepMCFile",self.GeneratorDatacardName)
outputFile = "{0}.{1}".format(self.GeneratorDatacardBase,self.procinfo.get("output_format"))
self.add_run_option("Main:HepMCFile",outputFile)

self.run += self.procDB.get_run_out()
self.run += self.procDB.get_proc_out()
Expand Down Expand Up @@ -180,7 +181,7 @@ def write_key4hepfile(self):
key4hepRun += self.executable+" "+self.GeneratorDatacardName+"\n"

hepmcformat = self.procinfo.get("output_format")
key4hepRun += "$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i {0} -o edm4hep {1}.hepmc {1}.edm4hep\n".format(hepmcformat,self.GeneratorDatacardBase)
key4hepRun += "$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i {0} -o edm4hep {1}.{0} {1}.edm4hep\n".format(hepmcformat,self.GeneratorDatacardBase)

self.write_Key4hepScript(key4hepRun)

Expand Down

0 comments on commit 75f84de

Please sign in to comment.