10 #include <boost/algorithm/string/classification.hpp>
11 #include <boost/algorithm/string/split.hpp>
14 #include "CLHEP/Random/RandomEngine.h"
33 char* dummy3 =
nullptr;
52 pyslha_(&mupda, &kforig, &iretrn);
63 return service->fRandomEngine->flat();
76 throw cms::Exception(
"PythiaError") <<
"Two Pythia6Service instances claiming Pythia6 ownership." << std::endl;
98 std::vector<std::string> setNames = pythia_params.
getParameter<std::vector<std::string> >(
"parameterSets");
106 for (std::vector<std::string>::const_iterator iter = setNames.begin(); iter != setNames.end(); ++iter) {
107 std::vector<std::string>
lines = pythia_params.
getParameter<std::vector<std::string> >(*iter);
110 if (
line->substr(0, 7) ==
"MRPY(1)")
111 throw cms::Exception(
"PythiaError") <<
"Attempted to set random number"
112 " using Pythia command 'MRPY(1)'."
114 " RandomNumberGeneratorService."
117 if (*iter ==
"CSAParameters") {
119 }
else if (*iter ==
"SLHAParameters") {
121 }
else if (*iter ==
"PYUPDAParameters") {
144 edm::LogInfo(
"Generator|Pythia6Interface") <<
"gen::Pythia6Service is going to initialise Pythia, as no other "
145 "instace has done so yet, and Pythia service routines have been "
146 "requested by a dummy instance."
150 call_pyinit(
"NONE",
"",
"", 0.0);
161 throw cms::Exception(
"PythiaError") <<
"Pythia did not accept \"" << *iter <<
"\"." << std::endl;
168 #define SETCSAPARBUFSIZE 514
172 for (std::vector<std::string>::const_iterator iter =
fParamCSA.begin(); iter !=
fParamCSA.end(); ++iter) {
178 if (iter->length() <= 0)
194 #undef SETCSAPARBUFSIZE
198 std::ostringstream pyCard1;
201 std::ostringstream pyCard2;
212 std::cout <<
"=== WRITING PYUPDA FILE " <<
file <<
" ===" << std::endl;
217 std::cout <<
"=== READING PYUPDA FILE " <<
file <<
" ===" << std::endl;
239 for (std::vector<std::string>::const_iterator iter =
fParamSLHA.begin(); iter !=
fParamSLHA.end(); iter++) {
240 if (iter->find(
"SLHAFILE", 0) == std::string::npos)
245 if (
temp != std::string::npos) {
247 end = iter->find_last_of(
"'") - 1;
250 end = iter->find_last_not_of(
" ",
end);
277 bool write_file =
false;
278 bool usePostPyinit =
false;
286 if (iter->find(
"PYUPDAFILE", 0) != std::string::npos) {
290 if (
temp != std::string::npos) {
292 end = iter->find_last_of(
"'") - 1;
295 end = iter->find_last_not_of(
" ",
end);
298 }
else if (iter->find(
"PYUPDAWRITE", 0) != std::string::npos) {
300 }
else if (iter->find(
"PYUPDApostPYINIT", 0) != std::string::npos) {
301 usePostPyinit =
true;
305 if (!shortfile.empty()) {
315 if (afterPyinit == usePostPyinit || (write_file && afterPyinit)) {
324 std::set<std::string>
blocks;
325 unsigned int model = 0, subModel = 0;
326 char tempslhaname[] =
"pythia6slhaXXXXXX";
327 int fd = mkstemp(tempslhaname);
330 std::stringstream f_info;
331 for (std::vector<std::string>::const_iterator iter =
lines.begin(); iter !=
lines.end(); ++iter) {
337 if (
pos != std::string::npos)
343 if (!boost::algorithm::is_space()(
line[0])) {
344 std::vector<std::string> tokens;
345 boost::split(tokens,
line, boost::algorithm::is_space(), boost::token_compress_on);
349 if (tokens.size() < 2)
351 if (tokens[0] ==
"BLOCK") {
357 if (tokens[0] ==
"DECAY") {
361 }
else if (
block ==
"MODSEL") {
362 std::istringstream
ss(
line);
364 }
else if (
block ==
"SMINPUTS") {
365 std::istringstream
ss(
line);
377 pydat2_.pmas[0][23 - 1] =
value;
380 pydat2_.pmas[0][6 - 1] =
value;
383 pydat2_.pmas[0][15 - 1] =
value;
388 write(
fd, f_info.str().c_str(), f_info.str().size());
391 if (
blocks.count(
"SMINPUTS"))
394 (pydat2_.pmas[0][23 - 1] * pydat2_.pmas[0][23 - 1]));
417 if (
blocks.count(
"DECAY"))