10 #include <boost/bind.hpp>
11 #include <boost/algorithm/string/classification.hpp>
12 #include <boost/algorithm/string/split.hpp>
13 #include <boost/filesystem.hpp>
15 #include "CLHEP/Random/RandomEngine.h"
34 char* dummy3 =
nullptr;
53 pyslha_(&mupda, &kforig, &iretrn);
64 return service->fRandomEngine->flat();
77 throw cms::Exception(
"PythiaError") <<
"Two Pythia6Service instances claiming Pythia6 ownership." << std::endl;
99 std::vector<std::string> setNames = pythia_params.
getParameter<std::vector<std::string> >(
"parameterSets");
107 for (std::vector<std::string>::const_iterator iter = setNames.begin(); iter != setNames.end(); ++iter) {
108 std::vector<std::string>
lines = pythia_params.
getParameter<std::vector<std::string> >(*iter);
111 if (
line->substr(0, 7) ==
"MRPY(1)")
112 throw cms::Exception(
"PythiaError") <<
"Attempted to set random number"
113 " using Pythia command 'MRPY(1)'."
115 " RandomNumberGeneratorService."
118 if (*iter ==
"CSAParameters") {
120 }
else if (*iter ==
"SLHAParameters") {
122 }
else if (*iter ==
"PYUPDAParameters") {
145 edm::LogInfo(
"Generator|Pythia6Interface") <<
"gen::Pythia6Service is going to initialise Pythia, as no other "
146 "instace has done so yet, and Pythia service routines have been "
147 "requested by a dummy instance."
151 call_pyinit(
"NONE",
"",
"", 0.0);
162 throw cms::Exception(
"PythiaError") <<
"Pythia did not accept \"" << *iter <<
"\"." << std::endl;
169 #define SETCSAPARBUFSIZE 514
173 for (std::vector<std::string>::const_iterator iter =
fParamCSA.begin(); iter !=
fParamCSA.end(); ++iter) {
179 if (iter->length() <= 0)
195 #undef SETCSAPARBUFSIZE
199 std::ostringstream pyCard1;
202 std::ostringstream pyCard2;
213 std::cout <<
"=== WRITING PYUPDA FILE " <<
file <<
" ===" << std::endl;
218 std::cout <<
"=== READING PYUPDA FILE " <<
file <<
" ===" << std::endl;
240 for (std::vector<std::string>::const_iterator iter =
fParamSLHA.begin(); iter !=
fParamSLHA.end(); iter++) {
241 if (iter->find(
"SLHAFILE", 0) == std::string::npos)
246 if (
temp != std::string::npos) {
248 end = iter->find_last_of(
"'") - 1;
251 end = iter->find_last_not_of(
" ",
end);
278 bool write_file =
false;
279 bool usePostPyinit =
false;
287 if (iter->find(
"PYUPDAFILE", 0) != std::string::npos) {
291 if (
temp != std::string::npos) {
293 end = iter->find_last_of(
"'") - 1;
296 end = iter->find_last_not_of(
" ",
end);
299 }
else if (iter->find(
"PYUPDAWRITE", 0) != std::string::npos) {
301 }
else if (iter->find(
"PYUPDApostPYINIT", 0) != std::string::npos) {
302 usePostPyinit =
true;
306 if (!shortfile.empty()) {
316 if (afterPyinit == usePostPyinit || (write_file && afterPyinit)) {
325 std::set<std::string>
blocks;
326 unsigned int model = 0, subModel = 0;
328 std::string fnamest = boost::filesystem::unique_path().string();
329 const char*
fname = fnamest.c_str();
332 for (std::vector<std::string>::const_iterator iter =
lines.begin(); iter !=
lines.end(); ++iter) {
338 if (
pos != std::string::npos)
344 if (!boost::algorithm::is_space()(
line[0])) {
345 std::vector<std::string> tokens;
346 boost::split(tokens,
line, boost::algorithm::is_space(), boost::token_compress_on);
350 if (tokens.size() < 2)
352 if (tokens[0] ==
"BLOCK") {
358 if (tokens[0] ==
"DECAY") {
362 }
else if (
block ==
"MODSEL") {
363 std::istringstream
ss(
line);
365 }
else if (
block ==
"SMINPUTS") {
366 std::istringstream
ss(
line);
378 pydat2_.pmas[0][23 - 1] =
value;
381 pydat2_.pmas[0][6 - 1] =
value;
384 pydat2_.pmas[0][15 - 1] =
value;
391 if (
blocks.count(
"SMINPUTS"))
394 (pydat2_.pmas[0][23 - 1] * pydat2_.pmas[0][23 - 1]));
417 if (
blocks.count(
"DECAY"))