14 #include <HepMC/GenEvent.h>
15 #include <HepMC/HEPEVT_Wrapper.h>
16 #include <HepMC/IO_BaseClass.h>
17 #include <HepMC/IO_GenEvent.h>
18 #include <HepMC/IO_HEPEVT.h>
19 #include <HepMC/PdfInfo.h>
20 #include <HepMC/PythiaWrapper.h>
21 #include <HepMC/PythiaWrapper6_4.h>
22 #include <HepMC/Units.h>
33 #define pytune pytune_
34 extern "C" int pytune(
int *itune);
42 , _configFile(
"phpythia6.cfg")
44 , _filename_ascii(
"pythia_hepmc.dat")
45 , _registeredTriggers()
66 HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
67 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
71 fSeed =
abs(fSeed) % 900000000;
73 if ((fSeed >= 0) && (fSeed <= 900000000))
75 pydatr.mrpy[0] = fSeed;
80 cout <<
PHWHERE <<
" ERROR: seed " << fSeed <<
" is not valid" << endl;
84 if (
Verbosity()) cout <<
"PHPythia6 random seed: " << fSeed << endl;
103 <<
" events passed trigger" << endl;
107 cout <<
" *------- End PYTHIA Trigger Statistics ------------------------"
108 <<
"-------------------------------------------------* " << endl;
117 cout <<
"PHPythia6::read_config - Reading " <<
_configFile << endl;
122 cout <<
"PHPythia6::read_config - Failed to open file " <<
_configFile << endl;
140 getline(infile, FullLine);
141 while (!infile.eof())
144 if (FullLine[0] ==
'#' || FullLine.substr(0, 2) ==
"//")
146 getline(infile, FullLine);
151 istringstream line(FullLine.c_str());
160 if (label ==
"nevents")
163 cout <<
"nevents\t" << _nevents << endl;
165 else if (label ==
"roots")
168 cout <<
"roots\t" << _roots << endl;
170 else if (label ==
"proj")
173 cout <<
"proj\t" << _proj << endl;
175 else if (label ==
"targ")
178 cout <<
"targ\t" << _targ << endl;
180 else if (label ==
"frame")
183 cout <<
"frame\t" << _frame << endl;
185 else if (label ==
"p1" || label ==
"p2")
189 line >> index >>
value;
192 cout <<
"p1\t" << index <<
" " << value << endl;
196 line >> index >>
value;
199 cout <<
"p2\t" << index <<
" " << value << endl;
222 else if (label ==
"msel")
225 pysubs.msel = (
int) value;
226 cout <<
"msel\t" << value << endl;
229 else if (label ==
"msub")
231 line >> index >>
value;
234 pysubs.msub[index - 1] = (
int) value;
235 cout <<
"msub\t" << index <<
" " << value << endl;
238 else if (label ==
"mstp")
240 line >> index >>
value;
241 pypars.mstp[index - 1] = (
int) value;
242 cout <<
"mstp\t" << index <<
" " << value << endl;
245 else if (label ==
"mstj")
247 line >> index >>
value;
249 cout <<
"mstj\t" << index <<
" " << value << endl;
252 else if (label ==
"mstu")
254 line >> index >>
value;
256 cout <<
"mstu\t" << index <<
" " << value << endl;
259 else if (label ==
"ckin")
261 line >> index >>
value;
262 pysubs.ckin[index - 1] =
value;
263 cout <<
"ckin\t" << index <<
" " << value << endl;
265 else if (label ==
"parp")
267 line >> index >>
value;
268 pypars.parp[index - 1] =
value;
269 cout <<
"parp\t" << index <<
" " << value << endl;
271 else if (label ==
"parj")
273 line >> index >>
value;
275 cout <<
"parj\t" << index <<
" " << value << endl;
277 else if (label ==
"paru")
279 line >> index >>
value;
281 cout <<
"paru\t" << index <<
" " << value << endl;
283 else if (label ==
"parf")
285 line >> index >>
value;
286 pydat2.parf[index - 1] =
value;
287 cout <<
"parf\t" << index <<
" " << value << endl;
289 else if (label ==
"mdme")
292 line >> idc >> index >>
value;
296 cout <<
"mdme\t" << idc <<
" " << index <<
" " << value << endl;
298 else if (label ==
"pmas")
301 line >> idc >> index >>
value;
303 pydat2.pmas[index - 1][idc - 1] =
value;
304 cout <<
"pmas\t" << idc <<
" " << index <<
" " << value << endl;
306 else if (label ==
"pytune")
311 cout <<
"pytune\t" << ivalue << endl;
316 cout <<
"************************************************************" << endl;
317 cout <<
"PHPythia6::ReadConfig(), ERROR this option is not supported: " << FullLine << endl;
318 cout <<
"************************************************************" << endl;
322 getline(infile, FullLine);
326 call_pyinit(_frame.c_str(), _proj.c_str(), _targ.c_str(), _roots);
344 bool passedTrigger =
false;
345 std::vector<bool> theTriggerResults;
352 HepMC::IO_HEPEVT hepevtio;
353 HepMC::GenEvent *evt;
355 while (!passedTrigger)
363 evt = hepevtio.read_next_event();
366 evt->use_units(HepMC::Units::GEV, HepMC::Units::MM);
372 evt->set_signal_process_id(pypars.msti[1 - 1]);
375 evt->set_mpi(pypars.msti[31 - 1]);
378 evt->set_cross_section(HepMC::getPythiaCrossSection());
381 HepMC::PdfInfo pdfinfo;
382 pdfinfo.set_x1(pypars.pari[33 - 1]);
383 pdfinfo.set_x2(pypars.pari[34 - 1]);
384 pdfinfo.set_scalePDF(pypars.pari[22 - 1]);
385 pdfinfo.set_id1(pypars.msti[15 - 1]);
386 pdfinfo.set_id2(pypars.msti[16 - 1]);
387 evt->set_pdf_info(pdfinfo);
391 bool andScoreKeeper =
true;
403 cout <<
"PHPythia6::process_event trigger: "
409 passedTrigger =
true;
414 andScoreKeeper &= trigResult;
419 cout <<
"PHPythia8::process_event - failed trigger: "
426 passedTrigger =
true;
431 if (!passedTrigger)
delete evt;
446 cout <<
"PHPythia6::process_event - Failed to add event to HepMC record!" << endl;
450 if (
Verbosity() > 2) cout <<
"PHPythia6::process_event - FINISHED WHOLE EVENT" << endl;
458 if (fmod(number, 1.0) != 0)
460 cout <<
"Warning: Value " << number <<
" is not an integer." << endl;
461 cout <<
"This parameter requires an integer value." << endl;
462 cout <<
"Value of parameter truncated to " << (
int) number << endl;
477 if (
Verbosity() > 1) cout <<
"PHPythia6::registerTrigger - trigger " << theTrigger->
GetName() <<
" registered" << endl;