File indexing completed on 2025-01-18 10:06:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef Pythia8_Settings_H
0018 #define Pythia8_Settings_H
0019
0020 #include "Pythia8/Logger.h"
0021 #include "Pythia8/PythiaStdlib.h"
0022
0023 namespace Pythia8 {
0024
0025
0026
0027
0028
0029 class Flag {
0030
0031 public:
0032
0033
0034 Flag(string nameIn = " ", bool defaultIn = false) : name(nameIn),
0035 valNow(defaultIn) , valDefault(defaultIn) { }
0036
0037
0038 string name;
0039 bool valNow, valDefault;
0040
0041 };
0042
0043
0044
0045
0046
0047 class Mode {
0048
0049 public:
0050
0051
0052 Mode(string nameIn = " ", int defaultIn = 0, bool hasMinIn = false,
0053 bool hasMaxIn = false, int minIn = 0, int maxIn = 0,
0054 bool optOnlyIn = false) : name(nameIn), valNow(defaultIn),
0055 valDefault(defaultIn), hasMin(hasMinIn), hasMax(hasMaxIn),
0056 valMin(minIn), valMax(maxIn), optOnly(optOnlyIn) { }
0057
0058
0059 string name;
0060 int valNow, valDefault;
0061 bool hasMin, hasMax;
0062 int valMin, valMax;
0063 bool optOnly;
0064
0065 };
0066
0067
0068
0069
0070
0071 class Parm {
0072
0073 public:
0074
0075
0076 Parm(string nameIn = " ", double defaultIn = 0.,
0077 bool hasMinIn = false, bool hasMaxIn = false, double minIn = 0.,
0078 double maxIn = 0.) : name(nameIn), valNow(defaultIn),
0079 valDefault(defaultIn), hasMin(hasMinIn), hasMax(hasMaxIn),
0080 valMin(minIn), valMax(maxIn) { }
0081
0082
0083 string name;
0084 double valNow, valDefault;
0085 bool hasMin, hasMax;
0086 double valMin, valMax;
0087
0088 };
0089
0090
0091
0092
0093
0094 class Word {
0095
0096 public:
0097
0098
0099 Word(string nameIn = " ", string defaultIn = " ") : name(nameIn),
0100 valNow(defaultIn) , valDefault(defaultIn) { }
0101
0102
0103 string name, valNow, valDefault;
0104
0105 };
0106
0107
0108
0109
0110
0111 class FVec {
0112
0113 public:
0114
0115
0116 FVec(string nameIn = " ", vector<bool> defaultIn = vector<bool>(1, false)) :
0117 name(nameIn), valNow(defaultIn) , valDefault(defaultIn) { }
0118
0119
0120 string name;
0121 vector<bool> valNow, valDefault;
0122
0123 };
0124
0125
0126
0127
0128
0129 class MVec {
0130
0131 public:
0132
0133
0134 MVec(string nameIn = " ", vector<int> defaultIn = vector<int>(1, 0),
0135 bool hasMinIn = false, bool hasMaxIn = false, int minIn = 0,
0136 int maxIn = 0) : name(nameIn), valNow(defaultIn),
0137 valDefault(defaultIn), hasMin(hasMinIn), hasMax(hasMaxIn),
0138 valMin(minIn), valMax(maxIn) { }
0139
0140
0141 string name;
0142 vector<int> valNow, valDefault;
0143 bool hasMin, hasMax;
0144 int valMin, valMax;
0145
0146 };
0147
0148
0149
0150
0151
0152 class PVec {
0153
0154 public:
0155
0156
0157 PVec(string nameIn = " ", vector<double> defaultIn = vector<double>(1, 0.),
0158 bool hasMinIn = false, bool hasMaxIn = false, double minIn = 0.,
0159 double maxIn = 0.) : name(nameIn), valNow(defaultIn),
0160 valDefault(defaultIn), hasMin(hasMinIn), hasMax(hasMaxIn),
0161 valMin(minIn), valMax(maxIn) { }
0162
0163
0164 string name;
0165 vector<double> valNow, valDefault;
0166 bool hasMin, hasMax;
0167 double valMin, valMax;
0168
0169 };
0170
0171
0172
0173
0174
0175 class WVec {
0176
0177 public:
0178
0179
0180 WVec(string nameIn = " ", vector<string> defaultIn = vector<string>(1, " "))
0181 : name(nameIn), valNow(defaultIn) , valDefault(defaultIn) { }
0182
0183
0184 string name;
0185 vector<string> valNow, valDefault;
0186
0187 };
0188
0189
0190
0191
0192
0193
0194
0195 class Settings {
0196
0197 public:
0198
0199
0200 Settings() : loggerPtr(), isInit(false), readingFailedSave(false),
0201 lineSaved(false) {}
0202
0203
0204 void initPtrs(Logger* loggerPtrIn) {loggerPtr = loggerPtrIn;}
0205
0206
0207 bool init(string startFile = "../share/Pythia8/xmldoc/Index.xml",
0208 bool append = false) ;
0209
0210
0211 bool init(istream& is, bool append = false) ;
0212
0213
0214 bool reInit(string startFile = "../share/Pythia8/xmldoc/Index.xml") ;
0215
0216
0217 bool readString(string line, bool warn = true) ;
0218
0219
0220 bool registerPluginLibrary(string libName, string startFile = "");
0221
0222
0223 bool writeFile(string toFile, bool writeAll = false) ;
0224 bool writeFile(ostream& os = cout, bool writeAll = false) ;
0225 bool writeFileXML(ostream& os = cout) ;
0226
0227
0228
0229 void listAll() { list( true, false, " "); }
0230 void listChanged() { list (false, false, " "); }
0231 void list(string match) { list (false, true, match); }
0232
0233
0234 string output(string keyIn, bool fullLine = true);
0235
0236
0237
0238 vector<string> getReadHistory(int subrun=-999) {
0239 if (subrun == -999) return readStringHistory;
0240 else if (readStringSubrun.find(subrun) != readStringSubrun.end())
0241 return readStringSubrun[subrun];
0242 else return vector<string>();
0243 }
0244
0245
0246 void resetAll() ;
0247
0248
0249 bool isFlag(string keyIn) {
0250 return (flags.find(toLower(keyIn)) != flags.end()); }
0251 bool isMode(string keyIn) {
0252 return (modes.find(toLower(keyIn)) != modes.end()); }
0253 bool isParm(string keyIn) {
0254 return (parms.find(toLower(keyIn)) != parms.end()); }
0255 bool isWord(string keyIn) {
0256 return (words.find(toLower(keyIn)) != words.end()); }
0257 bool isFVec(string keyIn) {
0258 return (fvecs.find(toLower(keyIn)) != fvecs.end()); }
0259 bool isMVec(string keyIn) {
0260 return (mvecs.find(toLower(keyIn)) != mvecs.end()); }
0261 bool isPVec(string keyIn) {
0262 return (pvecs.find(toLower(keyIn)) != pvecs.end()); }
0263 bool isWVec(string keyIn) {
0264 return (wvecs.find(toLower(keyIn)) != wvecs.end()); }
0265
0266
0267 void addFlag(string keyIn, bool defaultIn) {
0268 flags[toLower(keyIn)] = Flag(keyIn, defaultIn); }
0269 void addMode(string keyIn, int defaultIn, bool hasMinIn,
0270 bool hasMaxIn, int minIn, int maxIn, bool optOnlyIn = false) {
0271 modes[toLower(keyIn)] = Mode(keyIn, defaultIn, hasMinIn, hasMaxIn,
0272 minIn, maxIn, optOnlyIn); }
0273 void addParm(string keyIn, double defaultIn, bool hasMinIn,
0274 bool hasMaxIn, double minIn, double maxIn) { parms[toLower(keyIn)]
0275 = Parm(keyIn, defaultIn, hasMinIn, hasMaxIn, minIn, maxIn); }
0276 void addWord(string keyIn, string defaultIn) {
0277 words[toLower(keyIn)] = Word(keyIn, defaultIn); }
0278 void addFVec(string keyIn, vector<bool> defaultIn) {
0279 fvecs[toLower(keyIn)] = FVec(keyIn, defaultIn); }
0280 void addMVec(string keyIn, vector<int> defaultIn, bool hasMinIn,
0281 bool hasMaxIn, int minIn, int maxIn) { mvecs[toLower(keyIn)]
0282 = MVec(keyIn, defaultIn, hasMinIn, hasMaxIn, minIn, maxIn); }
0283 void addPVec(string keyIn, vector<double> defaultIn, bool hasMinIn,
0284 bool hasMaxIn, double minIn, double maxIn) { pvecs[toLower(keyIn)]
0285 = PVec(keyIn, defaultIn, hasMinIn, hasMaxIn, minIn, maxIn); }
0286 void addWVec(string keyIn, vector<string> defaultIn) {
0287 wvecs[toLower(keyIn)] = WVec(keyIn, defaultIn); }
0288
0289
0290 bool flag(string keyIn);
0291 int mode(string keyIn);
0292 double parm(string keyIn);
0293 string word(string keyIn);
0294 vector<bool> fvec(string keyIn);
0295 vector<int> mvec(string keyIn);
0296 vector<double> pvec(string keyIn);
0297 vector<string> wvec(string keyIn);
0298
0299
0300 bool flagDefault(string keyIn);
0301 int modeDefault(string keyIn);
0302 double parmDefault(string keyIn);
0303 string wordDefault(string keyIn);
0304 vector<bool> fvecDefault(string keyIn);
0305 vector<int> mvecDefault(string keyIn);
0306 vector<double> pvecDefault(string keyIn);
0307 vector<string> wvecDefault(string keyIn);
0308
0309
0310 map<string, Flag> getFlagMap(string match);
0311 map<string, Mode> getModeMap(string match);
0312 map<string, Parm> getParmMap(string match);
0313 map<string, Word> getWordMap(string match);
0314 map<string, FVec> getFVecMap(string match);
0315 map<string, MVec> getMVecMap(string match);
0316 map<string, PVec> getPVecMap(string match);
0317 map<string, WVec> getWVecMap(string match);
0318
0319
0320 void flag(string keyIn, bool nowIn, bool force = false);
0321 bool mode(string keyIn, int nowIn, bool force = false);
0322 bool parm(string keyIn, double nowIn, bool force = false);
0323 void word(string keyIn, string nowIn, bool force = false);
0324 void fvec(string keyIn, vector<bool> nowIn, bool force = false);
0325 bool mvec(string keyIn, vector<int> nowIn, bool force = false);
0326 bool pvec(string keyIn, vector<double> nowIn, bool force = false);
0327 void wvec(string keyIn, vector<string> nowIn, bool force = false);
0328
0329
0330
0331 void forceMode(string keyIn, int nowIn) {mode(keyIn,nowIn,true);}
0332 void forceParm(string keyIn, double nowIn) {parm(keyIn,nowIn,true);}
0333 void forceMVec(string keyIn, vector<int> nowIn) {mvec(keyIn,nowIn,true);}
0334 void forcePVec(string keyIn, vector<double> nowIn) {pvec(keyIn,nowIn,true);}
0335
0336
0337 void resetFlag(string keyIn);
0338 void resetMode(string keyIn);
0339 void resetParm(string keyIn);
0340 void resetWord(string keyIn);
0341 void resetFVec(string keyIn);
0342 void resetMVec(string keyIn);
0343 void resetPVec(string keyIn);
0344 void resetWVec(string keyIn);
0345
0346
0347 bool getIsInit() {return isInit;}
0348
0349
0350 bool readingFailed() {return readingFailedSave;}
0351
0352
0353 bool unfinishedInput() {return lineSaved;}
0354
0355
0356 bool hasHardProc();
0357
0358 private:
0359
0360
0361 Logger* loggerPtr;
0362
0363
0364 map<string, Flag> flags;
0365
0366
0367 map<string, Mode> modes;
0368
0369
0370 map<string, Parm> parms;
0371
0372
0373 map<string, Word> words;
0374
0375
0376 map<string, FVec> fvecs;
0377
0378
0379 map<string, MVec> mvecs;
0380
0381
0382 map<string, PVec> pvecs;
0383
0384
0385 map<string, WVec> wvecs;
0386
0387
0388 set<string> pluginLibraries;
0389
0390
0391 bool isInit, readingFailedSave;
0392
0393
0394 bool lineSaved;
0395 string savedLine;
0396
0397
0398 vector<string> readStringHistory;
0399 map<int, vector<string> > readStringSubrun;
0400
0401
0402 void list(bool doListAll, bool doListString, string match);
0403
0404
0405 void printQuiet(bool quiet);
0406
0407
0408 void resetTuneEE();
0409 void resetTunePP();
0410
0411
0412 void initTuneEE(int eeTune);
0413 void initTunePP(int ppTune);
0414
0415
0416 bool boolString(string tag);
0417 string attributeValue(string line, string attribute);
0418 bool boolAttributeValue(string line, string attribute);
0419 int intAttributeValue(string line, string attribute);
0420 double doubleAttributeValue(string line, string attribute);
0421 vector<bool> boolVectorAttributeValue(string line, string attribute);
0422 vector<int> intVectorAttributeValue(string line, string attribute);
0423 vector<double> doubleVectorAttributeValue(string line, string attribute);
0424 vector<string> stringVectorAttributeValue(string line, string attribute);
0425
0426 };
0427
0428
0429
0430 }
0431
0432 #endif