22 #include <HepMC/GenEvent.h>
23 #include <HepMC/Units.h>
25 #include <Pythia8/Event.h>
26 #include <Pythia8/Info.h>
27 #include <Pythia8/Pythia.h>
28 #include <Pythia8Plugins/HepMC2.h>
30 #include <boost/format.hpp>
44 , m_TriggersAND(
false)
46 , m_ConfigFileName(
"phpythia8.cfg")
47 , m_Pythia8ToHepMC(nullptr)
48 , m_SaveEventWeightFlag(
true)
49 , m_SaveIntegratedLuminosityFlag(
true)
50 , m_IntegralNode(nullptr)
52 char *charPath = getenv(
"PYTHIA8");
55 cout <<
"PHPythia8::Could not find $PYTHIA8 path!" << endl;
59 std::string thePath(charPath);
60 thePath +=
"/xmldoc/";
61 m_Pythia8 =
new Pythia8::Pythia(thePath.c_str());
64 m_Pythia8ToHepMC->set_store_proc(
true);
65 m_Pythia8ToHepMC->set_store_pdf(
true);
66 m_Pythia8ToHepMC->set_store_xsec(
true);
80 for (
unsigned int j = 0; j <
m_Commands.size(); j++)
95 seed = seed % 900000000;
98 if ((seed > 0) && (seed <= 900000000))
100 m_Pythia8->readString(
"Random:setSeed = on");
101 m_Pythia8->readString(str(boost::format(
"Random:seed = %1%") % seed));
105 cout <<
PHWHERE <<
" ERROR: seed " << seed <<
" is not valid" << endl;
109 cout <<
"PHPythia8 random seed: " << seed << endl;
129 <<
" events passed trigger" << endl;
133 cout <<
" *------- End PYTHIA Trigger Statistics ------------------------"
134 <<
"-------------------------------------------------* " << endl;
138 cout <<
"Integral information on stored on node RUN/PHGenIntegral:" << endl;
140 cout <<
" *------- End PYTHIA Integral Node Print ------------------------"
141 <<
"-------------------------------------------------* " << endl;
159 cout <<
"PHPythia8::read_config - Failed to open file " <<
m_ConfigFileName << endl;
178 bool passedGen =
false;
179 bool passedTrigger =
false;
182 while (!passedTrigger)
194 bool andScoreKeeper =
true;
206 cout <<
"PHPythia8::process_event trigger: "
212 passedTrigger =
true;
217 andScoreKeeper &= trigResult;
222 cout <<
"PHPythia8::process_event - failed trigger: "
229 passedTrigger =
true;
238 HepMC::GenEvent *
genevent =
new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM);
243 genevent->weights().push_back(
m_Pythia8->info.weight());
250 cout <<
"PHPythia8::process_event - Failed to add event to HepMC record!" << endl;
283 cout <<
PHWHERE <<
"RUN Node missing doing nothing" << endl;
288 m_IntegralNode = findNode::getClass<PHGenIntegral>(sumNode,
"PHGenIntegral");
293 sumNode->addNode(newmapnode);
297 cout <<
"PHPythia8::create_node_tree - Fatal Error - "
298 <<
"RUN/PHGenIntegral node already exist. "
299 <<
"It is messy to overwrite integrated luminosities. Please turn off this function in the macro with " << endl;
300 cout <<
" PHPythia8::save_integrated_luminosity(false);" << endl;
301 cout <<
"The current RUN/PHGenIntegral node is ";