11 #ifndef Pythia8_HepMC3Hooks_H 12 #define Pythia8_HepMC3Hooks_H 15 #include "Pythia8/Pythia.h" 16 #include "Pythia8/Plugins.h" 17 #include "Pythia8Plugins/HepMC3.h" 29 bool makeDir(vector<string> path, mode_t mode = 0777) {
37 for (
string& dir : path) {
40 pathNow += (first ?
"" :
"/") + dir;
42 if (stat(pathNow.c_str(), &info) == 0) {
43 if ((info.st_mode & S_IFDIR) == 0)
return false;
48 if (mkdir(pathNow.c_str(), mode) != 0)
return false;
65 pythiaPtr(pythiaPtrIn) {}
66 ~
HepMC3Hooks() {
if (hepMCPtr !=
nullptr)
delete hepMCPtr;}
74 if (hepMCPtr ==
nullptr) {
77 string filename = word(
"HepMC:filename");
78 int idx = mode(
"Parallelism:index");
80 size_t iSuffix = filename.find(
".hepmc");
81 if (iSuffix != string::npos)
82 filename = filename.substr(0,iSuffix);
83 filename = filename +
"_" + to_string(idx) +
".hepmc";
88 if (path.size() > 1) {
90 makeDir(vector<string>(path.begin(), path.end() - 1));
97 hepMCPtr->set_free_parton_warnings(
flag(
"HepMC:freePartonWarnings"));
98 hepMCPtr->set_store_pdf(
flag(
"HepMC:storePDF"));
99 hepMCPtr->set_store_proc(
flag(
"HepMC:storeProcess"));
135 settingsPtr->addWord(
"HepMC:fileName",
"events.hepmc");
136 settingsPtr->
addFlag(
"HepMC:printInconsistency",
"true");
137 settingsPtr->
addFlag(
"HepMC:freePartonWarnings",
"true");
138 settingsPtr->
addFlag(
"HepMC:storePDF",
"true");
139 settingsPtr->
addFlag(
"HepMC:storeProcess",
"true");
149 PYTHIA8_PLUGIN_VERSIONS(PYTHIA_VERSION_INTEGER)
vector< string > splitString(string val, string delim)
Split a string by a delimiter.
Definition: PythiaStdlib.cc:72
Settings * settingsPtr
Pointer to the settings database.
Definition: PhysicsBase.h:85
mutex * mutexPtr
Mutex that should be locked for thread-unsafe code.
Definition: PhysicsBase.h:131
PYTHIA8_PLUGIN_PARALLEL(true)
Declare the plugin.
void onStat(vector< PhysicsBase * >, Pythia *) override
Definition: HepMC3Hooks.h:119
HepMC3Hooks()
Constructors and destructor.
Definition: HepMC3Hooks.h:63
void writeEvent()
Write out the current GenEvent to the internal stream.
Definition: HepMC2.h:451
void set_print_inconsistency(bool b=true)
Set values for some switches.
Definition: HepMC3.h:258
void hepmcSettings(Settings *settingsPtr)
Register HepMC settings.
Definition: HepMC3Hooks.h:134
Status
Enumerate the different status codes the event generation can have.
Definition: PhysicsBase.h:31
void onStat() override
Finalise.
Definition: HepMC3Hooks.h:113
bool makeDir(vector< string > path, mode_t mode=0777)
Definition: HepMC3Hooks.h:29
UserHook to write HepMC3 files.
Definition: HepMC3Hooks.h:58
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:72
bool fillNextEvent(Pythia &pythia)
Definition: HepMC2.h:445
UserHooks is base class for user access to program execution.
Definition: UserHooks.h:32
bool flag(string key) const
Shorthand to read settings values.
Definition: PhysicsBase.h:44
void onEndEvent(Status) override
Print event to HepMC file.
Definition: HepMC3Hooks.h:71
Definition: Settings.h:196
void addFlag(string keyIn, bool defaultIn)
Add new entry.
Definition: Settings.h:280