10 #include <boost/bind.hpp>
11 #include <boost/algorithm/string/classification.hpp>
12 #include <boost/algorithm/string/split.hpp>
14 #include "CLHEP/Random/RandomEngine.h"
40 py1ent_(dummy, dummy, dummy2, dummy2, dummy2);
53 void pyslha_(
int*,
int*,
int* );
57 pyslha_(&mupda, &kforig, &iretrn);
70 Pythia6Service* service = FortranInstance::getInstance<Pythia6Service>();
81 : fRandomEngine(
nullptr), fUnitSLHA(24), fUnitPYUPDA(25)
90 "Two Pythia6Service instances claiming Pythia6 ownership." <<
115 std::vector<std::string> setNames =
116 pythia_params.
getParameter<std::vector<std::string> >(
"parameterSets");
125 for(std::vector<std::string>::const_iterator iter = setNames.begin();
126 iter != setNames.end(); ++iter)
128 std::vector<std::string>
lines =
129 pythia_params.
getParameter< std::vector<std::string> >(*iter);
131 for(std::vector<std::string>::const_iterator
line = lines.begin();
134 if (
line->substr(0, 7) ==
"MRPY(1)")
136 "Attempted to set random number"
137 " using Pythia command 'MRPY(1)'."
139 " RandomNumberGeneratorService." <<
142 if ( *iter ==
"CSAParameters" )
146 else if ( *iter ==
"SLHAParameters" )
150 else if ( *iter ==
"PYUPDAParameters" )
179 "gen::Pythia6Service is going to initialise Pythia, as no other "
180 "instace has done so yet, and Pythia service routines have been "
181 "requested by a dummy instance." << std::endl;
184 call_pyinit(
"NONE",
"",
"", 0.0);
194 for(std::vector<std::string>::const_iterator iter =
fParamGeneral.begin();
199 <<
"Pythia did not accept \""
200 << *iter <<
"\"." << std::endl;
208 #define SETCSAPARBUFSIZE 514
212 for(std::vector<std::string>::const_iterator iter =
fParamCSA.begin();
220 if (iter->length() <= 0)
223 size_t maxSize = iter->length() > (SETCSAPARBUFSIZE-2) ? (SETCSAPARBUFSIZE-2) : iter->length();
224 strncpy(buf, iter->c_str(),
maxSize);
226 if (buf[maxSize-1] !=
'\n')
231 buf[maxSize + 1] = 0;
237 #undef SETCSAPARBUFSIZE
243 std::ostringstream pyCard1 ;
246 std::ostringstream pyCard2 ;
250 fioopn_( &fUnitSLHA, file, strlen(file) );
260 std::cout<<
"=== WRITING PYUPDA FILE "<<file<<
" ==="<<std::endl;
265 std::cout<<
"=== READING PYUPDA FILE "<<file<<
" ==="<<std::endl;
294 for (std::vector<std::string>::const_iterator iter =
fParamSLHA.begin();
298 if( iter->find(
"SLHAFILE", 0 ) == std::string::npos )
continue;
302 if( temp != std::string::npos ) {
304 end = iter->find_last_of(
"'" ) - 1;
306 start = iter->find_first_not_of(
" ", start );
307 end = iter->find_last_not_of(
" ", end );
309 std::string shortfile = iter->substr( start, end - start + 1 );
336 bool write_file =
false;
337 bool usePostPyinit =
false;
343 for (std::vector<std::string>::const_iterator iter =
fParamPYUPDA.begin();
347 if( iter->find(
"PYUPDAFILE", 0 ) != std::string::npos ) {
351 if( temp != std::string::npos ) {
353 end = iter->find_last_of(
"'" ) - 1;
355 start = iter->find_first_not_of(
" ", start );
356 end = iter->find_last_not_of(
" ", end );
358 shortfile = iter->substr( start, end - start + 1 );
359 }
else if ( iter->find(
"PYUPDAWRITE", 0 ) != std::string::npos ) {
361 }
else if ( iter->find(
"PYUPDApostPYINIT", 0 ) != std::string::npos ) {
362 usePostPyinit =
true;
366 if (!shortfile.empty()) {
376 if (afterPyinit == usePostPyinit || (write_file && afterPyinit)) {
387 std::set<std::string>
blocks;
388 unsigned int model = 0, subModel = 0;
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)
CLHEP::HepRandomEngine & getEngineReference()
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 *)
return(e1-e2)*(e1-e2)+dp *dp
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)