22 #ifndef Pythia8_GeneratorInput_H
23 #define Pythia8_GeneratorInput_H
26 #include "Pythia8/Pythia.h"
27 using namespace Pythia8;
42 bool parse(
const string paramStr);
45 void extractRunParam(
string line);
48 bool haveParam(
const string ¶mIn) {
49 return (
params.find(paramIn) ==
params.end()) ?
false :
true; }
53 double getParam(
const string ¶mIn) {
54 return (haveParam(paramIn)) ?
params[paramIn] : 0.; }
55 int getParamAsInt(
const string ¶mIn) {
56 return (haveParam(paramIn)) ? int(
params[paramIn]) : 0.; }
64 void warnParamOverwrite(
const string ¶mIn,
double val);
67 static string trim(
string s);
76 static const double ZEROTHRESHOLD;
94 bool fileFound() {
return (isUnw != NULL); }
98 bool setEvent(
int,
double);
101 void printParticles();
106 bool addResonances();
109 bool rescaleMomenta();
112 string baseFN, parFN, unwFN;
115 double ebmupA, ebmupB;
120 vector<LHAParticle> myParticles;
123 static const bool LHADEBUG, LHADEBUGRESCALE;
124 static const double ZEROTHRESHOLD, EWARNTHRESHOLD, PTWARNTHRESHOLD,
144 bool initAfterBeams();
166 bool parse(
const string paramStr);
169 void extractRunParam(
string line);
172 bool haveParam(
const string ¶mIn) {
173 return (
params.find(paramIn) ==
params.end()) ?
false :
true; }
177 double getParam(
const string ¶mIn) {
178 return (haveParam(paramIn)) ?
params[paramIn] : 0.; }
179 int getParamAsInt(
const string ¶mIn) {
180 return (haveParam(paramIn)) ? int(
params[paramIn]) : 0.; }
188 void warnParamOverwrite(
const string ¶mIn,
double val);
191 static string trim(
string s);
194 map<string,double>
params;
200 static const double ZEROTHRESHOLD;
216 const double AlpgenPar::ZEROTHRESHOLD = 1e-10;
223 bool AlpgenPar::parse(
const string paramStr) {
232 stringstream paramStream(paramStr);
234 while (getline(paramStream, line)) {
237 if (line.find(
"run parameters") != string::npos) {
241 }
else if (line.find(
"end parameters") != string::npos) {
245 }
else if (block == 0) {
249 extractRunParam(line);
261 void AlpgenPar::extractRunParam(
string line) {
264 size_t idx = line.rfind(
"!");
265 if (idx == string::npos)
return;
266 string paramName = trim(line.substr(idx + 1));
267 string paramVal = trim(line.substr(0, idx));
268 istringstream iss(paramVal);
272 if (paramName ==
"hard process code") {
274 warnParamOverwrite(
"hpc", val);
278 }
else if (paramName.find(
"Crosssection") == 0) {
280 iss >> val >> xerrup;
281 warnParamOverwrite(
"xsecup", val);
282 warnParamOverwrite(
"xerrup", val);
284 params[
"xerrup"] = xerrup;
287 }
else if (paramName.find(
"unwtd events") == 0) {
289 iss >> nevent >> val;
290 warnParamOverwrite(
"nevent", val);
291 warnParamOverwrite(
"lum", val);
292 params[
"nevent"] = nevent;
296 }
else if (paramName.find(
",") != string::npos) {
300 istringstream issName(paramName);
301 while (getline(issName, paramNameNow,
',')) {
303 warnParamOverwrite(paramNameNow, val);
304 params[paramNameNow] = val;
310 iss >> paramIdx >> val;
311 warnParamOverwrite(paramName, val);
320 void AlpgenPar::printParams() {
323 cout << fixed << setprecision(3) << endl
324 <<
" *------- Alpgen parameters -------*" << endl;
325 for (map < string, double >::iterator it =
params.begin();
327 cout <<
" | " << left << setw(13) << it->first
328 <<
" | " << right << setw(13) << it->second
330 cout <<
" *-----------------------------------*" << endl;
337 void AlpgenPar::warnParamOverwrite(
const string ¶mIn,
double val) {
340 if (haveParam(paramIn) &&
341 abs(getParam(paramIn) - val) > ZEROTHRESHOLD) {
342 if (infoPtr) infoPtr->errorMsg(
"Warning in LHAupAlpgen::"
343 "warnParamOverwrite: overwriting existing parameter", paramIn);
351 string AlpgenPar::trim(
string s) {
355 if ((i = s.find_last_not_of(
" \t\r\n")) != string::npos)
356 s = s.substr(0, i + 1);
357 if ((i = s.find_first_not_of(
" \t\r\n")) != string::npos)
374 const bool LHAupAlpgen::LHADEBUG =
false;
377 const bool LHAupAlpgen::LHADEBUGRESCALE =
false;
380 const double LHAupAlpgen::ZEROTHRESHOLD = 1e-10;
383 const double LHAupAlpgen::EWARNTHRESHOLD = 3e-3;
384 const double LHAupAlpgen::PTWARNTHRESHOLD = 1e-3;
387 const double LHAupAlpgen::INCOMINGMIN = 1e-3;
393 LHAupAlpgen::LHAupAlpgen(
const char* baseFNin,
Info* infoPtrIn)
394 : baseFN(baseFNin), alpgenPar(infoPtrIn), isUnw(NULL) {
397 if (infoPtrIn) setPtr(infoPtrIn);
401 istream* isPar = NULL;
405 parFN = baseFN +
"_unw.par.gz";
406 isPar = openFile(parFN.c_str(), ifsPar);
407 if (!ifsPar.is_open()) closeFile(isPar, ifsPar);
410 parFN = baseFN +
"_unw.par";
411 isPar = openFile(parFN.c_str(), ifsPar);
412 if (!ifsPar.is_open()) {
413 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::LHAupAlpgen: "
414 "cannot open parameter file", parFN);
415 closeFile(isPar, ifsPar);
421 string paramStr((istreambuf_iterator<char>(isPar->rdbuf())),
422 istreambuf_iterator<char>());
426 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::LHAupAlpgen: "
427 "cannot read parameter file", parFN);
430 closeFile(isPar, ifsPar);
433 alpgenPar.parse(paramStr);
434 if (infoPtr) setInfoHeader(
"AlpgenPar", paramStr);
438 unwFN = baseFN +
".unw.gz";
439 isUnw = openFile(unwFN.c_str(), ifsUnw);
440 if (!ifsUnw.is_open()) closeFile(isUnw, ifsUnw);
443 unwFN = baseFN +
".unw";
444 isUnw = openFile(unwFN.c_str(), ifsUnw);
445 if (!ifsUnw.is_open()) {
446 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::LHAupAlpgen: "
447 "cannot open event file", unwFN);
448 closeFile(isUnw, ifsUnw);
458 bool LHAupAlpgen::setInit() {
461 if (!alpgenPar.haveParam(
"ih2") || !alpgenPar.haveParam(
"ebeam") ||
462 !alpgenPar.haveParam(
"hpc") || !alpgenPar.haveParam(
"xsecup") ||
463 !alpgenPar.haveParam(
"xerrup")) {
464 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setInit: "
465 "missing input parameters");
470 int ih2 = alpgenPar.getParamAsInt(
"ih2");
472 int idbmupB = (ih2 == 1) ? 2212 : -2212;
475 double ebeam = alpgenPar.getParam(
"ebeam");
480 int pdfgupA = 0, pdfsupA = 0;
481 int pdfgupB = 0, pdfsupB = 0;
488 lprup = alpgenPar.getParamAsInt(
"hpc");
491 if (lprup == 7 || lprup == 8 || lprup == 13) {
492 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setInit: "
493 "process not implemented");
502 if (lprup == 6 || lprup == 7 || lprup == 8 || lprup == 16) {
503 if (!alpgenPar.haveParam(
"ihvy")) {
504 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setInit: "
505 "heavy flavour information not present");
508 ihvy1 = alpgenPar.getParamAsInt(
"ihvy");
512 if (!alpgenPar.haveParam(
"ihvy2")) {
513 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setInit: "
514 "heavy flavour information not present");
517 ihvy2 = alpgenPar.getParamAsInt(
"ihvy2");
522 if (!alpgenPar.haveParam(
"mb")) {
523 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setInit: "
524 "heavy flavour information not present");
527 mb = alpgenPar.getParam(
"mb");
531 setBeamA(idbmupA, ebmupA, pdfgupA, pdfsupA);
532 setBeamB(idbmupB, ebmupB, pdfgupB, pdfsupB);
536 double xsecup = alpgenPar.getParam(
"xsecup");
537 double xerrup = alpgenPar.getParam(
"xerrup");
538 addProcess(lprup, xsecup, xerrup, xmaxup);
539 xSecSumSave = xsecup;
540 xErrSumSave = xerrup;
551 bool LHAupAlpgen::setEvent(
int,
double) {
554 int nEvent, iProc, nParton;
557 if (!getline(*isUnw, line)) {
560 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setEvent: "
561 "could not read events from file");
565 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setEvent: "
566 "end of file reached");
569 istringstream iss1(line);
570 iss1 >> nEvent >> iProc >> nParton >> Swgt >> Sq;
573 double wgtT = Swgt, scaleT = Sq;
574 setProcess(lprup, wgtT, scaleT);
580 int idT, statusT, mother1T, mother2T, col1T, col2T;
581 double pxT, pyT, pzT, eT, mT;
583 double tauT = 0., spinT = 9.;
589 for (
int i = 0; i < nParton; i++) {
591 if (!getline(*isUnw, line)) {
592 if (infoPtr) infoPtr->errorMsg(
"Error in LHAupAlpgen::setEvent: "
593 "could not read events from file");
596 istringstream iss2(line);
602 iss2 >> idT >> col1T >> col2T >> pzT;
604 mother1T = mother2T = 0;
610 pzT = (i == 0) ? INCOMINGMIN : -INCOMINGMIN;
618 iss2 >> idT >> col1T >> col2T >> pxT >> pyT >> pzT >> mT;
622 eT = sqrt(max(0., pxT*pxT + pyT*pyT + pzT*pzT + mT*mT));
627 idT, statusT, mother1T, mother2T, col1T, col2T,
628 pxT, pyT, pzT, eT, mT, tauT, spinT,-1.));
632 if (!addResonances())
return false;
636 if (!rescaleMomenta())
return false;
639 for (
size_t i = 0; i < myParticles.size(); i++)
640 addParticle(myParticles[i]);
643 id1T = myParticles[0].idPart;
644 x1T = myParticles[0].ePart / ebmupA;
645 id2T = myParticles[1].idPart;
646 x2T = myParticles[1].ePart / ebmupA;
647 setIdX(id1T, id2T, x1T, x2T);
648 setPdf(id1T, id2T, x1T, x2T, 0., 0., 0.,
false);
656 void LHAupAlpgen::printParticles() {
658 cout << endl <<
"---- LHAupAlpgen particle listing begin ----" << endl;
659 cout << scientific << setprecision(6);
660 for (
int i = 0; i < int(myParticles.size()); i++) {
662 << setw(5) << myParticles[i].idPart
663 << setw(5) << myParticles[i].statusPart
664 << setw(15) << myParticles[i].pxPart
665 << setw(15) << myParticles[i].pyPart
666 << setw(15) << myParticles[i].pzPart
667 << setw(15) << myParticles[i].ePart
668 << setw(15) << myParticles[i].mPart
669 << setw(5) << myParticles[i].mother1Part - 1
670 << setw(5) << myParticles[i].mother2Part - 1
671 << setw(5) << myParticles[i].col1Part
672 << setw(5) << myParticles[i].col2Part
675 cout <<
"---- LHAupAlpgen particle listing end ----" << endl;
683 bool LHAupAlpgen::addResonances() {
686 int idT, statusT, mother1T, mother2T, col1T, col2T;
687 double pxT, pyT, pzT, eT, mT;
689 double tauT = 0., spinT = 9.;
702 if (lprup <= 4 || lprup == 10 || lprup == 14 || lprup == 15) {
704 int i1 = myParticles.size() - 1, i2 = i1 - 1;
707 if (myParticles[i1].idPart + myParticles[i2].idPart == 0)
710 idT = - (myParticles[i1].idPart % 2) - (myParticles[i2].idPart % 2);
711 idT = (idT > 0) ? 24 : (idT < 0) ? -24 : 23;
714 if (lprup == 2 || lprup == 4) {
716 if (infoPtr) infoPtr->errorMsg(
"Error in "
717 "LHAupAlpgen::addResonances: wrong resonance type in event");
723 if (abs(idT) != 24) {
724 if (infoPtr) infoPtr->errorMsg(
"Error in "
725 "LHAupAlpgen::addResonances: wrong resonance type in event");
735 pxT = myParticles[i1].pxPart + myParticles[i2].pxPart;
736 pyT = myParticles[i1].pyPart + myParticles[i2].pyPart;
737 pzT = myParticles[i1].pzPart + myParticles[i2].pzPart;
738 eT = myParticles[i1].ePart + myParticles[i2].ePart;
739 mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
741 idT, statusT, mother1T, mother2T, col1T, col2T,
742 pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
745 myParticles[i1].mother1Part = myParticles[i2].mother1Part =
747 myParticles[i1].mother2Part = myParticles[i2].mother2Part = 0;
773 }
else if ( ((lprup == 6 || lprup == 8 || lprup == 16) && ihvy1 == 6) ||
774 lprup == 5 || lprup == 13) {
777 int idx = myParticles.size() - 1;
778 for (
int i = myParticles.size() - 1; i > -1; i--) {
781 if (myParticles[i].idPart == 23 ||
782 abs(myParticles[i].idPart) == 24) {
786 if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
789 flav = - (myParticles[idx].idPart % 2)
790 - (myParticles[idx - 1].idPart % 2);
791 flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
792 if (flav != myParticles[i].idPart) {
794 infoPtr->errorMsg(
"Error in LHAupAlpgen::addResonance: "
795 "resonance does not match decay products");
800 myParticles[i].statusPart = 2;
801 myParticles[idx ].mother1Part = i + 1;
802 myParticles[idx--].mother2Part = 0;
803 myParticles[idx ].mother1Part = i + 1;
804 myParticles[idx--].mother2Part = 0;
807 }
else if (abs(myParticles[i].idPart) == 6) {
811 if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
814 flav = - (myParticles[idx].idPart % 2)
815 - (myParticles[idx - 1].idPart % 2);
816 flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
818 bool outOfOrder =
false, wrongFlavour =
false;;
819 if ( abs(flav) != 24 ||
820 (flav == 24 && myParticles[i].idPart != 6) ||
821 (flav == -24 && myParticles[i].idPart != -6) ) {
824 if (lprup == 5 || lprup == 13) {
832 if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
835 flav = - (myParticles[idx].idPart % 2)
836 - (myParticles[idx - 1].idPart % 2);
837 flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
840 if ( abs(flav) != 24 ||
841 (flav == 24 && myParticles[i].idPart != 6) ||
842 (flav == -24 && myParticles[i].idPart != -6) )
844 else outOfOrder =
true;
850 infoPtr->errorMsg(
"Error in LHAupAlpgen::addResonance: "
851 "resonance does not match decay products");
857 myParticles[i].statusPart = 2;
865 pxT = myParticles[idx].pxPart + myParticles[idx - 1].pxPart;
866 pyT = myParticles[idx].pyPart + myParticles[idx - 1].pyPart;
867 pzT = myParticles[idx].pzPart + myParticles[idx - 1].pzPart;
868 eT = myParticles[idx].ePart + myParticles[idx - 1].ePart;
869 mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
871 idT, statusT, mother1T, mother2T, col1T, col2T,
872 pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
875 myParticles[idx ].mother1Part = myParticles.size();
876 myParticles[idx--].mother2Part = 0;
877 myParticles[idx ].mother1Part = myParticles.size();
878 myParticles[idx--].mother2Part = 0;
881 idT = (flav == 24) ? 5 : -5;
884 col1T = myParticles[i].col1Part;
885 col2T = myParticles[i].col2Part;
887 pxT = myParticles[i].pxPart - myParticles.back().pxPart;
888 pyT = myParticles[i].pyPart - myParticles.back().pyPart;
889 pzT = myParticles[i].pzPart - myParticles.back().pzPart;
890 eT = myParticles[i].ePart - myParticles.back().ePart;
891 mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
893 idT, statusT, mother1T, mother2T, col1T, col2T,
894 pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
898 if (outOfOrder) idx += 4;
909 }
else if (lprup == 7 || lprup == 9 || lprup == 11 || lprup == 12) {
914 if (lprup == 13)
for (
int i = 0; i < 2; i++)
915 if (abs(myParticles[i].idPart) == 5) {
916 myParticles[i].mPart = mb;
917 myParticles[i].ePart = sqrt(pow2(myParticles[i].pzPart) + pow2(mb));
921 if (LHADEBUG) printParticles();
940 bool LHAupAlpgen::rescaleMomenta() {
945 for (
int i = 0; i < int(myParticles.size()); i++) {
946 Vec4 pNow =
Vec4(myParticles[i].pxPart, myParticles[i].pyPart,
947 myParticles[i].pzPart, myParticles[i].ePart);
948 if (i < 2) pIn += pNow;
949 else if (myParticles[i].statusPart == 1) {
957 if (abs(pOut.pT() - pIn.pT()) > ZEROTHRESHOLD) {
959 double pxDiff = (pOut.px() - pIn.px()) / nOut,
960 pyDiff = (pOut.py() - pIn.py()) / nOut;
963 if (pxDiff > PTWARNTHRESHOLD || pyDiff > PTWARNTHRESHOLD) {
964 if (infoPtr) infoPtr->errorMsg(
"Warning in LHAupAlpgen::setEvent: "
965 "large pT imbalance in incoming event");
968 if (LHADEBUGRESCALE) {
970 cout <<
"pxDiff = " << pxDiff <<
", pyDiff = " << pyDiff << endl;
976 for (
int i = 2; i < int(myParticles.size()); i++) {
977 if (myParticles[i].statusPart != 1)
continue;
978 myParticles[i].pxPart -= pxDiff;
979 myParticles[i].pyPart -= pyDiff;
980 myParticles[i].ePart = sqrt(max(0., pow2(myParticles[i].pxPart) +
981 pow2(myParticles[i].pyPart) + pow2(myParticles[i].pzPart) +
982 pow2(myParticles[i].mPart)));
983 pOut +=
Vec4(myParticles[i].pxPart, myParticles[i].pyPart,
984 myParticles[i].pzPart, myParticles[i].ePart);
989 double de = (pOut.e() - pIn.e());
990 double dp = (pOut.pz() - pIn.pz());
991 double a = 1 + (de + dp) / 2. / myParticles[0].ePart;
992 double b = 1 + (de - dp) / 2. / myParticles[1].ePart;
999 if (abs(a - 1.) * myParticles[0].ePart > EWARNTHRESHOLD ||
1000 abs(b - 1.) * myParticles[1].ePart > EWARNTHRESHOLD) {
1001 if (infoPtr) infoPtr->errorMsg(
"Warning in LHAupAlpgen::setEvent: "
1002 "large rescaling factor");
1005 if (LHADEBUGRESCALE) {
1007 cout <<
"de = " << de <<
", dp = " << dp
1008 <<
", a = " << a <<
", b = " << b << endl
1009 <<
"Absolute energy change for incoming 0 = "
1010 << abs(a - 1.) * myParticles[0].ePart << endl
1011 <<
"Absolute energy change for incoming 1 = "
1012 << abs(b - 1.) * myParticles[1].ePart << endl;
1015 myParticles[0].ePart *= a;
1016 myParticles[0].pzPart *= a;
1017 myParticles[1].ePart *= b;
1018 myParticles[1].pzPart *= b;
1021 for (
int i = 0; i < int(myParticles.size()); i++) {
1022 if (myParticles[i].statusPart != 2)
continue;
1026 for (
int j = 0; j < int(myParticles.size()); j++) {
1027 if (myParticles[j].mother1Part - 1 != i)
continue;
1028 resVec +=
Vec4(myParticles[j].pxPart, myParticles[j].pyPart,
1029 myParticles[j].pzPart, myParticles[j].ePart);
1032 myParticles[i].pxPart = resVec.px();
1033 myParticles[i].pyPart = resVec.py();
1034 myParticles[i].pzPart = resVec.pz();
1035 myParticles[i].ePart = resVec.e();
1052 AlpgenHooks::AlpgenHooks(
Pythia &pythia) : LHAagPtr(NULL) {
1055 string agFile = pythia.settings.word(
"Alpgen:file");
1056 if (agFile !=
"void") {
1057 LHAagPtr =
new LHAupAlpgen(agFile.c_str(), &pythia.info);
1058 pythia.settings.mode(
"Beams:frameType", 5);
1059 pythia.setLHAupPtr(LHAagPtr);
1071 bool AlpgenHooks::initAfterBeams() {
1074 bool setLightMasses = settingsPtr->flag(
"Alpgen:setLightMasses");
1075 bool setHeavyMasses = settingsPtr->flag(
"Alpgen:setHeavyMasses");
1076 bool setNjet = settingsPtr->flag(
"Alpgen:setNjet");
1077 bool setMLM = settingsPtr->flag(
"Alpgen:setMLM");
1081 string parStr = infoPtr->header(
"AlpgenPar");
1082 if (!parStr.empty()) {
1088 if (setLightMasses) {
1089 if (par.haveParam(
"mc")) particleDataPtr->m0(4, par.getParam(
"mc"));
1090 if (par.haveParam(
"mb")) particleDataPtr->m0(5, par.getParam(
"mb"));
1092 if (setHeavyMasses) {
1093 if (par.haveParam(
"mt")) particleDataPtr->m0(6, par.getParam(
"mt"));
1094 if (par.haveParam(
"mz")) particleDataPtr->m0(23, par.getParam(
"mz"));
1095 if (par.haveParam(
"mw")) particleDataPtr->m0(24, par.getParam(
"mw"));
1096 if (par.haveParam(
"mh")) particleDataPtr->m0(25, par.getParam(
"mh"));
1101 if (par.haveParam(
"njets"))
1102 settingsPtr->mode(
"JetMatching:nJet", par.getParamAsInt(
"njets"));
1104 infoPtr->errorMsg(
"Warning in AlpgenHooks:init: "
1105 "no ALPGEN nJet parameter found");
1110 if (par.haveParam(
"ptjmin") && par.haveParam(
"drjmin") &&
1111 par.haveParam(
"etajmax")) {
1112 double ptjmin = par.getParam(
"ptjmin");
1113 ptjmin = max(ptjmin + 5., 1.2 * ptjmin);
1114 settingsPtr->parm(
"JetMatching:eTjetMin", ptjmin);
1115 settingsPtr->parm(
"JetMatching:coneRadius", par.getParam(
"drjmin"));
1116 settingsPtr->parm(
"JetMatching:etaJetMax", par.getParam(
"etajmax"));
1120 infoPtr->errorMsg(
"Warning in AlpgenHooks:init: "
1121 "no ALPGEN merging parameters found");
1141 const double MadgraphPar::ZEROTHRESHOLD = 1e-10;
1147 bool MadgraphPar::parse(
const string paramStr) {
1150 stringstream paramStream(paramStr);
1152 while ( getline(paramStream, line) ) extractRunParam(line);
1161 void MadgraphPar::extractRunParam(
string line) {
1164 size_t idz = line.find(
"#");
1165 if ( !(idz == string::npos) )
return;
1166 size_t idx = line.find(
"=");
1167 size_t idy = line.find(
"!");
1168 if (idy == string::npos) idy = line.size();
1169 if (idx == string::npos)
return;
1170 string paramName = trim( line.substr( idx + 1, idy - idx - 1) );
1171 string paramVal = trim( line.substr( 0, idx) );
1172 replace( paramVal.begin(), paramVal.end(),
'd',
'e');
1175 istringstream iss(paramVal);
1177 if (paramName.find(
",") != string::npos) {
1178 string paramNameNow;
1179 istringstream issName( paramName);
1180 while ( getline(issName, paramNameNow,
',') ) {
1182 warnParamOverwrite( paramNameNow, val);
1183 params[paramNameNow] = val;
1189 warnParamOverwrite( paramName, val);
1198 void MadgraphPar::printParams() {
1202 <<
" *-------- Madgraph parameters --------*" << endl;
1203 for (map<string,double>::iterator it =
params.begin();
1204 it !=
params.end(); ++it)
1205 cout <<
" | " << left << setw(15) << it->first
1206 <<
" | " << right << setw(15) << it->second
1208 cout <<
" *---------------------------------------*" << endl;
1215 void MadgraphPar::warnParamOverwrite(
const string ¶mIn,
double val) {
1218 if (haveParam(paramIn) &&
1219 abs(getParam(paramIn) - val) > ZEROTHRESHOLD) {
1220 if (infoPtr) infoPtr->errorMsg(
"Warning in LHAupAlpgen::"
1221 "warnParamOverwrite: overwriting existing parameter", paramIn);
1229 string MadgraphPar::trim(
string s) {
1233 if ( (i = s.find_last_not_of(
" \t\r\n")) != string::npos)
1234 s = s.substr(0, i + 1);
1235 if ( (i = s.find_first_not_of(
" \t\r\n")) != string::npos)
1242 #endif // Pythia8_GeneratorInput_H