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" 35 char * dummy3 =
nullptr;
39 py1ent_(dummy, dummy, dummy2, dummy2, dummy2);
50 void fioopnw_(
int* unit,
const char* line,
int length );
52 void pyslha_(
int*,
int*,
int* );
56 pyslha_(&mupda, &kforig, &iretrn);
80 : fRandomEngine(
nullptr), fUnitSLHA(24), fUnitPYUPDA(25)
89 "Two Pythia6Service instances claiming Pythia6 ownership." <<
114 std::vector<std::string> setNames =
115 pythia_params.
getParameter<std::vector<std::string> >(
"parameterSets");
124 for(std::vector<std::string>::const_iterator iter = setNames.begin();
125 iter != setNames.end(); ++iter)
127 std::vector<std::string>
lines =
128 pythia_params.
getParameter< std::vector<std::string> >(*iter);
130 for(std::vector<std::string>::const_iterator
line = lines.begin();
133 if (
line->substr(0, 7) ==
"MRPY(1)")
135 "Attempted to set random number" 136 " using Pythia command 'MRPY(1)'." 138 " RandomNumberGeneratorService." <<
141 if ( *iter ==
"CSAParameters" )
145 else if ( *iter ==
"SLHAParameters" )
149 else if ( *iter ==
"PYUPDAParameters" )
178 "gen::Pythia6Service is going to initialise Pythia, as no other " 179 "instace has done so yet, and Pythia service routines have been " 180 "requested by a dummy instance." << std::endl;
183 call_pyinit(
"NONE",
"",
"", 0.0);
193 for(std::vector<std::string>::const_iterator iter =
fParamGeneral.begin();
198 <<
"Pythia did not accept \"" 199 << *iter <<
"\"." << std::endl;
207 #define SETCSAPARBUFSIZE 514 211 for(std::vector<std::string>::const_iterator iter =
fParamCSA.begin();
219 if (iter->length() <= 0)
222 size_t maxSize = iter->length() > (SETCSAPARBUFSIZE-2) ? (SETCSAPARBUFSIZE-2) : iter->length();
223 strncpy(buf, iter->c_str(),
maxSize);
225 if (buf[maxSize-1] !=
'\n')
230 buf[maxSize + 1] = 0;
236 #undef SETCSAPARBUFSIZE 242 std::ostringstream pyCard1 ;
245 std::ostringstream pyCard2 ;
249 fioopn_( &fUnitSLHA, file, strlen(file) );
259 std::cout<<
"=== WRITING PYUPDA FILE "<<file<<
" ==="<<std::endl;
264 std::cout<<
"=== READING PYUPDA FILE "<<file<<
" ==="<<std::endl;
293 for (std::vector<std::string>::const_iterator iter =
fParamSLHA.begin();
297 if( iter->find(
"SLHAFILE", 0 ) == std::string::npos )
continue;
301 if( temp != std::string::npos ) {
303 end = iter->find_last_of(
"'" ) - 1;
305 start = iter->find_first_not_of(
" ", start );
306 end = iter->find_last_not_of(
" ", end );
308 std::string shortfile = iter->substr( start, end - start + 1 );
335 bool write_file =
false;
336 bool usePostPyinit =
false;
342 for (std::vector<std::string>::const_iterator iter =
fParamPYUPDA.begin();
346 if( iter->find(
"PYUPDAFILE", 0 ) != std::string::npos ) {
350 if( temp != std::string::npos ) {
352 end = iter->find_last_of(
"'" ) - 1;
354 start = iter->find_first_not_of(
" ", start );
355 end = iter->find_last_not_of(
" ", end );
357 shortfile = iter->substr( start, end - start + 1 );
358 }
else if ( iter->find(
"PYUPDAWRITE", 0 ) != std::string::npos ) {
360 }
else if ( iter->find(
"PYUPDApostPYINIT", 0 ) != std::string::npos ) {
361 usePostPyinit =
true;
365 if (!shortfile.empty()) {
375 if (afterPyinit == usePostPyinit || (write_file && afterPyinit)) {
385 std::set<std::string>
blocks;
386 unsigned int model = 0, subModel = 0;
388 std::string fnamest = boost::filesystem::unique_path().string();
389 const char *
fname = fnamest.c_str();
392 for(std::vector<std::string>::const_iterator iter = lines.begin();
393 iter != lines.end(); ++iter) {
398 line.begin(), (
int(*)(
int))std::toupper);
400 if (pos != std::string::npos)
406 if (!boost::algorithm::is_space()(line[0])) {
407 std::vector<std::string> tokens;
409 boost::algorithm::is_space(),
410 boost::token_compress_on);
414 if (tokens.size() < 2)
416 if (tokens[0] ==
"BLOCK") {
418 blocks.insert(block);
422 if (tokens[0] ==
"DECAY") {
424 blocks.insert(block);
426 }
else if (block ==
"MODSEL") {
427 std::istringstream ss(line);
428 ss >> model >> subModel;
429 }
else if (block ==
"SMINPUTS") {
430 std::istringstream ss(line);
433 ss >> index >>
value;
442 pydat2_.pmas[0][23 - 1] =
value;
445 pydat2_.pmas[0][6 - 1] =
value;
448 pydat2_.pmas[0][15 - 1] =
value;
455 if (blocks.count(
"SMINPUTS"))
459 (pydat2_.pmas[0][23 - 1] * pydat2_.pmas[0][23 - 1]));
474 blocks.count(
"HIGMIX") ||
475 blocks.count(
"SBOTMIX") ||
476 blocks.count(
"STOPMIX") ||
477 blocks.count(
"STAUMIX") ||
478 blocks.count(
"AMIX") ||
479 blocks.count(
"NMIX") ||
480 blocks.count(
"UMIX") ||
481 blocks.count(
"VMIX"))
484 blocks.count(
"QNUMBERS") ||
485 blocks.count(
"PARTICLE") ||
486 blocks.count(
"MINPAR") ||
487 blocks.count(
"EXTPAR") ||
488 blocks.count(
"SMINPUTS") ||
489 blocks.count(
"SMINPUTS"))
491 if (blocks.count(
"MASS"))
493 if (blocks.count(
"DECAY"))
T getParameter(std::string const &) const
static void call_pyupda(int opt, int iunit)
__attribute__((visibility("hidden"))) void dummy()
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 *)
void setSLHAFromHeader(const std::vector< std::string > &lines)
~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
CLHEP::HepRandomEngine * fRandomEngine
std::vector< std::string > fParamCSA
void openSLHA(const char *)
def remove(d, key, TELL=False)
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)