22 #ifndef Pythia8_GeneratorInput_H
23 #define Pythia8_GeneratorInput_H
26 #include "Pythia8/Pythia.h"
43 bool parse(
const string paramStr);
46 void extractRunParam(
string line);
49 bool haveParam(
const string ¶mIn) {
50 return (
params.find(paramIn) ==
params.end()) ?
false :
true; }
54 double getParam(
const string ¶mIn) {
55 return (haveParam(paramIn)) ?
params[paramIn] : 0.; }
56 int getParamAsInt(
const string ¶mIn) {
57 return (haveParam(paramIn)) ? int(
params[paramIn]) : 0.; }
65 void warnParamOverwrite(
const string ¶mIn,
double val);
68 static string trim(
string s);
74 static const double ZEROTHRESHOLD;
92 bool fileFound() {
return (isUnw != NULL); }
99 void printParticles();
104 bool addResonances();
107 bool rescaleMomenta();
110 string baseFN, parFN, unwFN;
113 double ebmupA, ebmupB;
118 vector<LHAParticle> myParticles;
121 static const bool LHADEBUG, LHADEBUGRESCALE;
122 static const double ZEROTHRESHOLD, EWARNTHRESHOLD, PTWARNTHRESHOLD,
142 bool initAfterBeams();
147 shared_ptr<LHAupAlpgen> LHAagPtr;
164 bool parse(
const string paramStr);
167 void extractRunParam(
string line);
170 bool haveParam(
const string ¶mIn) {
171 return (
params.find(paramIn) ==
params.end()) ?
false :
true; }
175 double getParam(
const string ¶mIn) {
176 return (haveParam(paramIn)) ?
params[paramIn] : 0.; }
177 int getParamAsInt(
const string ¶mIn) {
178 return (haveParam(paramIn)) ? int(
params[paramIn]) : 0.; }
186 void warnParamOverwrite(
const string ¶mIn,
double val);
189 static string trim(
string s);
192 map<string,double>
params;
195 static const double ZEROTHRESHOLD;
211 const double AlpgenPar::ZEROTHRESHOLD = 1e-10;
218 inline bool AlpgenPar::parse(
const string paramStr) {
227 stringstream paramStream(paramStr);
229 while (getline(paramStream, line)) {
232 if (line.find(
"run parameters") != string::npos) {
236 }
else if (line.find(
"end parameters") != string::npos) {
240 }
else if (block == 0) {
244 extractRunParam(line);
256 inline void AlpgenPar::extractRunParam(
string line) {
259 size_t idx = line.rfind(
"!");
260 if (idx == string::npos)
return;
261 string paramName = trim(line.substr(idx + 1));
262 string paramVal = trim(line.substr(0, idx));
263 istringstream iss(paramVal);
267 if (paramName ==
"hard process code") {
269 warnParamOverwrite(
"hpc", val);
273 }
else if (paramName.find(
"Crosssection") == 0) {
275 iss >> val >> xerrup;
276 warnParamOverwrite(
"xsecup", val);
277 warnParamOverwrite(
"xerrup", val);
279 params[
"xerrup"] = xerrup;
282 }
else if (paramName.find(
"unwtd events") == 0) {
284 iss >> nevent >> val;
285 warnParamOverwrite(
"nevent", val);
286 warnParamOverwrite(
"lum", val);
287 params[
"nevent"] = nevent;
291 }
else if (paramName.find(
",") != string::npos) {
295 istringstream issName(paramName);
296 while (getline(issName, paramNameNow,
',')) {
298 warnParamOverwrite(paramNameNow, val);
299 params[paramNameNow] = val;
305 iss >> paramIdx >> val;
306 warnParamOverwrite(paramName, val);
315 inline void AlpgenPar::printParams() {
318 cout << fixed << setprecision(3) << endl
319 <<
" *------- Alpgen parameters -------*" << endl;
320 for (map < string, double >::iterator it =
params.begin();
322 cout <<
" | " << left << setw(13) << it->first
323 <<
" | " << right << setw(13) << it->second
325 cout <<
" *-----------------------------------*" << endl;
332 inline void AlpgenPar::warnParamOverwrite(
const string ¶mIn,
double val) {
335 if (haveParam(paramIn) &&
336 abs(getParam(paramIn) - val) > ZEROTHRESHOLD) {
337 cout <<
"Warning in LHAupAlpgen::warnParamOverwrite:"
338 <<
" overwriting existing parameter" << paramIn << endl;
346 inline string AlpgenPar::trim(
string s) {
350 if ((i = s.find_last_not_of(
" \t\r\n")) != string::npos)
351 s = s.substr(0, i + 1);
352 if ((i = s.find_first_not_of(
" \t\r\n")) != string::npos)
369 const bool LHAupAlpgen::LHADEBUG =
false;
372 const bool LHAupAlpgen::LHADEBUGRESCALE =
false;
375 const double LHAupAlpgen::ZEROTHRESHOLD = 1e-10;
378 const double LHAupAlpgen::EWARNTHRESHOLD = 3e-3;
379 const double LHAupAlpgen::PTWARNTHRESHOLD = 1e-3;
382 const double LHAupAlpgen::INCOMINGMIN = 1e-3;
388 LHAupAlpgen::LHAupAlpgen(
const char* baseFNin)
389 : baseFN(baseFNin), alpgenPar(), isUnw(NULL) {
393 istream* isPar = NULL;
397 parFN = baseFN +
"_unw.par.gz";
398 isPar = openFile(parFN.c_str(), ifsPar);
399 if (!ifsPar.is_open()) closeFile(isPar, ifsPar);
402 parFN = baseFN +
"_unw.par";
403 isPar = openFile(parFN.c_str(), ifsPar);
404 if (!ifsPar.is_open()) {
405 cout <<
"Error in LHAupAlpgen::LHAupAlpgen: "
406 <<
"cannot open parameter file " << parFN << endl;
407 closeFile(isPar, ifsPar);
413 string paramStr((std::istreambuf_iterator<char>(isPar->rdbuf())),
414 std::istreambuf_iterator<char>());
418 cout <<
"Error in LHAupAlpgen::LHAupAlpgen: "
419 <<
"cannot read parameter file " << parFN << endl;
422 closeFile(isPar, ifsPar);
425 alpgenPar.parse(paramStr);
426 setInfoHeader(
"AlpgenPar", paramStr);
430 unwFN = baseFN +
".unw.gz";
431 isUnw = openFile(unwFN.c_str(), ifsUnw);
432 if (!ifsUnw.is_open()) closeFile(isUnw, ifsUnw);
435 unwFN = baseFN +
".unw";
436 isUnw = openFile(unwFN.c_str(), ifsUnw);
437 if (!ifsUnw.is_open()) {
438 cout <<
"Error in LHAupAlpgen::LHAupAlpgen: "
439 <<
"cannot open event file " << unwFN << endl;
440 closeFile(isUnw, ifsUnw);
450 inline bool LHAupAlpgen::setInit() {
453 if (!alpgenPar.haveParam(
"ih2") || !alpgenPar.haveParam(
"ebeam") ||
454 !alpgenPar.haveParam(
"hpc") || !alpgenPar.haveParam(
"xsecup") ||
455 !alpgenPar.haveParam(
"xerrup")) {
456 cout <<
"Error in LHAupAlpgen::setInit: "
457 <<
"missing input parameters" << endl;
462 int ih2 = alpgenPar.getParamAsInt(
"ih2");
464 int idbmupB = (ih2 == 1) ? 2212 : -2212;
467 double ebeam = alpgenPar.getParam(
"ebeam");
472 int pdfgupA = 0, pdfsupA = 0;
473 int pdfgupB = 0, pdfsupB = 0;
480 lprup = alpgenPar.getParamAsInt(
"hpc");
483 if (lprup == 7 || lprup == 8 || lprup == 13) {
484 cout <<
"Error in LHAupAlpgen::setInit: "
485 <<
"process not implemented" << endl;
494 if (lprup == 6 || lprup == 7 || lprup == 8 || lprup == 16) {
495 if (!alpgenPar.haveParam(
"ihvy")) {
496 cout <<
"Error in LHAupAlpgen::setInit: "
497 <<
"heavy flavour information not present" << endl;
500 ihvy1 = alpgenPar.getParamAsInt(
"ihvy");
504 if (!alpgenPar.haveParam(
"ihvy2")) {
505 cout <<
"Error in LHAupAlpgen::setInit: "
506 <<
"heavy flavour information not present" << endl;
509 ihvy2 = alpgenPar.getParamAsInt(
"ihvy2");
514 if (!alpgenPar.haveParam(
"mb")) {
515 cout <<
"Error in LHAupAlpgen::setInit: "
516 <<
"heavy flavour information not present" << endl;
519 mb = alpgenPar.getParam(
"mb");
523 setBeamA(idbmupA, ebmupA, pdfgupA, pdfsupA);
524 setBeamB(idbmupB, ebmupB, pdfgupB, pdfsupB);
528 double xsecup = alpgenPar.getParam(
"xsecup");
529 double xerrup = alpgenPar.getParam(
"xerrup");
530 addProcess(lprup, xsecup, xerrup, xmaxup);
531 xSecSumSave = xsecup;
532 xErrSumSave = xerrup;
543 inline bool LHAupAlpgen::setEvent(
int) {
546 int nEvent, iProc, nParton;
549 if (!getline(*isUnw, line)) {
552 cout <<
"Error in LHAupAlpgen::setEvent: "
553 <<
"could not read events from file" << endl;
557 cout <<
"Error in LHAupAlpgen::setEvent: "
558 <<
"end of file reached" << endl;
561 istringstream iss1(line);
562 iss1 >> nEvent >> iProc >> nParton >> Swgt >> Sq;
565 double wgtT = Swgt, scaleT = Sq;
566 setProcess(lprup, wgtT, scaleT);
572 int idT, statusT, mother1T, mother2T, col1T, col2T;
573 double pxT, pyT, pzT, eT, mT;
575 double tauT = 0., spinT = 9.;
581 for (
int i = 0; i < nParton; i++) {
583 if (!getline(*isUnw, line)) {
584 cout <<
"Error in LHAupAlpgen::setEvent: "
585 <<
"could not read events from file" << endl;
588 istringstream iss2(line);
594 iss2 >> idT >> col1T >> col2T >> pzT;
596 mother1T = mother2T = 0;
602 pzT = (i == 0) ? INCOMINGMIN : -INCOMINGMIN;
610 iss2 >> idT >> col1T >> col2T >> pxT >> pyT >> pzT >> mT;
614 eT = sqrt(max(0., pxT*pxT + pyT*pyT + pzT*pzT + mT*mT));
618 myParticles.push_back(LHAParticle(
619 idT, statusT, mother1T, mother2T, col1T, col2T,
620 pxT, pyT, pzT, eT, mT, tauT, spinT,-1.));
624 if (!addResonances())
return false;
628 if (!rescaleMomenta())
return false;
631 for (
size_t i = 0; i < myParticles.size(); i++)
632 addParticle(myParticles[i]);
635 id1T = myParticles[0].idPart;
636 x1T = myParticles[0].ePart / ebmupA;
637 id2T = myParticles[1].idPart;
638 x2T = myParticles[1].ePart / ebmupA;
639 setIdX(id1T, id2T, x1T, x2T);
640 setPdf(id1T, id2T, x1T, x2T, 0., 0., 0.,
false);
648 inline void LHAupAlpgen::printParticles() {
650 cout << endl <<
"---- LHAupAlpgen particle listing begin ----" << endl;
651 cout << scientific << setprecision(6);
652 for (
int i = 0; i < int(myParticles.size()); i++) {
654 << setw(5) << myParticles[i].idPart
655 << setw(5) << myParticles[i].statusPart
656 << setw(15) << myParticles[i].pxPart
657 << setw(15) << myParticles[i].pyPart
658 << setw(15) << myParticles[i].pzPart
659 << setw(15) << myParticles[i].ePart
660 << setw(15) << myParticles[i].mPart
661 << setw(5) << myParticles[i].mother1Part - 1
662 << setw(5) << myParticles[i].mother2Part - 1
663 << setw(5) << myParticles[i].col1Part
664 << setw(5) << myParticles[i].col2Part
667 cout <<
"---- LHAupAlpgen particle listing end ----" << endl;
675 inline bool LHAupAlpgen::addResonances() {
678 int idT, statusT, mother1T, mother2T, col1T, col2T;
679 double pxT, pyT, pzT, eT, mT;
681 double tauT = 0., spinT = 9.;
694 if (lprup <= 4 || lprup == 10 || lprup == 14 || lprup == 15) {
696 int i1 = myParticles.size() - 1, i2 = i1 - 1;
699 if (myParticles[i1].idPart + myParticles[i2].idPart == 0)
702 idT = - (myParticles[i1].idPart % 2) - (myParticles[i2].idPart % 2);
703 idT = (idT > 0) ? 24 : (idT < 0) ? -24 : 23;
706 if (lprup == 2 || lprup == 4) {
709 <<
"LHAupAlpgen::addResonances: wrong resonance type in event"
716 if (abs(idT) != 24) {
718 <<
"LHAupAlpgen::addResonances: wrong resonance type in event"
729 pxT = myParticles[i1].pxPart + myParticles[i2].pxPart;
730 pyT = myParticles[i1].pyPart + myParticles[i2].pyPart;
731 pzT = myParticles[i1].pzPart + myParticles[i2].pzPart;
732 eT = myParticles[i1].ePart + myParticles[i2].ePart;
733 mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
734 myParticles.push_back(LHAParticle(
735 idT, statusT, mother1T, mother2T, col1T, col2T,
736 pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
739 myParticles[i1].mother1Part = myParticles[i2].mother1Part =
741 myParticles[i1].mother2Part = myParticles[i2].mother2Part = 0;
767 }
else if ( ((lprup == 6 || lprup == 8 || lprup == 16) && ihvy1 == 6) ||
768 lprup == 5 || lprup == 13) {
771 int idx = myParticles.size() - 1;
772 for (
int i = myParticles.size() - 1; i > -1; i--) {
775 if (myParticles[i].idPart == 23 ||
776 abs(myParticles[i].idPart) == 24) {
780 if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
783 flav = - (myParticles[idx].idPart % 2)
784 - (myParticles[idx - 1].idPart % 2);
785 flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
786 if (flav != myParticles[i].idPart) {
788 infoPtr->errorMsg(
"Error in LHAupAlpgen::addResonance: "
789 "resonance does not match decay products");
794 myParticles[i].statusPart = 2;
795 myParticles[idx ].mother1Part = i + 1;
796 myParticles[idx--].mother2Part = 0;
797 myParticles[idx ].mother1Part = i + 1;
798 myParticles[idx--].mother2Part = 0;
801 }
else if (abs(myParticles[i].idPart) == 6) {
805 if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
808 flav = - (myParticles[idx].idPart % 2)
809 - (myParticles[idx - 1].idPart % 2);
810 flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
812 bool outOfOrder =
false, wrongFlavour =
false;;
813 if ( abs(flav) != 24 ||
814 (flav == 24 && myParticles[i].idPart != 6) ||
815 (flav == -24 && myParticles[i].idPart != -6) ) {
818 if (lprup == 5 || lprup == 13) {
826 if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
829 flav = - (myParticles[idx].idPart % 2)
830 - (myParticles[idx - 1].idPart % 2);
831 flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
834 if ( abs(flav) != 24 ||
835 (flav == 24 && myParticles[i].idPart != 6) ||
836 (flav == -24 && myParticles[i].idPart != -6) )
838 else outOfOrder =
true;
844 infoPtr->errorMsg(
"Error in LHAupAlpgen::addResonance: "
845 "resonance does not match decay products");
851 myParticles[i].statusPart = 2;
859 pxT = myParticles[idx].pxPart + myParticles[idx - 1].pxPart;
860 pyT = myParticles[idx].pyPart + myParticles[idx - 1].pyPart;
861 pzT = myParticles[idx].pzPart + myParticles[idx - 1].pzPart;
862 eT = myParticles[idx].ePart + myParticles[idx - 1].ePart;
863 mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
864 myParticles.push_back(LHAParticle(
865 idT, statusT, mother1T, mother2T, col1T, col2T,
866 pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
869 myParticles[idx ].mother1Part = myParticles.size();
870 myParticles[idx--].mother2Part = 0;
871 myParticles[idx ].mother1Part = myParticles.size();
872 myParticles[idx--].mother2Part = 0;
875 idT = (flav == 24) ? 5 : -5;
878 col1T = myParticles[i].col1Part;
879 col2T = myParticles[i].col2Part;
881 pxT = myParticles[i].pxPart - myParticles.back().pxPart;
882 pyT = myParticles[i].pyPart - myParticles.back().pyPart;
883 pzT = myParticles[i].pzPart - myParticles.back().pzPart;
884 eT = myParticles[i].ePart - myParticles.back().ePart;
885 mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
886 myParticles.push_back(LHAParticle(
887 idT, statusT, mother1T, mother2T, col1T, col2T,
888 pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
892 if (outOfOrder) idx += 4;
903 }
else if (lprup == 7 || lprup == 9 || lprup == 11 || lprup == 12) {
908 if (lprup == 13)
for (
int i = 0; i < 2; i++)
909 if (abs(myParticles[i].idPart) == 5) {
910 myParticles[i].mPart = mb;
911 myParticles[i].ePart = sqrt(pow2(myParticles[i].pzPart) + pow2(mb));
915 if (LHADEBUG) printParticles();
934 inline bool LHAupAlpgen::rescaleMomenta() {
939 for (
int i = 0; i < int(myParticles.size()); i++) {
940 Vec4 pNow = Vec4(myParticles[i].pxPart, myParticles[i].pyPart,
941 myParticles[i].pzPart, myParticles[i].ePart);
942 if (i < 2) pIn += pNow;
943 else if (myParticles[i].statusPart == 1) {
951 if (abs(pOut.pT() - pIn.pT()) > ZEROTHRESHOLD) {
953 double pxDiff = (pOut.px() - pIn.px()) / nOut,
954 pyDiff = (pOut.py() - pIn.py()) / nOut;
957 if (pxDiff > PTWARNTHRESHOLD || pyDiff > PTWARNTHRESHOLD) {
958 cout <<
"Warning in LHAupAlpgen::setEvent: "
959 <<
"large pT imbalance in incoming event" << endl;
962 if (LHADEBUGRESCALE) {
964 cout <<
"pxDiff = " << pxDiff <<
", pyDiff = " << pyDiff << endl;
970 for (
int i = 2; i < int(myParticles.size()); i++) {
971 if (myParticles[i].statusPart != 1)
continue;
972 myParticles[i].pxPart -= pxDiff;
973 myParticles[i].pyPart -= pyDiff;
974 myParticles[i].ePart = sqrt(max(0., pow2(myParticles[i].pxPart) +
975 pow2(myParticles[i].pyPart) + pow2(myParticles[i].pzPart) +
976 pow2(myParticles[i].mPart)));
977 pOut += Vec4(myParticles[i].pxPart, myParticles[i].pyPart,
978 myParticles[i].pzPart, myParticles[i].ePart);
983 double de = (pOut.e() - pIn.e());
984 double dp = (pOut.pz() - pIn.pz());
985 double a = 1 + (de + dp) / 2. / myParticles[0].ePart;
986 double b = 1 + (de - dp) / 2. / myParticles[1].ePart;
993 if (abs(a - 1.) * myParticles[0].ePart > EWARNTHRESHOLD ||
994 abs(b - 1.) * myParticles[1].ePart > EWARNTHRESHOLD) {
995 cout <<
"Warning in LHAupAlpgen::setEvent: "
996 <<
"large rescaling factor" << endl;
999 if (LHADEBUGRESCALE) {
1001 cout <<
"de = " << de <<
", dp = " << dp
1002 <<
", a = " << a <<
", b = " << b << endl
1003 <<
"Absolute energy change for incoming 0 = "
1004 << abs(a - 1.) * myParticles[0].ePart << endl
1005 <<
"Absolute energy change for incoming 1 = "
1006 << abs(b - 1.) * myParticles[1].ePart << endl;
1009 myParticles[0].ePart *= a;
1010 myParticles[0].pzPart *= a;
1011 myParticles[1].ePart *= b;
1012 myParticles[1].pzPart *= b;
1015 for (
int i = 0; i < int(myParticles.size()); i++) {
1016 if (myParticles[i].statusPart != 2)
continue;
1020 for (
int j = 0; j < int(myParticles.size()); j++) {
1021 if (myParticles[j].mother1Part - 1 != i)
continue;
1022 resVec += Vec4(myParticles[j].pxPart, myParticles[j].pyPart,
1023 myParticles[j].pzPart, myParticles[j].ePart);
1026 myParticles[i].pxPart = resVec.px();
1027 myParticles[i].pyPart = resVec.py();
1028 myParticles[i].pzPart = resVec.pz();
1029 myParticles[i].ePart = resVec.e();
1046 AlpgenHooks::AlpgenHooks(Pythia &pythia) {
1049 string agFile = pythia.settings.word(
"Alpgen:file");
1050 if (agFile !=
"void") {
1051 LHAagPtr = make_shared<LHAupAlpgen>(agFile.c_str());
1052 pythia.settings.mode(
"Beams:frameType", 5);
1053 pythia.setLHAupPtr(LHAagPtr);
1065 inline bool AlpgenHooks::initAfterBeams() {
1068 bool setLightMasses = settingsPtr->flag(
"Alpgen:setLightMasses");
1069 bool setHeavyMasses = settingsPtr->flag(
"Alpgen:setHeavyMasses");
1070 bool setNjet = settingsPtr->flag(
"Alpgen:setNjet");
1071 bool setMLM = settingsPtr->flag(
"Alpgen:setMLM");
1075 string parStr = infoPtr->header(
"AlpgenPar");
1076 if (!parStr.empty()) {
1082 if (setLightMasses) {
1083 if (par.haveParam(
"mc")) particleDataPtr->m0(4, par.getParam(
"mc"));
1084 if (par.haveParam(
"mb")) particleDataPtr->m0(5, par.getParam(
"mb"));
1086 if (setHeavyMasses) {
1087 if (par.haveParam(
"mt")) particleDataPtr->m0(6, par.getParam(
"mt"));
1088 if (par.haveParam(
"mz")) particleDataPtr->m0(23, par.getParam(
"mz"));
1089 if (par.haveParam(
"mw")) particleDataPtr->m0(24, par.getParam(
"mw"));
1090 if (par.haveParam(
"mh")) particleDataPtr->m0(25, par.getParam(
"mh"));
1095 if (par.haveParam(
"njets"))
1096 settingsPtr->mode(
"JetMatching:nJet", par.getParamAsInt(
"njets"));
1098 cout <<
"Warning in AlpgenHooks:init: "
1099 <<
"no ALPGEN nJet parameter found" << endl;
1104 if (par.haveParam(
"ptjmin") && par.haveParam(
"drjmin") &&
1105 par.haveParam(
"etajmax")) {
1106 double ptjmin = par.getParam(
"ptjmin");
1107 ptjmin = max(ptjmin + 5., 1.2 * ptjmin);
1108 settingsPtr->parm(
"JetMatching:eTjetMin", ptjmin);
1109 settingsPtr->parm(
"JetMatching:coneRadius", par.getParam(
"drjmin"));
1110 settingsPtr->parm(
"JetMatching:etaJetMax", par.getParam(
"etajmax"));
1114 cout <<
"Warning in AlpgenHooks:init: "
1115 <<
"no ALPGEN merging parameters found" << endl;
1135 const double MadgraphPar::ZEROTHRESHOLD = 1e-10;
1141 inline bool MadgraphPar::parse(
const string paramStr) {
1144 stringstream paramStream(paramStr);
1146 while ( getline(paramStream, line) ) extractRunParam(line);
1155 inline void MadgraphPar::extractRunParam(
string line) {
1158 size_t idz = line.find(
"#");
1159 if ( !(idz == string::npos) )
return;
1160 size_t idx = line.find(
"=");
1161 size_t idy = line.find(
"!");
1162 if (idy == string::npos) idy = line.size();
1163 if (idx == string::npos)
return;
1164 string paramName = trim( line.substr( idx + 1, idy - idx - 1) );
1165 string paramVal = trim( line.substr( 0, idx) );
1166 replace( paramVal.begin(), paramVal.end(),
'd',
'e');
1169 istringstream iss(paramVal);
1171 if (paramName.find(
",") != string::npos) {
1172 string paramNameNow;
1173 istringstream issName( paramName);
1174 while ( getline(issName, paramNameNow,
',') ) {
1176 warnParamOverwrite( paramNameNow, val);
1177 params[paramNameNow] = val;
1183 warnParamOverwrite( paramName, val);
1192 inline void MadgraphPar::printParams() {
1196 <<
" *-------- Madgraph parameters --------*" << endl;
1197 for (map<string,double>::iterator it =
params.begin();
1198 it !=
params.end(); ++it)
1199 cout <<
" | " << left << setw(15) << it->first
1200 <<
" | " << right << setw(15) << it->second
1202 cout <<
" *---------------------------------------*" << endl;
1209 inline void MadgraphPar::warnParamOverwrite(
const string ¶mIn,
1213 if (haveParam(paramIn) &&
1214 abs(getParam(paramIn) - val) > ZEROTHRESHOLD) {
1215 cout <<
"Warning in LHAupAlpgen::"
1216 <<
"warnParamOverwrite: overwriting existing parameter"
1225 inline string MadgraphPar::trim(
string s) {
1229 if ( (i = s.find_last_not_of(
" \t\r\n")) != string::npos)
1230 s = s.substr(0, i + 1);
1231 if ( (i = s.find_first_not_of(
" \t\r\n")) != string::npos)
1240 #endif // Pythia8_GeneratorInput_H