7 #ifndef Pythia8_PowhegProcs_H
8 #define Pythia8_PowhegProcs_H
10 #include "Pythia8/Pythia.h"
11 #include "Pythia8Plugins/PowhegHooks.h"
33 PowhegProcs(Pythia *pythia,
string procIn,
string dirIn =
"powhegrun",
34 string pdfIn =
"",
bool random =
true);
37 bool readString(
string line);
40 bool readFile(
string name);
48 string proc, dir, pdf;
51 map<string, string> settings;
81 PowhegProcs::PowhegProcs(Pythia *pythia,
string procIn,
string dirIn,
82 string pdfIn,
bool random) : proc(procIn), dir(dirIn), pdf(pdfIn) {
85 pythia->settings.addWord(
"POWHEG:dir", dir);
86 pythia->settings.addFlag(
"POWHEG:pythiaRandom", random);
87 pythia->setLHAupPtr(make_shared<LHAupPlugin>
88 (
"libpythia8powheg" + proc +
".so", pythia));
89 pythia->setUserHooksPtr(make_shared<PowhegHooks>());
98 bool PowhegProcs::readString(
string line) {
101 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
return true;
102 int firstChar = line.find_first_not_of(
" \n\t\v\b\r\f\a");
103 int lastChar = line.find_last_not_of(
" \n\t\v\b\r\f\a");
104 line = line.substr(firstChar, lastChar + 1 - firstChar);
107 firstChar = line.find_first_of(
" \t\f\v\n\r");
108 string key = toLower( line.substr(0, firstChar),
false);
112 && key.find_first_of(
"abcdedfghijklmnopqrtsuvwxyz") == 0) {
113 map<string, string>::iterator setting = settings.find(key);
114 if (setting != settings.end()) {
115 cout <<
"Warning from PowhegProcs::readString: replacing "
116 <<
"previous POWHEG setting for " << key <<
"." << endl;
117 setting->second = line;
118 }
else settings[key] = line;
128 bool PowhegProcs::readFile(
string name) {
130 fstream config(name.c_str(), ios::in);
string line;
131 while (getline(config, line,
'\n')) readString(line);
141 bool PowhegProcs::init() {
145 fstream pdfin(pdf.c_str(), ios::in | ios::binary);
146 fstream pdfout((dir +
"/" + pdf.substr(0, pdf.find_last_of(
"/"))).c_str(),
147 ios::out | ios::binary);
148 pdfout << pdfin.rdbuf();
154 fstream config((dir +
"/" +
"powheg.input").c_str(), ios::out);
155 for (map<string, string>::iterator setting = settings.begin();
156 setting != settings.end(); ++setting) config << setting->second <<
"\n";
166 #endif // Pythia8_PowhegProcs_H