10 #include <boost/algorithm/string/classification.hpp>
11 #include <boost/algorithm/string/split.hpp>
14 #include "CLHEP/Random/RandomEngine.h"
33 char* dummy3 =
nullptr;
37 py1ent_(dummy, dummy, dummy2, dummy2, dummy2);
52 pyslha_(&mupda, &kforig, &iretrn);
62 Pythia6Service* service = FortranInstance::getInstance<Pythia6Service>();
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);
109 for (std::vector<std::string>::const_iterator
line = lines.begin();
line != lines.end(); ++
line) {
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)
181 size_t maxSize = iter->length() > (SETCSAPARBUFSIZE - 2) ? (SETCSAPARBUFSIZE - 2) : iter->length();
182 strncpy(buf, iter->c_str(),
maxSize);
184 if (buf[maxSize - 1] !=
'\n') {
188 buf[maxSize + 1] = 0;
194 #undef SETCSAPARBUFSIZE
198 std::ostringstream pyCard1;
201 std::ostringstream pyCard2;
205 fioopn_(&fUnitSLHA, file, strlen(file));
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;
249 start = iter->find_first_not_of(
" ", start);
250 end = iter->find_last_not_of(
" ", end);
252 std::string shortfile = iter->substr(start, end - start + 1);
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;
294 start = iter->find_first_not_of(
" ", start);
295 end = iter->find_last_not_of(
" ", end);
297 shortfile = iter->substr(start, end - start + 1);
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) {
335 std::transform(line.begin(), line.end(), line.begin(), (int (*)(int))std::toupper);
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") {
353 blocks.insert(block);
357 if (tokens[0] ==
"DECAY") {
359 blocks.insert(block);
361 }
else if (block ==
"MODSEL") {
362 std::istringstream
ss(line);
363 ss >> model >> subModel;
364 }
else if (block ==
"SMINPUTS") {
365 std::istringstream
ss(line);
368 ss >> index >>
value;
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]));
408 if (model || blocks.count(
"HIGMIX") || blocks.count(
"SBOTMIX") || blocks.count(
"STOPMIX") ||
409 blocks.count(
"STAUMIX") || blocks.count(
"AMIX") || blocks.count(
"NMIX") || blocks.count(
"UMIX") ||
410 blocks.count(
"VMIX"))
412 if (model || blocks.count(
"QNUMBERS") || blocks.count(
"PARTICLE") || blocks.count(
"MINPAR") ||
413 blocks.count(
"EXTPAR") || blocks.count(
"SMINPUTS") || blocks.count(
"SMINPUTS"))
415 if (blocks.count(
"MASS"))
417 if (blocks.count(
"DECAY"))
static void call_pyupda(int opt, int iunit)
void pyupda_(int *, int *)
void fioopn_(int *unit, const char *line, int length)
bool call_pygive(const std::string &line)
void pyjoin_(int &njoin, int ijoin[])
void pygive_(const char *, int)
void fioopnw_(int *unit, const char *line, int length)
void pyslha_(int *, int *, int *)
tuple maxSize
'/store/data/Commissioning08/BeamHalo/RECO/StuffAlmostToP5_v1/000/061/642/10A0FE34-A67D-DD11-AD05-000...
void setSLHAFromHeader(const std::vector< std::string > &lines)
float __attribute__((vector_size(8))) cms_float32x2_t
~Pythia6Service() override
std::vector< std::string > fParamPYUPDA
static int call_pyslha(int mupda, int kforig=0)
void setPYUPDAParams(bool afterPyinit)
std::vector< std::string > fParamGeneral
static Pythia6Service * fPythia6Owner
Log< level::Info, false > LogInfo
CLHEP::HepRandomEngine * fRandomEngine
std::vector< std::string > fParamCSA
void openSLHA(const char *)
T getParameter(std::string const &) const
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
void openPYUPDA(const char *, bool write_file)
std::string fullPath() const
std::vector< std::string > fParamSLHA
void txgive_(const char *, int)
Basic3DVector unit() const