14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
16 #include <HepMC/GenEvent.h>
17 #pragma GCC diagnostic pop
19 #include <HepMC/HEPEVT_Wrapper.h>
20 #include <HepMC/IO_BaseClass.h>
21 #include <HepMC/IO_GenEvent.h>
22 #include <HepMC/IO_HEPEVT.h>
23 #include <HepMC/PdfInfo.h>
24 #include <HepMC/PythiaWrapper.h>
25 #include <HepMC/PythiaWrapper6_4.h>
26 #include <HepMC/Units.h>
37 #define pytune pytune_
38 extern "C" int pytune(
int *itune);
46 , _configFile(
"phpythia6.cfg")
48 , _filename_ascii(
"pythia_hepmc.dat")
49 , _registeredTriggers()
70 HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
71 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
75 fSeed = abs(fSeed) % 900000000;
77 if ((fSeed >= 0) && (fSeed <= 900000000))
84 cout <<
PHWHERE <<
" ERROR: seed " << fSeed <<
" is not valid" << endl;
88 if (
Verbosity()) cout <<
"PHPythia6 random seed: " << fSeed << endl;
107 <<
" events passed trigger" << endl;
111 cout <<
" *------- End PYTHIA Trigger Statistics ------------------------"
112 <<
"-------------------------------------------------* " << endl;
121 cout <<
"PHPythia6::read_config - Reading " <<
_configFile << endl;
126 cout <<
"PHPythia6::read_config - Failed to open file " <<
_configFile << endl;
144 getline(infile, FullLine);
145 while (!infile.eof())
148 if (FullLine[0] ==
'#' || FullLine.substr(0, 2) ==
"//")
150 getline(infile, FullLine);
155 istringstream
line(FullLine.c_str());
161 std::transform(label.begin(), label.end(), label.begin(), (int (*)(int)) std::tolower);
164 if (label ==
"nevents")
167 cout <<
"nevents\t" << _nevents << endl;
169 else if (label ==
"roots")
172 cout <<
"roots\t" << _roots << endl;
174 else if (label ==
"proj")
177 cout <<
"proj\t" << _proj << endl;
179 else if (label ==
"targ")
182 cout <<
"targ\t" << _targ << endl;
184 else if (label ==
"frame")
187 cout <<
"frame\t" << _frame << endl;
189 else if (label ==
"p1" || label ==
"p2")
196 cout <<
"p1\t" << index <<
" " << value << endl;
203 cout <<
"p2\t" << index <<
" " << value << endl;
226 else if (label ==
"msel")
229 pysubs.msel = (int) value;
230 cout <<
"msel\t" << value << endl;
233 else if (label ==
"msub")
238 pysubs.msub[index - 1] = (int) value;
239 cout <<
"msub\t" << index <<
" " << value << endl;
242 else if (label ==
"mstp")
245 pypars.mstp[index - 1] = (int) value;
246 cout <<
"mstp\t" << index <<
" " << value << endl;
249 else if (label ==
"mstj")
252 pydat1.mstj[index - 1] = (int) value;
253 cout <<
"mstj\t" << index <<
" " << value << endl;
256 else if (label ==
"mstu")
259 pydat1.mstu[index - 1] = (int) value;
260 cout <<
"mstu\t" << index <<
" " << value << endl;
263 else if (label ==
"ckin")
267 cout <<
"ckin\t" << index <<
" " << value << endl;
269 else if (label ==
"parp")
273 cout <<
"parp\t" << index <<
" " << value << endl;
275 else if (label ==
"parj")
279 cout <<
"parj\t" << index <<
" " << value << endl;
281 else if (label ==
"paru")
285 cout <<
"paru\t" << index <<
" " << value << endl;
287 else if (label ==
"parf")
291 cout <<
"parf\t" << index <<
" " << value << endl;
293 else if (label ==
"mdme")
300 cout <<
"mdme\t" << idc <<
" " << index <<
" " << value << endl;
302 else if (label ==
"pmas")
308 cout <<
"pmas\t" << idc <<
" " << index <<
" " << value << endl;
310 else if (label ==
"pytune")
315 cout <<
"pytune\t" << ivalue << endl;
320 cout <<
"************************************************************" << endl;
321 cout <<
"PHPythia6::ReadConfig(), ERROR this option is not supported: " << FullLine << endl;
322 cout <<
"************************************************************" << endl;
326 getline(infile, FullLine);
330 call_pyinit(_frame.c_str(), _proj.c_str(), _targ.c_str(), _roots);
348 bool passedTrigger =
false;
349 std::vector<bool> theTriggerResults;
356 HepMC::IO_HEPEVT hepevtio;
357 HepMC::GenEvent *evt;
359 while (!passedTrigger)
367 evt = hepevtio.read_next_event();
370 evt->use_units(HepMC::Units::GEV, HepMC::Units::MM);
376 evt->set_signal_process_id(
pypars.msti[1 - 1]);
379 evt->set_mpi(
pypars.msti[31 - 1]);
382 evt->set_cross_section(HepMC::getPythiaCrossSection());
385 HepMC::PdfInfo pdfinfo;
386 pdfinfo.set_x1(
pypars.pari[33 - 1]);
387 pdfinfo.set_x2(
pypars.pari[34 - 1]);
388 pdfinfo.set_scalePDF(
pypars.pari[22 - 1]);
389 pdfinfo.set_id1(
pypars.msti[15 - 1]);
390 pdfinfo.set_id2(
pypars.msti[16 - 1]);
391 evt->set_pdf_info(pdfinfo);
395 bool andScoreKeeper =
true;
407 cout <<
"PHPythia6::process_event trigger: "
413 passedTrigger =
true;
418 andScoreKeeper &= trigResult;
423 cout <<
"PHPythia8::process_event - failed trigger: "
430 passedTrigger =
true;
435 if (!passedTrigger)
delete evt;
450 cout <<
"PHPythia6::process_event - Failed to add event to HepMC record!" << endl;
454 if (
Verbosity() > 2) cout <<
"PHPythia6::process_event - FINISHED WHOLE EVENT" << endl;
462 if (fmod(number, 1.0) != 0)
464 cout <<
"Warning: Value " << number <<
" is not an integer." << endl;
465 cout <<
"This parameter requires an integer value." << endl;
466 cout <<
"Value of parameter truncated to " << (int) number << endl;
481 if (
Verbosity() > 1) cout <<
"PHPythia6::registerTrigger - trigger " << theTrigger->
GetName() <<
" registered" << endl;