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"
39 py1ent_(dummy, dummy, dummy2, dummy2, dummy2);
52 void pyslha_(
int*,
int*,
int* );
56 pyslha_(&mupda, &kforig, &iretrn);
69 Pythia6Service* service = FortranInstance::getInstance<Pythia6Service>();
80 : fRandomEngine(
nullptr), fUnitSLHA(24), fUnitPYUPDA(25)
85 : 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)) {
386 std::set<std::string>
blocks;
387 unsigned int model = 0, subModel = 0;
389 std::string fnamest = boost::filesystem::unique_path().string();
390 const char *
fname = fnamest.c_str();
393 for(std::vector<std::string>::const_iterator iter = lines.begin();
394 iter != lines.end(); ++iter) {
399 line.begin(), (int(*)(int))std::toupper);
401 if (pos != std::string::npos)
407 if (!boost::algorithm::is_space()(line[0])) {
408 std::vector<std::string> tokens;
410 boost::algorithm::is_space(),
411 boost::token_compress_on);
415 if (tokens.size() < 2)
417 if (tokens[0] ==
"BLOCK") {
419 blocks.insert(block);
423 if (tokens[0] ==
"DECAY") {
425 blocks.insert(block);
427 }
else if (block ==
"MODSEL") {
428 std::istringstream
ss(line);
429 ss >> model >> subModel;
430 }
else if (block ==
"SMINPUTS") {
431 std::istringstream
ss(line);
434 ss >> index >>
value;
443 pydat2_.pmas[0][23 - 1] =
value;
446 pydat2_.pmas[0][6 - 1] =
value;
449 pydat2_.pmas[0][15 - 1] =
value;
456 if (blocks.count(
"SMINPUTS"))
460 (pydat2_.pmas[0][23 - 1] * pydat2_.pmas[0][23 - 1]));
475 blocks.count(
"HIGMIX") ||
476 blocks.count(
"SBOTMIX") ||
477 blocks.count(
"STOPMIX") ||
478 blocks.count(
"STAUMIX") ||
479 blocks.count(
"AMIX") ||
480 blocks.count(
"NMIX") ||
481 blocks.count(
"UMIX") ||
482 blocks.count(
"VMIX"))
485 blocks.count(
"QNUMBERS") ||
486 blocks.count(
"PARTICLE") ||
487 blocks.count(
"MINPAR") ||
488 blocks.count(
"EXTPAR") ||
489 blocks.count(
"SMINPUTS") ||
490 blocks.count(
"SMINPUTS"))
492 if (blocks.count(
"MASS"))
494 if (blocks.count(
"DECAY"))
T getParameter(std::string const &) const
static void call_pyupda(int opt, int iunit)
tuple start
Check for commandline option errors.
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)
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
float __attribute__((vector_size(8))) float32x2_t
std::vector< std::string > fParamCSA
void openSLHA(const char *)
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
void openPYUPDA(const char *, bool write_file)
std::vector< std::string > fParamSLHA
std::string fullPath() const
void txgive_(const char *, int)