StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Settings.cc
1 // Settings.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Function definitions (not found in the header) for the Settings class.
7 
8 #include "Pythia8/Settings.h"
9 
10 // Allow string and character manipulation.
11 #include <cctype>
12 
13 namespace Pythia8 {
14 
15 //==========================================================================
16 
17 // Settings class.
18 // This class contains flags, modes, parms and words used in generation.
19 
20 //--------------------------------------------------------------------------
21 
22 // Read in database from specific file.
23 
24 bool Settings::init(string startFile, bool append) {
25 
26  // Don't initialize if it has already been done and not in append mode.
27  if (isInit && !append) return true;
28  int nError = 0;
29 
30  // Reset readString history.
31  if (!append) {
32  readStringHistory.resize(0);
33  readStringSubrun.clear();
34  }
35 
36  // List of files to be checked. Start with input file.
37  vector<string> files;
38  files.push_back(startFile);
39 
40  // If nontrivial startfile path, then use that for other files as well.
41  string pathName = "";
42  if (startFile.rfind("/") != string::npos)
43  pathName = startFile.substr(0, startFile.rfind("/") + 1);
44 
45  // Loop over files. Open them for read.
46  for (int i = 0; i < int(files.size()); ++i) {
47  const char* cstring = files[i].c_str();
48  ifstream is(cstring);
49 
50  // Check that instream is OK.
51  if (!is.good()) {
52  cout << "\n PYTHIA Error: settings file " << files[i]
53  << " not found" << endl;
54  return false;
55  }
56 
57  // Read in one line at a time.
58  string line;
59  while ( getline(is, line) ) {
60 
61  // Get first word of a line, to interpret it as tag. Remove "more".
62  istringstream getfirst(line);
63  string tag;
64  getfirst >> tag;
65  if (tag.find("more") != string::npos) tag.erase( tag.find("more"), 4);
66 
67  // Skip ahead if not interesting. Only look for new files in startfile.
68  if (tag != "<flag" && tag != "<flagfix" && tag != "<mode"
69  && tag != "<modeopen" && tag != "<modepick" && tag != "<modefix"
70  && tag != "<parm" && tag != "<parmfix" && tag != "<word"
71  && tag != "<wordfix" && tag != "<fvec" && tag != "<fvecfix"
72  && tag != "<mvec" && tag != "<mvecfix"
73  && tag != "<pvec" && tag != "<pvecfix"
74  && tag != "<wvec" && tag != "<wvecfix" && tag != "<aidx") continue;
75 
76  // Read and append continuation line(s) if line does not contain >.
77  while (line.find(">") == string::npos) {
78  string addLine;
79  getline(is, addLine);
80  line += " " + addLine;
81  }
82 
83  // Remove extra blanks before an = sign.
84  while (line.find(" =") != string::npos) line.erase( line.find(" ="), 1);
85 
86  // Add file also to be read.
87  if (tag == "<aidx") {
88  string name = attributeValue( line, "href");
89  if (name == "") {
90  cout << " PYTHIA Error: failed to find name attribute in line "
91  << line << endl;
92  ++nError;
93  continue;
94  }
95  files.push_back(pathName + name + ".xml");
96  continue;
97  }
98 
99  // Find name attribute.
100  string name = attributeValue( line, "name=");
101  if (name == "") {
102  cout << " PYTHIA Error: failed to find name attribute in line "
103  << line << endl;
104  ++nError;
105  continue;
106  }
107 
108  // Check that default value attribute present, and whether max and min.
109  if (line.find("default=") == string::npos) {
110  cout << " PYTHIA Error: failed to find default value token in line "
111  << line << endl;
112  ++nError;
113  continue;
114  }
115  bool hasMin = (line.find("min=") != string::npos);
116  bool hasMax = (line.find("max=") != string::npos);
117 
118  // Check for occurence of a bool and add to flag map.
119  if (tag == "<flag" || tag == "<flagfix") {
120  bool value = boolAttributeValue( line, "default=");
121  addFlag( name, value);
122 
123  // Check for occurence of an int and add to mode map.
124  } else if (tag == "<mode" || tag == "<modeopen"
125  || tag == "<modepick" || tag == "<modefix") {
126  int value = intAttributeValue( line, "default=");
127  int minVal = intAttributeValue( line, "min=");
128  int maxVal = intAttributeValue( line, "max=");
129  // Enforce check that only allowed options are accepted.
130  bool optOnly = false;
131  if (tag == "<modepick" && hasMin && hasMax) optOnly = true;
132  if (tag == "<modefix") {
133  hasMin = true;
134  hasMax = true;
135  minVal = value;
136  maxVal = value;
137  optOnly = true;
138  }
139  addMode( name, value, hasMin, hasMax, minVal, maxVal, optOnly);
140 
141  // Check for occurence of a double and add to parm map.
142  } else if (tag == "<parm" || tag == "<parmfix") {
143  double value = doubleAttributeValue( line, "default=");
144  double minVal = doubleAttributeValue( line, "min=");
145  double maxVal = doubleAttributeValue( line, "max=");
146  addParm( name, value, hasMin, hasMax, minVal, maxVal);
147 
148  // Check for occurence of a string and add to word map.
149  } else if (tag == "<word" || tag == "<wordfix") {
150  string value = attributeValue( line, "default=");
151  addWord( name, value);
152 
153  // Check for occurence of a bool vector and add to fvec map.
154  } else if (tag == "<fvec" || tag == "<fvecfix") {
155  vector<bool> value = boolVectorAttributeValue( line, "default=");
156  addFVec( name, value);
157 
158  // Check for occurence of an int vector and add to mvec map.
159  } else if (tag == "<mvec" || tag == "<mvecfix") {
160  vector<int> value = intVectorAttributeValue( line, "default=");
161  int minVal = intAttributeValue( line, "min=");
162  int maxVal = intAttributeValue( line, "max=");
163  addMVec( name, value, hasMin, hasMax, minVal, maxVal);
164 
165  // Check for occurence of a double vector and add to pvec map.
166  } else if (tag == "<pvec" || tag == "<pvecfix") {
167  vector<double> value = doubleVectorAttributeValue( line, "default=");
168  double minVal = doubleAttributeValue( line, "min=");
169  double maxVal = doubleAttributeValue( line, "max=");
170  addPVec( name, value, hasMin, hasMax, minVal, maxVal);
171 
172  // Check for occurence of a string vector and add to wvec map.
173  } else if (tag == "<wvec" || tag == "<wvecfix") {
174  vector<string> value = stringVectorAttributeValue( line, "default=");
175  addWVec( name, value);
176  }
177 
178  // End of loop over lines in input file and loop over files.
179  };
180  };
181 
182  // Set up default e+e- and pp tunes, if positive.
183  int eeTune = mode("Tune:ee");
184  if (eeTune > 0) initTuneEE( eeTune);
185  int ppTune = mode("Tune:pp");
186  if (ppTune > 0) initTunePP( ppTune);
187 
188  // Done.
189  if (nError > 0) return false;
190  isInit = true;
191  return true;
192 
193 }
194 
195 
196 //--------------------------------------------------------------------------
197 
198 // Read in database from specific stream.
199 
200 bool Settings::init(istream& is, bool append) {
201 
202  // Don't initialize if it has already been done and not in append mode.
203  if (isInit && !append) return true;
204  int nError = 0;
205 
206  // Check that instream is OK.
207  if (!is.good()) {
208  cout << "\n PYTHIA Error: settings stream not found " << endl;
209  return false;
210  }
211 
212  // Reset readString history.
213  if (!append) {
214  readStringHistory.resize(0);
215  readStringSubrun.clear();
216  }
217 
218  // Read in one line at a time.
219  string line;
220  while ( getline(is, line) ) {
221 
222  // Get first word of a line, to interpret it as tag. Remove "more".
223  istringstream getfirst(line);
224  string tag;
225  getfirst >> tag;
226  if (tag.find("more") != string::npos) tag.erase( tag.find("more"), 4);
227 
228  // Skip ahead if not interesting. Only look for new files in startfile.
229  if (tag != "<flag" && tag != "<flagfix" && tag != "<mode"
230  && tag != "<modeopen" && tag != "<modepick" && tag != "<modefix"
231  && tag != "<parm" && tag != "<parmfix" && tag != "<word"
232  && tag != "<wordfix" && tag != "<fvec" && tag != "<fvecfix"
233  && tag != "<mvec" && tag != "<mvecfix"
234  && tag != "<pvec" && tag != "<pvecfix"
235  && tag != "<wvec" && tag != "<wvecfix" && tag != "<aidx") continue;
236 
237  // Read and append continuation line(s) if line does not contain >.
238  while (line.find(">") == string::npos) {
239  string addLine;
240  getline(is, addLine);
241  line += " " + addLine;
242  }
243 
244  // Remove extra blanks before an = sign.
245  while (line.find(" =") != string::npos) line.erase( line.find(" ="), 1);
246 
247  // Find name attribute.
248  string name = attributeValue( line, "name=");
249  if (name == "") {
250  cout << " PYTHIA Error: failed to find name attribute in line "
251  << line << endl;
252  ++nError;
253  continue;
254  }
255 
256  // Check that default value attribute present, and whether max and min.
257  if (line.find("default=") == string::npos) {
258  cout << " PYTHIA Error: failed to find default value token in line "
259  << line << endl;
260  ++nError;
261  continue;
262  }
263  bool hasMin = (line.find("min=") != string::npos);
264  bool hasMax = (line.find("max=") != string::npos);
265 
266  // Check for occurence of a bool and add to flag map.
267  if (tag == "<flag" || tag == "<flagfix") {
268  bool value = boolAttributeValue( line, "default=");
269  addFlag( name, value);
270 
271  // Check for occurence of an int and add to mode map.
272  } else if (tag == "<mode" || tag == "<modeopen"
273  || tag == "<modepick" || tag == "<modefix") {
274  int value = intAttributeValue( line, "default=");
275  int minVal = intAttributeValue( line, "min=");
276  int maxVal = intAttributeValue( line, "max=");
277 
278  // Enforce check that only allowed options are accepted.
279  bool optOnly = false;
280  if (tag == "<modepick" && hasMin && hasMax) optOnly = true;
281  if (tag == "<modefix") {
282  hasMin = true;
283  hasMax = true;
284  minVal = value;
285  maxVal = value;
286  optOnly = true;
287  }
288  addMode( name, value, hasMin, hasMax, minVal, maxVal, optOnly);
289 
290  // Check for occurence of a double and add to parm map.
291  } else if (tag == "<parm" || tag == "<parmfix") {
292  double value = doubleAttributeValue( line, "default=");
293  double minVal = doubleAttributeValue( line, "min=");
294  double maxVal = doubleAttributeValue( line, "max=");
295  addParm( name, value, hasMin, hasMax, minVal, maxVal);
296 
297  // Check for occurence of a string and add to word map.
298  } else if (tag == "<word" || tag == "<wordfix") {
299  string value = attributeValue( line, "default=");
300  addWord( name, value);
301 
302  // Check for occurence of a bool vector and add to fvec map.
303  } else if (tag == "<fvec" || tag == "<fvecfix") {
304  vector<bool> value = boolVectorAttributeValue( line, "default=");
305  addFVec( name, value);
306 
307  // Check for occurence of an int vector and add to mvec map.
308  } else if (tag == "<mvec" || tag == "<mvecfix") {
309  vector<int> value = intVectorAttributeValue( line, "default=");
310  int minVal = intAttributeValue( line, "min=");
311  int maxVal = intAttributeValue( line, "max=");
312  addMVec( name, value, hasMin, hasMax, minVal, maxVal);
313 
314  // Check for occurence of a double vector and add to pvec map.
315  } else if (tag == "<pvec" || tag == "<pvecfix") {
316  vector<double> value = doubleVectorAttributeValue( line, "default=");
317  double minVal = doubleAttributeValue( line, "min=");
318  double maxVal = doubleAttributeValue( line, "max=");
319  addPVec( name, value, hasMin, hasMax, minVal, maxVal);
320 
321  // Check for occurence of a string vector and add to word map.
322  } else if (tag == "<wvec" || tag == "<wvecfix") {
323  vector<string> value = stringVectorAttributeValue( line, "default=");
324  addWVec( name, value);
325  }
326 
327  // End of loop over lines in input file and loop over files.
328  };
329 
330  // Set up default e+e- and pp tunes, if positive.
331  int eeTune = mode("Tune:ee");
332  if (eeTune > 0) initTuneEE( eeTune);
333  int ppTune = mode("Tune:pp");
334  if (ppTune > 0) initTunePP( ppTune);
335 
336  // Done.
337  if (nError > 0) return false;
338  isInit = true;
339  return true;
340 
341 }
342 
343 //--------------------------------------------------------------------------
344 
345 // Overwrite existing database by reading from specific file.
346 
347 bool Settings::reInit(string startFile) {
348 
349  // Reset maps to empty.
350  flags.clear();
351  modes.clear();
352  parms.clear();
353  words.clear();
354  fvecs.clear();
355  mvecs.clear();
356  pvecs.clear();
357  wvecs.clear();
358 
359  // Then let normal init do the rest.
360  isInit = false;
361  return init(startFile, false);
362 
363 }
364 
365 //--------------------------------------------------------------------------
366 
367 // Read in updates from a character string, like a line of a file.
368 // Is used by readString (and readFile) in Pythia.
369 
370 bool Settings::readString(string line, bool warn) {
371 
372  // If empty line then done.
373  if (line.find_first_not_of(" \n\t\v\b\r\f\a") == string::npos) return true;
374 
375  // If unfinished line then add new to existing, else use input line as is.
376  string lineNow = (lineSaved) ? savedLine + line : line;
377  lineSaved = false;
378 
379  // If first character is not a letter, then taken to be a comment line.
380  int firstChar = lineNow.find_first_not_of(" \n\t\v\b\r\f\a");
381  if (!isalpha(lineNow[firstChar])) return true;
382 
383  // Replace an equal sign by a blank to make parsing simpler, except after {.
384  size_t iBrace = (lineNow.find_first_of("{") == string::npos) ? lineNow.size()
385  : lineNow.find_first_of("{");
386  while (lineNow.find("=") != string::npos
387  && lineNow.find_first_of("=") < iBrace) {
388  int firstEqual = lineNow.find_first_of("=");
389  lineNow.replace(firstEqual, 1, " ");
390  }
391 
392  // Get first word of a line.
393  istringstream splitLine(lineNow);
394  string name;
395  splitLine >> name;
396 
397  // Replace two colons by one (:: -> :) to allow for such mistakes.
398  while (name.find("::") != string::npos) {
399  int firstColonColon = name.find_first_of("::");
400  name.replace(firstColonColon, 2, ":");
401  }
402 
403  // Check whether this is in the database.
404  int inDataBase = 0;
405  if (isFlag(name)) inDataBase = 1;
406  else if (isMode(name)) inDataBase = 2;
407  else if (isParm(name)) inDataBase = 3;
408  else if (isWord(name)) inDataBase = 4;
409  else if (isFVec(name)) inDataBase = 5;
410  else if (isMVec(name)) inDataBase = 6;
411  else if (isPVec(name)) inDataBase = 7;
412  else if (isWVec(name)) inDataBase = 8;
413 
414  // For backwards compatibility: old (parts of) names mapped onto new ones.
415  // This code currently has no use, but is partly preserved for the day
416  // it may be needed again.
417  /*
418  if (inDataBase == 0) {
419  bool retry = false;
420  string nameLower = toLower(name);
421  if (!retry && nameLower.find("minbias") != string::npos) {
422  int firstMB = nameLower.find_first_of("minbias");
423  name.replace(firstMB, 7, "nonDiffractive");
424  retry = true;
425  }
426  if (retry) {
427  if (isFlag(name)) inDataBase = 1;
428  else if (isMode(name)) inDataBase = 2;
429  else if (isParm(name)) inDataBase = 3;
430  else if (isWord(name)) inDataBase = 4;
431  else if (isFVec(name)) inDataBase = 5;
432  else if (isMVec(name)) inDataBase = 6;
433  else if (isPVec(name)) inDataBase = 7;
434  else if (isWVec(name)) inDataBase = 8;
435  }
436  }
437  */
438 
439  // Warn and done if not in database.
440  if (inDataBase == 0) {
441  if (warn) cout << "\n PYTHIA Error: input string not found in settings"
442  << " databases::\n " << line << endl;
443  readingFailedSave = true;
444  return false;
445  }
446 
447  // Find value. Warn if none found.
448  string valueString;
449  splitLine >> valueString;
450  if (!splitLine) {
451  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
452  << " not meaningful:\n " << line << endl;
453  readingFailedSave = true;
454  return false;
455  }
456 
457  // If value is a ? then echo the current value.
458  if (valueString == "?") {
459  cout << output(name);
460  return true;
461  }
462 
463  // Check for FORCE= statements (to ignore min/max values)
464  bool force = false;
465  if (valueString.find("force") != string::npos) {
466  force = true;
467  // Read value from next word
468  splitLine >> valueString;
469  if (!splitLine) {
470  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
471  << " not meaningful:\n " << line << endl;
472  readingFailedSave = true;
473  return false;
474  }
475  }
476 
477 
478  // If string begins with { then find matching } and extract contents.
479  if (valueString[0] == '{') {
480  size_t openBrace = lineNow.find_first_of("{");
481  size_t closeBrace = lineNow.find_first_of("}");
482  // If not } on same line then must append next line and try again.
483  if (closeBrace == string::npos) {
484  lineSaved = true;
485  savedLine = lineNow;
486  return true;
487  }
488  valueString = lineNow.substr(openBrace, closeBrace - openBrace + 1);
489  }
490 
491  // Update flag map; allow many ways to say yes.
492  if (inDataBase == 1) {
493  bool value = boolString(valueString);
494  flag(name, value, force);
495 
496  // Update mode map.
497  } else if (inDataBase == 2) {
498  istringstream modeData(valueString);
499  int value;
500  modeData >> value;
501  if (!modeData) {
502  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
503  << " not meaningful:\n " << line << endl;
504  readingFailedSave = true;
505  return false;
506  }
507  if (!mode(name, value, force)) {
508  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
509  << " non-existing option:\n " << line << endl;
510  readingFailedSave = true;
511  return false;
512  }
513 
514  // Update parm map.
515  } else if (inDataBase == 3) {
516  istringstream parmData(valueString);
517  double value;
518  parmData >> value;
519  if (!parmData) {
520  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
521  << " not meaningful:\n " << line << endl;
522  readingFailedSave = true;
523  return false;
524  }
525  parm(name, value, force);
526 
527  // Update word map.
528  } else if (inDataBase == 4) {
529  word(name, valueString, force);
530 
531  // Update fvec map.
532  } else if (inDataBase == 5) {
533  istringstream fvecData(valueString);
534  vector<bool> value(boolVectorAttributeValue(
535  "value=\"" + valueString + "\"", "value="));
536  if (!fvecData) {
537  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
538  << " not meaningful:\n " << line << endl;
539  readingFailedSave = true;
540  return false;
541  }
542  fvec(name, value, force);
543 
544  // Update mvec map.
545  } else if (inDataBase == 6) {
546  istringstream mvecData(valueString);
547  vector<int> value(intVectorAttributeValue(
548  "value=\"" + valueString + "\"", "value="));
549  if (!mvecData) {
550  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
551  << " not meaningful:\n " << line << endl;
552  readingFailedSave = true;
553  return false;
554  }
555  mvec(name, value, force);
556 
557  // Update pvec map.
558  } else if (inDataBase == 7) {
559  istringstream pvecData(valueString);
560  vector<double> value(doubleVectorAttributeValue(
561  "value=\"" + valueString + "\"", "value="));
562  if (!pvecData) {
563  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
564  << " not meaningful:\n " << line << endl;
565  readingFailedSave = true;
566  return false;
567  }
568  pvec(name, value, force);
569 
570  // Update wvec map.
571  } else if (inDataBase == 8) {
572  istringstream wvecData(valueString);
573  vector<string> value(stringVectorAttributeValue(
574  "value=\"" + valueString + "\"", "value="));
575  if (!wvecData) {
576  if (warn) cout << "\n PYTHIA Error: variable recognized, but its value"
577  << " not meaningful:\n " << line << endl;
578  readingFailedSave = true;
579  return false;
580  }
581  wvec(name, value, force);
582  }
583 
584  // Store history of valid readString statements
585  readStringHistory.push_back(lineNow);
586  int subrun = max(-1,mode("Main:subrun"));
587  if (readStringSubrun.find(subrun) == readStringSubrun.end())
588  readStringSubrun[subrun] = vector<string>();
589  readStringSubrun[subrun].push_back(lineNow);
590 
591  // Done.
592  return true;
593 }
594 
595 //--------------------------------------------------------------------------
596 
597 // Write updates or everything to user-defined file.
598 
599 bool Settings::writeFile(string toFile, bool writeAll) {
600 
601  // Open file for writing.
602  const char* cstring = toFile.c_str();
603  ofstream os(cstring);
604  if (!os) {
605  infoPtr->errorMsg("Error in Settings::writeFile:"
606  " could not open file", toFile);
607  return false;
608  }
609 
610  // Hand over real work to next method.
611  return writeFile( os, writeAll);
612 
613 }
614 
615 //--------------------------------------------------------------------------
616 
617 // Write updates or everything to user-defined stream (or file).
618 
619 bool Settings::writeFile(ostream& os, bool writeAll) {
620 
621  // Write simple header as comment.
622  if (writeAll) os << "! List of all current PYTHIA ";
623  else os << "! List of all modified PYTHIA ";
624  os << fixed << setprecision(3) << parm("Pythia:versionNumber")
625  << " settings.\n";
626 
627  // Iterators for the flag, mode and parm tables.
628  map<string, Flag>::iterator flagEntry = flags.begin();
629  map<string, Mode>::iterator modeEntry = modes.begin();
630  map<string, Parm>::iterator parmEntry = parms.begin();
631  map<string, Word>::iterator wordEntry = words.begin();
632  map<string, FVec>::iterator fvecEntry = fvecs.begin();
633  map<string, MVec>::iterator mvecEntry = mvecs.begin();
634  map<string, PVec>::iterator pvecEntry = pvecs.begin();
635  map<string, WVec>::iterator wvecEntry = wvecs.begin();
636 
637  // Loop while there is something left to do.
638  while (flagEntry != flags.end() || modeEntry != modes.end()
639  || parmEntry != parms.end() || wordEntry != words.end()
640  || fvecEntry != fvecs.end() || mvecEntry != mvecs.end()
641  || pvecEntry != pvecs.end() || wvecEntry != wvecs.end() ) {
642 
643  // Check if a flag is next in lexigraphical order; if so print it.
644  if ( flagEntry != flags.end()
645  && ( modeEntry == modes.end() || flagEntry->first < modeEntry->first )
646  && ( parmEntry == parms.end() || flagEntry->first < parmEntry->first )
647  && ( wordEntry == words.end() || flagEntry->first < wordEntry->first )
648  && ( fvecEntry == fvecs.end() || flagEntry->first < fvecEntry->first )
649  && ( mvecEntry == mvecs.end() || flagEntry->first < mvecEntry->first )
650  && ( pvecEntry == pvecs.end() || flagEntry->first < pvecEntry->first )
651  && ( wvecEntry == wvecs.end() || flagEntry->first < wvecEntry->first )
652  ) {
653  string state[2] = {"off", "on"};
654  bool valNow = flagEntry->second.valNow;
655  bool valDefault = flagEntry->second.valDefault;
656  if ( writeAll || valNow != valDefault )
657  os << flagEntry->second.name << " = " << state[valNow] << "\n";
658  ++flagEntry;
659 
660  // Else check if mode is next, and if so print it.
661  } else if ( modeEntry != modes.end()
662  && ( parmEntry == parms.end() || modeEntry->first < parmEntry->first )
663  && ( wordEntry == words.end() || modeEntry->first < wordEntry->first )
664  && ( fvecEntry == fvecs.end() || modeEntry->first < fvecEntry->first )
665  && ( mvecEntry == mvecs.end() || modeEntry->first < mvecEntry->first )
666  && ( pvecEntry == pvecs.end() || modeEntry->first < pvecEntry->first )
667  && ( wvecEntry == wvecs.end() || modeEntry->first < wvecEntry->first )
668  ) {
669  int valNow = modeEntry->second.valNow;
670  int valDefault = modeEntry->second.valDefault;
671  if ( writeAll || valNow != valDefault )
672  os << modeEntry->second.name << " = " << valNow << "\n";
673  ++modeEntry;
674 
675  // Else check if parm is next, and if so print it; fixed or scientific.
676  } else if ( parmEntry != parms.end()
677  && ( wordEntry == words.end() || parmEntry->first < wordEntry->first )
678  && ( fvecEntry == fvecs.end() || parmEntry->first < fvecEntry->first )
679  && ( mvecEntry == mvecs.end() || parmEntry->first < mvecEntry->first )
680  && ( pvecEntry == pvecs.end() || parmEntry->first < pvecEntry->first )
681  && ( wvecEntry == wvecs.end() || parmEntry->first < wvecEntry->first )
682  ) {
683  double valNow = parmEntry->second.valNow;
684  double valDefault = parmEntry->second.valDefault;
685  if ( writeAll || valNow != valDefault ) {
686  os << parmEntry->second.name << " = ";
687  if ( valNow == 0. ) os << fixed << setprecision(1);
688  else if ( abs(valNow) < 0.001 ) os << scientific << setprecision(4);
689  else if ( abs(valNow) < 0.1 ) os << fixed << setprecision(7);
690  else if ( abs(valNow) < 1000. ) os << fixed << setprecision(5);
691  else if ( abs(valNow) < 1000000. ) os << fixed << setprecision(3);
692  else os << scientific << setprecision(4);
693  os << valNow << "\n";
694  }
695  ++parmEntry;
696 
697  // Else check if word is next, and if so print it.
698  } else if ( wordEntry != words.end()
699  && ( fvecEntry == fvecs.end() || wordEntry->first < fvecEntry->first )
700  && ( mvecEntry == mvecs.end() || wordEntry->first < mvecEntry->first )
701  && ( pvecEntry == pvecs.end() || wordEntry->first < pvecEntry->first )
702  && ( wvecEntry == wvecs.end() || wordEntry->first < wvecEntry->first )
703  ) {
704  string valNow = wordEntry->second.valNow;
705  string valDefault = wordEntry->second.valDefault;
706  if ( writeAll || valNow != valDefault )
707  os << wordEntry->second.name << " = " << valNow << "\n";
708  ++wordEntry;
709 
710  // Else check if fvec is next, and if so print it.
711  } else if ( fvecEntry != fvecs.end()
712  && ( mvecEntry == mvecs.end() || fvecEntry->first < mvecEntry->first )
713  && ( pvecEntry == pvecs.end() || fvecEntry->first < pvecEntry->first )
714  && ( wvecEntry == wvecs.end() || fvecEntry->first < wvecEntry->first )
715  ) {
716  string state[2] = {"off", "on"};
717  vector<bool> valNow = fvecEntry->second.valNow;
718  vector<bool> valDefault = fvecEntry->second.valDefault;
719  if ( writeAll || valNow != valDefault ) {
720  os << fvecEntry->second.name << " = {";
721  if (valNow.size() > 0) {
722  for (vector<bool>::iterator val = valNow.begin();
723  val != --valNow.end(); ++val) os << state[*val] << ",";
724  os << state[*(--valNow.end())] << "}\n";
725  } else os << "}\n";
726  }
727  ++fvecEntry;
728 
729  // Else check if mvec is next, and if so print it.
730  } else if ( mvecEntry != mvecs.end()
731  && ( pvecEntry == pvecs.end() || mvecEntry->first < pvecEntry->first )
732  && ( wvecEntry == wvecs.end() || mvecEntry->first < wvecEntry->first )
733  ) {
734  vector<int> valNow = mvecEntry->second.valNow;
735  vector<int> valDefault = mvecEntry->second.valDefault;
736  if ( writeAll || valNow != valDefault ) {
737  os << mvecEntry->second.name << " = {";
738  if (valNow.size() > 0) {
739  for (vector<int>::iterator val = valNow.begin();
740  val != --valNow.end(); ++val) os << *val << ",";
741  os << *(--valNow.end()) << "}\n";
742  } else os << "}\n";
743  }
744  ++mvecEntry;
745 
746  // Else check if pvec is next; print fixed or scientific.
747  } else if ( pvecEntry != pvecs.end()
748  && ( wvecEntry == wvecs.end() || pvecEntry->first < wvecEntry->first )
749  ) {
750  vector<double> valNow = pvecEntry->second.valNow;
751  vector<double> valDefault = pvecEntry->second.valDefault;
752  if ( writeAll || valNow != valDefault ) {
753  os << pvecEntry->second.name << " = {";
754  if (valNow.size() > 0) {
755  for (vector<double>::iterator val = valNow.begin();
756  val != --valNow.end(); ++val) {
757  if ( *val == 0. ) os << fixed << setprecision(1);
758  else if ( abs(*val) < 0.001 ) os << scientific << setprecision(4);
759  else if ( abs(*val) < 0.1 ) os << fixed << setprecision(7);
760  else if ( abs(*val) < 1000. ) os << fixed << setprecision(5);
761  else if ( abs(*val) < 1000000. ) os << fixed << setprecision(3);
762  else os << scientific << setprecision(4);
763  os << *val << ",";
764  } os << *(--valNow.end()) << "}\n";
765  } else os << "}\n";
766  }
767  ++pvecEntry;
768 
769  // Else print wvec.
770  } else {
771  vector<string> valNow = wvecEntry->second.valNow;
772  vector<string> valDefault = wvecEntry->second.valDefault;
773  if ( writeAll || valNow != valDefault ) {
774  if (valNow.size() > 0) {
775  os << wvecEntry->second.name << " = {";
776  for (vector<string>::iterator val = valNow.begin();
777  val != --valNow.end(); ++val) os << *val << ",";
778  os << *(--valNow.end()) << "}\n";
779  } else os << "}\n";
780  }
781  ++wvecEntry;
782  }
783  } ;
784 
785  // Done.
786  return true;
787 }
788 
789 //--------------------------------------------------------------------------
790 
791  // Write updates or everything to user-defined stream (or file).
792 
793 bool Settings::writeFileXML(ostream& os) {
794 
795  // Iterators for the flag, mode and parm tables.
796  map<string, Flag>::iterator flagEntry = flags.begin();
797  map<string, Mode>::iterator modeEntry = modes.begin();
798  map<string, Parm>::iterator parmEntry = parms.begin();
799  map<string, Word>::iterator wordEntry = words.begin();
800  map<string, FVec>::iterator fvecEntry = fvecs.begin();
801  map<string, MVec>::iterator mvecEntry = mvecs.begin();
802  map<string, PVec>::iterator pvecEntry = pvecs.begin();
803  map<string, WVec>::iterator wvecEntry = wvecs.begin();
804 
805  // Loop while there is something left to do.
806  while (flagEntry != flags.end() || modeEntry != modes.end()
807  || parmEntry != parms.end() || wordEntry != words.end()
808  || fvecEntry != fvecs.end() || mvecEntry != mvecs.end()
809  || pvecEntry != pvecs.end() || wvecEntry != wvecs.end() ) {
810 
811  // Check if a flag is next in lexigraphical order; if so print it.
812  if ( flagEntry != flags.end()
813  && ( modeEntry == modes.end() || flagEntry->first < modeEntry->first )
814  && ( parmEntry == parms.end() || flagEntry->first < parmEntry->first )
815  && ( wordEntry == words.end() || flagEntry->first < wordEntry->first )
816  && ( fvecEntry == fvecs.end() || flagEntry->first < fvecEntry->first )
817  && ( mvecEntry == mvecs.end() || flagEntry->first < mvecEntry->first )
818  && ( pvecEntry == pvecs.end() || flagEntry->first < pvecEntry->first )
819  && ( wvecEntry == wvecs.end() || flagEntry->first < wvecEntry->first )
820  ) {
821  string state[2] = {"off", "on"};
822  bool valDefault = flagEntry->second.valDefault;
823  os << "<flag name=\"" << flagEntry->second.name << "\" default=\""
824  << state[valDefault] << "\"></flag>" << endl;
825  ++flagEntry;
826 
827  // Else check if mode is next, and if so print it.
828  } else if ( modeEntry != modes.end()
829  && ( parmEntry == parms.end() || modeEntry->first < parmEntry->first )
830  && ( wordEntry == words.end() || modeEntry->first < wordEntry->first )
831  && ( fvecEntry == fvecs.end() || modeEntry->first < fvecEntry->first )
832  && ( mvecEntry == mvecs.end() || modeEntry->first < mvecEntry->first )
833  && ( pvecEntry == pvecs.end() || modeEntry->first < pvecEntry->first )
834  && ( wvecEntry == wvecs.end() || modeEntry->first < wvecEntry->first )
835  ) {
836  int valDefault = modeEntry->second.valDefault;
837  os << "<mode name=\"" << modeEntry->second.name << "\" default=\""
838  << valDefault << "\">";
839  if (modeEntry->second.hasMin ) os << " min=\""
840  << modeEntry->second.valMin << "\"";
841  if (modeEntry->second.hasMax ) os << " max=\""
842  << modeEntry->second.valMax << "\"";
843  os << "</mode>" << endl;
844  ++modeEntry;
845 
846  // Else check if parm is next, and if so print it; fixed or scientific.
847  } else if ( parmEntry != parms.end()
848  && ( wordEntry == words.end() || parmEntry->first < wordEntry->first )
849  && ( fvecEntry == fvecs.end() || parmEntry->first < fvecEntry->first )
850  && ( mvecEntry == mvecs.end() || parmEntry->first < mvecEntry->first )
851  && ( pvecEntry == pvecs.end() || parmEntry->first < pvecEntry->first )
852  && ( wvecEntry == wvecs.end() || parmEntry->first < wvecEntry->first )
853  ) {
854  double valDefault = parmEntry->second.valDefault;
855  os << "<parm name=\"" << parmEntry->second.name << "\" default=\"";
856  if ( valDefault == 0. ) os << fixed << setprecision(1);
857  else if ( abs(valDefault) < 0.001 ) os << scientific << setprecision(4);
858  else if ( abs(valDefault) < 0.1 ) os << fixed << setprecision(7);
859  else if ( abs(valDefault) < 1000. ) os << fixed << setprecision(5);
860  else if ( abs(valDefault) < 1000000. ) os << fixed << setprecision(3);
861  else os << scientific << setprecision(4);
862  os << valDefault << "\">";
863  if (parmEntry->second.hasMin) {
864  os << " min=\"";
865  valDefault = parmEntry->second.valMin;
866  if ( valDefault == 0. ) os << fixed << setprecision(1);
867  else if ( abs(valDefault) < 0.001) os << scientific << setprecision(4);
868  else if ( abs(valDefault) < 0.1 ) os << fixed << setprecision(7);
869  else if ( abs(valDefault) < 1000. ) os << fixed << setprecision(5);
870  else if ( abs(valDefault) < 1000000. ) os << fixed << setprecision(3);
871  else os << scientific << setprecision(4);
872  os << valDefault << "\">";
873  }
874  if (parmEntry->second.hasMax) {
875  os << " max=\"";
876  valDefault = parmEntry->second.valMax;
877  if ( valDefault == 0. ) os << fixed << setprecision(1);
878  else if ( abs(valDefault) < 0.001) os << scientific << setprecision(4);
879  else if ( abs(valDefault) < 0.1 ) os << fixed << setprecision(7);
880  else if ( abs(valDefault) < 1000. ) os << fixed << setprecision(5);
881  else if ( abs(valDefault) < 1000000. ) os << fixed << setprecision(3);
882  else os << scientific << setprecision(4);
883  os << valDefault << "\">";
884  }
885  os << "</parm>" << endl;
886  ++parmEntry;
887 
888  // Else check if word is next, and if so print it.
889  } else if ( wordEntry != words.end()
890  && ( fvecEntry == fvecs.end() || wordEntry->first < fvecEntry->first )
891  && ( mvecEntry == mvecs.end() || wordEntry->first < mvecEntry->first )
892  && ( pvecEntry == pvecs.end() || wordEntry->first < pvecEntry->first )
893  && ( wvecEntry == wvecs.end() || wordEntry->first < wvecEntry->first )
894  ) {
895  string valDefault = wordEntry->second.valDefault;
896  os << "<word name=\"" << wordEntry->second.name << "\" default=\""
897  << valDefault << "\"></word>" << endl;
898  ++wordEntry;
899 
900  // Else check if fvec is next, and if so print it.
901  } else if ( fvecEntry != fvecs.end()
902  && ( mvecEntry == mvecs.end() || fvecEntry->first < mvecEntry->first )
903  && ( pvecEntry == pvecs.end() || fvecEntry->first < pvecEntry->first )
904  && ( wvecEntry == wvecs.end() || fvecEntry->first < wvecEntry->first )
905  ) {
906  string state[2] = {"off", "on"};
907  vector<bool> valDefault = fvecEntry->second.valDefault;
908  os << "<fvec name=\"" << fvecEntry->second.name << "\" default={\"";
909  if (valDefault.size() > 0) {
910  for (vector<bool>::iterator val = valDefault.begin();
911  val != --valDefault.end(); ++val) os << state[*val] << ",";
912  os << state[*(--valDefault.end())] << "}\"></fvec>" << endl;
913  } else os << "}\"></fvec>" << endl;
914  ++fvecEntry;
915 
916  // Else check if mvec is next, and if so print it.
917  } else if ( mvecEntry != mvecs.end()
918  && ( pvecEntry == pvecs.end() || mvecEntry->first < pvecEntry->first )
919  && ( wvecEntry == wvecs.end() || mvecEntry->first < wvecEntry->first )
920  ) {
921  vector<int> valDefault = mvecEntry->second.valDefault;
922  os << "<mvec name=\"" << mvecEntry->second.name << "\" default={\"";
923  if (valDefault.size() > 0) {
924  for (vector<int>::iterator val = valDefault.begin();
925  val != --valDefault.end(); ++val) os << *val << ",";
926  os << *(--valDefault.end()) << "}\">";
927  } else os << "}\">";
928  if (mvecEntry->second.hasMin ) os << " min=\""
929  << mvecEntry->second.valMin << "\"";
930  if (mvecEntry->second.hasMax ) os << " max=\""
931  << mvecEntry->second.valMax << "\"";
932  os << "</mvec>" << endl;
933  ++mvecEntry;
934 
935  // Else check if pvec is next; print fixed or scientific.
936  } else if ( pvecEntry != pvecs.end()
937  && ( wvecEntry == wvecs.end() || pvecEntry->first < wvecEntry->first )
938  ) {
939  vector<double> valDefault = pvecEntry->second.valDefault;
940  os << "<pvec name=\"" << pvecEntry->second.name << "\" default={\"";
941  if (valDefault.size() > 0) {
942  for (vector<double>::iterator val = valDefault.begin();
943  val != --valDefault.end(); ++val) {
944  if ( *val == 0. ) os << fixed << setprecision(1);
945  else if ( abs(*val) < 0.001 ) os << scientific << setprecision(4);
946  else if ( abs(*val) < 0.1 ) os << fixed << setprecision(7);
947  else if ( abs(*val) < 1000. ) os << fixed << setprecision(5);
948  else if ( abs(*val) < 1000000. ) os << fixed << setprecision(3);
949  else os << scientific << setprecision(4);
950  os << *val << ",";
951  }
952  os << *(--valDefault.end()) << "}\">";
953  } else os << "}\">";
954  if (pvecEntry->second.hasMin ) {
955  double valLocal = pvecEntry->second.valMin;
956  os << " min=\"";
957  if ( valLocal == 0. ) os << fixed << setprecision(1);
958  else if ( abs(valLocal) < 0.001 ) os << scientific << setprecision(4);
959  else if ( abs(valLocal) < 0.1 ) os << fixed << setprecision(7);
960  else if ( abs(valLocal) < 1000. ) os << fixed << setprecision(5);
961  else if ( abs(valLocal) < 1000000. ) os << fixed << setprecision(3);
962  else os << scientific << setprecision(4);
963  os << valLocal << "\">";
964  }
965  if (pvecEntry->second.hasMax ) {
966  double valLocal = pvecEntry->second.valMax;
967  os << " max=\"";
968  if ( valLocal == 0. ) os << fixed << setprecision(1);
969  else if ( abs(valLocal) < 0.001 ) os << scientific << setprecision(4);
970  else if ( abs(valLocal) < 0.1 ) os << fixed << setprecision(7);
971  else if ( abs(valLocal) < 1000. ) os << fixed << setprecision(5);
972  else if ( abs(valLocal) < 1000000. ) os << fixed << setprecision(3);
973  else os << scientific << setprecision(4);
974  os << valLocal << "\">";
975  }
976  os << "</pvec>" << endl;
977  ++pvecEntry;
978 
979  // Else print wvec.
980  } else {
981  vector<string> valDefault = wvecEntry->second.valDefault;
982  os << "<wvec name=\"" << wvecEntry->second.name << "\" default={\"";
983  if (valDefault.size() > 0) {
984  for (vector<string>::iterator val = valDefault.begin();
985  val != --valDefault.end(); ++val) os << *val << ",";
986  os << *(--valDefault.end()) << "}\">";
987  } else os << "}\">";
988  os << "</wvec>" << endl;
989  ++wvecEntry;
990  }
991  } ;
992 
993  // Done.
994  return true;
995 }
996 
997 //--------------------------------------------------------------------------
998 
999 // Print out table of database in lexigraphical order.
1000 
1001 void Settings::list(bool doListAll, bool doListString, string match) {
1002 
1003  // Table header; output for bool as off/on.
1004  if (doListAll)
1005  cout << "\n *------- PYTHIA Flag + Mode + Parm + Word + FVec + MVec "
1006  << "+ PVec + WVec Settings (all) ---------------------------* \n";
1007  else if (!doListString)
1008  cout << "\n *------- PYTHIA Flag + Mode + Parm + Word + FVec + MVec "
1009  << "+ PVec + WVec Settings (changes only) ------------------* \n" ;
1010  else
1011  cout << "\n *------- PYTHIA Flag + Mode + Parm + Word + FVec + MVec "
1012  << "+ PVec + WVec Settings (with requested string) ----------* \n" ;
1013  cout << " | "
1014  << " | \n"
1015  << " | Name | "
1016  << " Now | Default Min Max | \n"
1017  << " | | "
1018  << " | | \n";
1019 
1020  // Convert input string to lowercase for match.
1021  toLowerRep(match);
1022  if (match == "") match = " ";
1023 
1024  // Iterators for the flag, mode and parm tables.
1025  map<string, Flag>::iterator flagEntry = flags.begin();
1026  map<string, Mode>::iterator modeEntry = modes.begin();
1027  map<string, Parm>::iterator parmEntry = parms.begin();
1028  map<string, Word>::iterator wordEntry = words.begin();
1029  map<string, FVec>::iterator fvecEntry = fvecs.begin();
1030  map<string, MVec>::iterator mvecEntry = mvecs.begin();
1031  map<string, PVec>::iterator pvecEntry = pvecs.begin();
1032  map<string, WVec>::iterator wvecEntry = wvecs.begin();
1033 
1034  // Loop while there is something left to do.
1035  while (flagEntry != flags.end() || modeEntry != modes.end()
1036  || parmEntry != parms.end() || wordEntry != words.end()
1037  || fvecEntry != fvecs.end() || mvecEntry != mvecs.end()
1038  || pvecEntry != pvecs.end() || wvecEntry != wvecs.end() ) {
1039 
1040  // Check if a flag is next in lexigraphical order; if so print it.
1041  if ( flagEntry != flags.end()
1042  && ( modeEntry == modes.end() || flagEntry->first < modeEntry->first )
1043  && ( parmEntry == parms.end() || flagEntry->first < parmEntry->first )
1044  && ( wordEntry == words.end() || flagEntry->first < wordEntry->first )
1045  && ( fvecEntry == fvecs.end() || flagEntry->first < fvecEntry->first )
1046  && ( mvecEntry == mvecs.end() || flagEntry->first < mvecEntry->first )
1047  && ( pvecEntry == pvecs.end() || flagEntry->first < pvecEntry->first )
1048  && ( wvecEntry == wvecs.end() || flagEntry->first < wvecEntry->first )
1049  ) {
1050  string state[2] = {"off", "on"};
1051  bool valNow = flagEntry->second.valNow;
1052  bool valDefault = flagEntry->second.valDefault;
1053  if ( doListAll || (!doListString && valNow != valDefault)
1054  || (doListString && flagEntry->first.find(match) != string::npos) )
1055  cout << " | " << setw(45) << left
1056  << flagEntry->second.name << " | " << setw(24) << right
1057  << state[valNow] << " | " << setw(12) << state[valDefault]
1058  << " | \n";
1059  ++flagEntry;
1060 
1061  // Else check if mode is next, and if so print it.
1062  } else if ( modeEntry != modes.end()
1063  && ( parmEntry == parms.end() || modeEntry->first < parmEntry->first )
1064  && ( wordEntry == words.end() || modeEntry->first < wordEntry->first )
1065  && ( fvecEntry == fvecs.end() || modeEntry->first < fvecEntry->first )
1066  && ( mvecEntry == mvecs.end() || modeEntry->first < mvecEntry->first )
1067  && ( pvecEntry == pvecs.end() || modeEntry->first < pvecEntry->first )
1068  && ( wvecEntry == wvecs.end() || modeEntry->first < wvecEntry->first )
1069  ) {
1070  int valNow = modeEntry->second.valNow;
1071  int valDefault = modeEntry->second.valDefault;
1072  if ( doListAll || (!doListString && valNow != valDefault)
1073  || (doListString && modeEntry->first.find(match) != string::npos) ) {
1074  cout << " | " << setw(45) << left
1075  << modeEntry->second.name << " | " << setw(24) << right
1076  << valNow << " | " << setw(12) << valDefault;
1077  if (modeEntry->second.hasMin)
1078  cout << setw(12) << modeEntry->second.valMin;
1079  else cout << " ";
1080  if (modeEntry->second.hasMax)
1081  cout << setw(12) << modeEntry->second.valMax;
1082  else cout << " ";
1083  cout << " | \n";
1084  }
1085  ++modeEntry;
1086 
1087  // Else check if parm is next, and if so print it; fixed or scientific.
1088  } else if ( parmEntry != parms.end()
1089  && ( wordEntry == words.end() || parmEntry->first < wordEntry->first )
1090  && ( fvecEntry == fvecs.end() || parmEntry->first < fvecEntry->first )
1091  && ( mvecEntry == mvecs.end() || parmEntry->first < mvecEntry->first )
1092  && ( pvecEntry == pvecs.end() || parmEntry->first < pvecEntry->first )
1093  && ( wvecEntry == wvecs.end() || parmEntry->first < wvecEntry->first )
1094  ) {
1095  double valNow = parmEntry->second.valNow;
1096  double valDefault = parmEntry->second.valDefault;
1097  if ( doListAll || (!doListString && valNow != valDefault )
1098  || (doListString && parmEntry->first.find(match) != string::npos) ) {
1099  cout << " | " << setw(45) << left
1100  << parmEntry->second.name << right << " | ";
1101  for (int i = 0; i < 4; ++i) {
1102  if (i == 1) valNow = valDefault;
1103  if (i == 2) valNow = parmEntry->second.valMin;
1104  if (i == 3) valNow = parmEntry->second.valMax;
1105  if ( (i == 2 && !parmEntry->second.hasMin)
1106  || (i == 3 && !parmEntry->second.hasMax) )
1107  cout << " ";
1108  else if ( valNow == 0. )
1109  cout << fixed << setprecision(1) << setw(12) << valNow;
1110  else if ( abs(valNow) < 0.001 )
1111  cout << scientific << setprecision(4) << setw(12) << valNow;
1112  else if ( abs(valNow) < 0.1 )
1113  cout << fixed << setprecision(7) << setw(12) << valNow;
1114  else if ( abs(valNow) < 1000. )
1115  cout << fixed << setprecision(5) << setw(12) << valNow;
1116  else if ( abs(valNow) < 1000000. )
1117  cout << fixed << setprecision(3) << setw(12) << valNow;
1118  else
1119  cout << scientific << setprecision(4) << setw(12) << valNow;
1120  if (i == 0) cout << " | ";
1121  }
1122  cout << " | \n";
1123  }
1124  ++parmEntry;
1125 
1126  // Else check if word is next, and if so print it.
1127  } else if ( wordEntry != words.end()
1128  && ( fvecEntry == fvecs.end() || wordEntry->first < fvecEntry->first )
1129  && ( mvecEntry == mvecs.end() || wordEntry->first < mvecEntry->first )
1130  && ( pvecEntry == pvecs.end() || wordEntry->first < pvecEntry->first )
1131  && ( wvecEntry == wvecs.end() || wordEntry->first < wvecEntry->first )
1132  ) {
1133  string valNow = wordEntry->second.valNow;
1134  string valDefault = wordEntry->second.valDefault;
1135  int blankLeft = max(0, 60 - max(24, int(valNow.length()) )
1136  - max(12, int(valDefault.length()) ) );
1137  string blankPad( blankLeft, ' ');
1138  if ( doListAll || (!doListString && valNow != valDefault)
1139  || (doListString && wordEntry->first.find(match) != string::npos) )
1140  cout << " | " << setw(45) << left
1141  << wordEntry->second.name << " | " << setw(24) << right
1142  << valNow << " | " << setw(12) << valDefault << blankPad
1143  << " | \n";
1144  ++wordEntry;
1145 
1146  // Else check if fvec is next, and if so print it.
1147  } else if ( fvecEntry != fvecs.end()
1148  && ( mvecEntry == mvecs.end() || fvecEntry->first < mvecEntry->first )
1149  && ( pvecEntry == pvecs.end() || fvecEntry->first < pvecEntry->first )
1150  && ( wvecEntry == wvecs.end() || fvecEntry->first < wvecEntry->first )
1151  ) {
1152  string state[2] = {"off", "on"};
1153  vector<bool> valsNow = fvecEntry->second.valNow;
1154  vector<bool> valsDefault = fvecEntry->second.valDefault;
1155  bool valNow(false), valDefault(false);
1156  if ( doListAll || (!doListString && valsNow != valsDefault )
1157  || (doListString && fvecEntry->first.find(match) != string::npos) ) {
1158  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
1159  ++i) {
1160  if ( i == 0 )
1161  cout << " | " << setw(45) << left
1162  << fvecEntry->second.name << right << " | ";
1163  else
1164  cout << " | " << setw(45) << " " << right << " | ";
1165  for (int j = 0; j < 4; ++j) {
1166  if (i < valsNow.size()) valNow = valsNow[i];
1167  if (i < valsDefault.size()) valDefault = valsDefault[i];
1168  if (j == 1) valNow = valDefault;
1169  if ( (j == 0 && i >= valsNow.size())
1170  || (j == 1 && i >= valsDefault.size()) || (j > 1) )
1171  cout << " ";
1172  else cout << setw(12) << state[valNow];
1173  if (j == 0) cout << " | ";
1174  }
1175  cout << " | \n";
1176  }
1177  }
1178  ++fvecEntry;
1179 
1180  // Else check if mvec is next, and if so print it.
1181  } else if ( mvecEntry != mvecs.end()
1182  && ( pvecEntry == pvecs.end() || mvecEntry->first < pvecEntry->first )
1183  && ( wvecEntry == wvecs.end() || mvecEntry->first < wvecEntry->first )
1184  ) {
1185  vector<int> valsNow = mvecEntry->second.valNow;
1186  vector<int> valsDefault = mvecEntry->second.valDefault;
1187  int valNow(0), valDefault(0);
1188  if ( doListAll || (!doListString && valsNow != valsDefault )
1189  || (doListString && mvecEntry->first.find(match) != string::npos) ) {
1190  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
1191  ++i) {
1192  if ( i == 0 )
1193  cout << " | " << setw(45) << left
1194  << mvecEntry->second.name << right << " | ";
1195  else
1196  cout << " | " << setw(45) << " " << right << " | ";
1197  for (int j = 0; j < 4; ++j) {
1198  if (i < valsNow.size()) valNow = valsNow[i];
1199  if (i < valsDefault.size()) valDefault = valsDefault[i];
1200  if (j == 1) valNow = valDefault;
1201  if (j == 2) valNow = mvecEntry->second.valMin;
1202  if (j == 3) valNow = mvecEntry->second.valMax;
1203  if ( (j == 0 && i >= valsNow.size())
1204  || (j == 1 && i >= valsDefault.size())
1205  || (j == 2 && !mvecEntry->second.hasMin)
1206  || (j == 3 && !mvecEntry->second.hasMax) )
1207  cout << " ";
1208  else cout << setw(12) << valNow;
1209  if (j == 0) cout << " | ";
1210  }
1211  cout << " | \n";
1212  }
1213  }
1214  ++mvecEntry;
1215 
1216  // Else check if pvec is next; print fixed or scientific.
1217  } else if ( pvecEntry != pvecs.end()
1218  && ( wvecEntry == wvecs.end() || pvecEntry->first < wvecEntry->first )
1219  ) {
1220  vector<double> valsNow = pvecEntry->second.valNow;
1221  vector<double> valsDefault = pvecEntry->second.valDefault;
1222  double valNow(0), valDefault(0);
1223  if ( doListAll || (!doListString && valsNow != valsDefault )
1224  || (doListString && pvecEntry->first.find(match) != string::npos) ) {
1225  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
1226  ++i) {
1227  if ( i == 0 )
1228  cout << " | " << setw(45) << left
1229  << pvecEntry->second.name << right << " | ";
1230  else
1231  cout << " | " << setw(45) << " " << right << " | ";
1232  for (int j = 0; j < 4; ++j) {
1233  if (i < valsNow.size()) valNow = valsNow[i];
1234  if (i < valsDefault.size()) valDefault = valsDefault[i];
1235  if (j == 1) valNow = valDefault;
1236  if (j == 2) valNow = pvecEntry->second.valMin;
1237  if (j == 3) valNow = pvecEntry->second.valMax;
1238  if ( (j == 0 && i >= valsNow.size())
1239  || (j == 1 && i >= valsDefault.size())
1240  || (j == 2 && !pvecEntry->second.hasMin)
1241  || (j == 3 && !pvecEntry->second.hasMax) )
1242  cout << " ";
1243  else if ( valNow == 0. )
1244  cout << fixed << setprecision(1) << setw(12) << valNow;
1245  else if ( abs(valNow) < 0.001 )
1246  cout << scientific << setprecision(4) << setw(12) << valNow;
1247  else if ( abs(valNow) < 0.1 )
1248  cout << fixed << setprecision(7) << setw(12) << valNow;
1249  else if ( abs(valNow) < 1000. )
1250  cout << fixed << setprecision(5) << setw(12) << valNow;
1251  else if ( abs(valNow) < 1000000. )
1252  cout << fixed << setprecision(3) << setw(12) << valNow;
1253  else
1254  cout << scientific << setprecision(4) << setw(12) << valNow;
1255  if (j == 0) cout << " | ";
1256  }
1257  cout << " | \n";
1258  }
1259  }
1260  ++pvecEntry;
1261 
1262  // Else print wvec.
1263  } else {
1264  vector<string> valsNow = wvecEntry->second.valNow;
1265  vector<string> valsDefault = wvecEntry->second.valDefault;
1266  if ( doListAll || (!doListString && valsNow != valsDefault )
1267  || (doListString && wvecEntry->first.find(match) != string::npos) ) {
1268  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
1269  ++i) {
1270  if ( i == 0 )
1271  cout << " | " << setw(45) << left
1272  << wvecEntry->second.name << right << " | ";
1273  else
1274  cout << " | " << setw(45) << " " << right << " | ";
1275  string valNow = (i < valsNow.size()) ? valsNow[i] : " ";
1276  string valDefault = (i < valsDefault.size()) ? valsDefault[i] : " ";
1277  int blankLeft = max(0, 60 - max(24, int(valNow.length()) )
1278  - max(12, int(valDefault.length()) ) );
1279  string blankPad( blankLeft, ' ');
1280  cout << setw(24) << right << valNow << " | " << setw(12)
1281  << valDefault << blankPad << " | \n";
1282  }
1283  }
1284  ++wvecEntry;
1285  }
1286  } ;
1287 
1288  // End of loop over database contents.
1289  cout << " | "
1290  << " | \n"
1291  << " *------- End PYTHIA Flag + Mode + Parm + Word + FVec + MVec "
1292  << "+ PVec + WVec Settings -----------------------------* " << endl;
1293 
1294 }
1295 
1296 //--------------------------------------------------------------------------
1297 
1298 // Give back current value(s) as a string, whatever the type.
1299 
1300 string Settings::output(string keyIn, bool fullLine) {
1301 
1302  // Default string echoes input key =.
1303  string outVal = (fullLine) ? " " + keyIn + " = " : "";
1304 
1305  // Identify flag, mode, parm or word, and convert to string.
1306  if (isFlag(keyIn)) {
1307  outVal += (flag(keyIn)) ? "true" : "false";
1308  } else if (isMode(keyIn)) {
1309  ostringstream ostr;
1310  ostr << mode(keyIn);
1311  outVal += ostr.str();
1312  } else if (isParm(keyIn)) {
1313  ostringstream ostr;
1314  ostr << scientific << setprecision(5) << parm(keyIn);
1315  outVal += ostr.str();
1316  } else if (isWord(keyIn)) {
1317  outVal += word(keyIn);
1318 
1319  // Identify fvec, mvec, pvec or wvec, and convert to string.
1320  } else if (isFVec(keyIn)) {
1321  vector<bool> outVec = fvec(keyIn);
1322  for (int i = 0; i < int(outVec.size()); ++i) {
1323  outVal += (outVec[i]) ? "true" : "false";
1324  if (i != int(outVec.size()) - 1) outVal += " ";
1325  }
1326  } else if (isMVec(keyIn)) {
1327  vector<int> outVec = mvec(keyIn);
1328  for (int i = 0; i < int(outVec.size()); ++i) {
1329  ostringstream ostr;
1330  ostr << outVec[i];
1331  outVal += ostr.str();
1332  if (i != int(outVec.size()) - 1) outVal += " ";
1333  }
1334  } else if (isPVec(keyIn)) {
1335  vector<double> outVec = pvec(keyIn);
1336  for (int i = 0; i < int(outVec.size()); ++i) {
1337  ostringstream ostr;
1338  ostr << scientific << setprecision(5) << outVec[i];
1339  outVal += ostr.str();
1340  if (i != int(outVec.size()) - 1) outVal += " ";
1341  }
1342  } else if (isWVec(keyIn)) {
1343  vector<string> outVec = wvec(keyIn);
1344  for (int i = 0; i < int(outVec.size()); ++i) {
1345  outVal += outVec[i];
1346  if (i != int(outVec.size()) - 1) outVal += " ";
1347  }
1348 
1349  // Default value, possible endline and done.
1350  } else outVal += "unknown";
1351  if (fullLine) outVal += "\n";
1352  return outVal;
1353 
1354 }
1355 
1356 //--------------------------------------------------------------------------
1357 
1358 // Reset all values to their defaults.
1359 
1360 void Settings::resetAll() {
1361 
1362  // Loop through the flags table, resetting all entries.
1363  for (map<string, Flag>::iterator flagEntry = flags.begin();
1364  flagEntry != flags.end(); ++flagEntry) {
1365  string name = flagEntry->first;
1366  resetFlag(name);
1367  }
1368 
1369  // Loop through the modes table, resetting all entries.
1370  for (map<string, Mode>::iterator modeEntry = modes.begin();
1371  modeEntry != modes.end(); ++modeEntry) {
1372  string name = modeEntry->first;
1373  resetMode(name);
1374  }
1375 
1376  // Loop through the parms table, resetting all entries.
1377  for (map<string, Parm>::iterator parmEntry = parms.begin();
1378  parmEntry != parms.end(); ++parmEntry) {
1379  string name = parmEntry->first;
1380  resetParm(name);
1381  }
1382 
1383  // Loop through the words table, resetting all entries.
1384  for (map<string, Word>::iterator wordEntry = words.begin();
1385  wordEntry != words.end(); ++wordEntry) {
1386  string name = wordEntry->first;
1387  resetWord(name);
1388  }
1389 
1390  // Loop through the fvecs table, resetting all entries.
1391  for (map<string, FVec>::iterator fvecEntry = fvecs.begin();
1392  fvecEntry != fvecs.end(); ++fvecEntry) {
1393  string name = fvecEntry->first;
1394  resetFVec(name);
1395  }
1396 
1397  // Loop through the mvecs table, resetting all entries.
1398  for (map<string, MVec>::iterator mvecEntry = mvecs.begin();
1399  mvecEntry != mvecs.end(); ++mvecEntry) {
1400  string name = mvecEntry->first;
1401  resetMVec(name);
1402  }
1403 
1404  // Loop through the pvecs table, resetting all entries.
1405  for (map<string, PVec>::iterator pvecEntry = pvecs.begin();
1406  pvecEntry != pvecs.end(); ++pvecEntry) {
1407  string name = pvecEntry->first;
1408  resetPVec(name);
1409  }
1410 
1411  // Loop through the wvecs table, resetting all entries.
1412  for (map<string, WVec>::iterator wvecEntry = wvecs.begin();
1413  wvecEntry != wvecs.end(); ++wvecEntry) {
1414  string name = wvecEntry->first;
1415  resetWVec(name);
1416  }
1417 
1418 }
1419 
1420 //--------------------------------------------------------------------------
1421 
1422 // Give back current value, with check that key exists.
1423 
1424 bool Settings::flag(string keyIn) {
1425  if (isFlag(keyIn)) return flags[toLower(keyIn)].valNow;
1426  infoPtr->errorMsg("Error in Settings::flag: unknown key", keyIn);
1427  return false;
1428 }
1429 
1430 int Settings::mode(string keyIn) {
1431  if (isMode(keyIn)) return modes[toLower(keyIn)].valNow;
1432  infoPtr->errorMsg("Error in Settings::mode: unknown key", keyIn);
1433  return 0;
1434 }
1435 
1436 double Settings::parm(string keyIn) {
1437  if (isParm(keyIn)) return parms[toLower(keyIn)].valNow;
1438  infoPtr->errorMsg("Error in Settings::parm: unknown key", keyIn);
1439  return 0.;
1440 }
1441 
1442 string Settings::word(string keyIn) {
1443  if (isWord(keyIn)) return words[toLower(keyIn)].valNow;
1444  infoPtr->errorMsg("Error in Settings::word: unknown key", keyIn);
1445  return " ";
1446 }
1447 
1448 vector<bool> Settings::fvec(string keyIn) {
1449  if (isFVec(keyIn)) return fvecs[toLower(keyIn)].valNow;
1450  infoPtr->errorMsg("Error in Settings::fvec: unknown key", keyIn);
1451  return vector<bool>(1, false);
1452 }
1453 
1454 vector<int> Settings::mvec(string keyIn) {
1455  if (isMVec(keyIn)) return mvecs[toLower(keyIn)].valNow;
1456  infoPtr->errorMsg("Error in Settings::mvec: unknown key", keyIn);
1457  return vector<int>(1, 0);
1458 }
1459 
1460 vector<double> Settings::pvec(string keyIn) {
1461  if (isPVec(keyIn)) return pvecs[toLower(keyIn)].valNow;
1462  infoPtr->errorMsg("Error in Settings::pvec: unknown key", keyIn);
1463  return vector<double>(1, 0.);
1464 }
1465 
1466 vector<string> Settings::wvec(string keyIn) {
1467  if (isWVec(keyIn)) return wvecs[toLower(keyIn)].valNow;
1468  infoPtr->errorMsg("Error in Settings::wvec: unknown key", keyIn);
1469  return vector<string>(1, " ");
1470 }
1471 
1472 //--------------------------------------------------------------------------
1473 
1474 // Give back default value, with check that key exists.
1475 
1476 bool Settings::flagDefault(string keyIn) {
1477  if (isFlag(keyIn)) return flags[toLower(keyIn)].valDefault;
1478  infoPtr->errorMsg("Error in Settings::flagDefault: unknown key", keyIn);
1479  return false;
1480 }
1481 
1482 int Settings::modeDefault(string keyIn) {
1483  if (isMode(keyIn)) return modes[toLower(keyIn)].valDefault;
1484  infoPtr->errorMsg("Error in Settings::modeDefault: unknown key", keyIn);
1485  return 0;
1486 }
1487 
1488 double Settings::parmDefault(string keyIn) {
1489  if (isParm(keyIn)) return parms[toLower(keyIn)].valDefault;
1490  infoPtr->errorMsg("Error in Settings::parmDefault: unknown key", keyIn);
1491  return 0.;
1492 }
1493 
1494 string Settings::wordDefault(string keyIn) {
1495  if (isWord(keyIn)) return words[toLower(keyIn)].valDefault;
1496  infoPtr->errorMsg("Error in Settings::wordDefault: unknown key", keyIn);
1497  return " ";
1498 }
1499 
1500 vector<bool> Settings::fvecDefault(string keyIn) {
1501  if (isFVec(keyIn)) return fvecs[toLower(keyIn)].valDefault;
1502  infoPtr->errorMsg("Error in Settings::fvecDefault: unknown key", keyIn);
1503  return vector<bool>(1, false);
1504 }
1505 
1506 vector<int> Settings::mvecDefault(string keyIn) {
1507  if (isMVec(keyIn)) return mvecs[toLower(keyIn)].valDefault;
1508  infoPtr->errorMsg("Error in Settings::mvecDefault: unknown key", keyIn);
1509  return vector<int>(1, 0);
1510 }
1511 
1512 vector<double> Settings::pvecDefault(string keyIn) {
1513  if (isPVec(keyIn)) return pvecs[toLower(keyIn)].valDefault;
1514  infoPtr->errorMsg("Error in Settings::pvecDefault: unknown key", keyIn);
1515  return vector<double>(1, 0.);
1516 }
1517 
1518 vector<string> Settings::wvecDefault(string keyIn) {
1519  if (isWVec(keyIn)) return wvecs[toLower(keyIn)].valDefault;
1520  infoPtr->errorMsg("Error in Settings::wvecDefault: unknown key", keyIn);
1521  return vector<string>(1, " ");
1522 }
1523 
1524 //--------------------------------------------------------------------------
1525 
1526 // Get a map of entries whose names contain the string "match".
1527 
1528 map<string, Flag> Settings::getFlagMap(string match) {
1529  // Make the match string lower case. Start with an empty map.
1530  toLowerRep(match);
1531  map<string, Flag> flagMap;
1532  // Loop over the flag map (using iterator).
1533  for (map<string,Flag>::iterator flagEntry = flags.begin();
1534  flagEntry != flags.end(); ++flagEntry)
1535  if (flagEntry->first.find(match) != string::npos)
1536  flagMap[flagEntry->first] = flagEntry->second;
1537  return flagMap;
1538 }
1539 
1540 map<string, Mode> Settings::getModeMap(string match) {
1541  // Make the match string lower case. Start with an empty map.
1542  toLowerRep(match);
1543  map<string, Mode> modeMap;
1544  // Loop over the mode map (using iterator).
1545  for (map<string,Mode>::iterator modeEntry = modes.begin();
1546  modeEntry != modes.end(); ++modeEntry)
1547  if (modeEntry->first.find(match) != string::npos)
1548  modeMap[modeEntry->first] = modeEntry->second;
1549  return modeMap;
1550 }
1551 
1552 map<string, Parm> Settings::getParmMap(string match) {
1553  // Make the match string lower case. Start with an empty map.
1554  toLowerRep(match);
1555  map<string, Parm> parmMap;
1556  // Loop over the parm map (using iterator).
1557  for (map<string,Parm>::iterator parmEntry = parms.begin();
1558  parmEntry != parms.end(); ++parmEntry)
1559  if (parmEntry->first.find(match) != string::npos)
1560  parmMap[parmEntry->first] = parmEntry->second;
1561  return parmMap;
1562 }
1563 
1564 map<string, Word> Settings::getWordMap(string match) {
1565  // Make the match string lower case. Start with an empty map.
1566  toLowerRep(match);
1567  map<string, Word> wordMap;
1568  // Loop over the word map (using iterator).
1569  for (map<string,Word>::iterator wordEntry = words.begin();
1570  wordEntry != words.end(); ++wordEntry)
1571  if (wordEntry->first.find(match) != string::npos)
1572  wordMap[wordEntry->first] = wordEntry->second;
1573  return wordMap;
1574 }
1575 
1576 map<string, FVec> Settings::getFVecMap(string match) {
1577  // Make the match string lower case. Start with an empty map.
1578  toLowerRep(match);
1579  map<string, FVec> fvecMap;
1580  // Loop over the fvec map (using iterator).
1581  for (map<string,FVec>::iterator fvecEntry = fvecs.begin();
1582  fvecEntry != fvecs.end(); ++fvecEntry)
1583  if (fvecEntry->first.find(match) != string::npos)
1584  fvecMap[fvecEntry->first] = fvecEntry->second;
1585  return fvecMap;
1586 }
1587 
1588 map<string, MVec> Settings::getMVecMap(string match) {
1589  // Make the match string lower case. Start with an empty map.
1590  toLowerRep(match);
1591  map<string, MVec> mvecMap;
1592  // Loop over the mvec map (using iterator).
1593  for (map<string,MVec>::iterator mvecEntry = mvecs.begin();
1594  mvecEntry != mvecs.end(); ++mvecEntry)
1595  if (mvecEntry->first.find(match) != string::npos)
1596  mvecMap[mvecEntry->first] = mvecEntry->second;
1597  return mvecMap;
1598 }
1599 
1600 map<string, PVec> Settings::getPVecMap(string match) {
1601  // Make the match string lower case. Start with an empty map.
1602  toLowerRep(match);
1603  map<string, PVec> pvecMap;
1604  // Loop over the pvec map (using iterator).
1605  for (map<string,PVec>::iterator pvecEntry = pvecs.begin();
1606  pvecEntry != pvecs.end(); ++pvecEntry)
1607  if (pvecEntry->first.find(match) != string::npos)
1608  pvecMap[pvecEntry->first] = pvecEntry->second;
1609  return pvecMap;
1610 }
1611 
1612 map<string, WVec> Settings::getWVecMap(string match) {
1613  // Make the match string lower case. Start with an empty map.
1614  toLowerRep(match);
1615  map<string, WVec> wvecMap;
1616  // Loop over the wvec map (using iterator).
1617  for (map<string,WVec>::iterator wvecEntry = wvecs.begin();
1618  wvecEntry != wvecs.end(); ++wvecEntry)
1619  if (wvecEntry->first.find(match) != string::npos)
1620  wvecMap[wvecEntry->first] = wvecEntry->second;
1621  return wvecMap;
1622 }
1623 
1624 //--------------------------------------------------------------------------
1625 
1626 // Change current value. Respect limits unless force==true.
1627 // If key not recognised, add new key if force==true, otherwise ignore.
1628 
1629 void Settings::flag(string keyIn, bool nowIn, bool force) {
1630  string keyLower = toLower(keyIn);
1631  if (isFlag(keyIn)) flags[keyLower].valNow = nowIn;
1632  else if (force) addFlag( keyIn, nowIn);
1633  // Print:quiet triggers a whole set of changes.
1634  if (keyLower == "print:quiet") printQuiet( nowIn);
1635 }
1636 
1637 bool Settings::mode(string keyIn, int nowIn, bool force) {
1638  if (isMode(keyIn)) {
1639  string keyLower = toLower(keyIn);
1640  Mode& modeNow = modes[keyLower];
1641  // For modepick and modefix fail if values are outside range.
1642  if (!force && modeNow.optOnly
1643  && (nowIn < modeNow.valMin || nowIn > modeNow.valMax) ) return false;
1644  if (!force && modeNow.hasMin && nowIn < modeNow.valMin)
1645  modeNow.valNow = modeNow.valMin;
1646  else if (!force && modeNow.hasMax && nowIn > modeNow.valMax)
1647  modeNow.valNow = modeNow.valMax;
1648  else modeNow.valNow = nowIn;
1649  // Tune:ee and Tune:pp each trigger a whole set of changes.
1650  if (keyLower == "tune:ee") initTuneEE( modeNow.valNow);
1651  if (keyLower == "tune:pp") initTunePP( modeNow.valNow);
1652  }
1653  else if (force) {
1654  addMode(keyIn, nowIn, false, false, 0, 0);
1655  }
1656  return true;
1657 }
1658 
1659 void Settings::parm(string keyIn, double nowIn, bool force) {
1660  if (isParm(keyIn)) {
1661  Parm& parmNow = parms[toLower(keyIn)];
1662  if (!force && parmNow.hasMin && nowIn < parmNow.valMin)
1663  parmNow.valNow = parmNow.valMin;
1664  else if (!force && parmNow.hasMax && nowIn > parmNow.valMax)
1665  parmNow.valNow = parmNow.valMax;
1666  else parmNow.valNow = nowIn;
1667  }
1668  else if (force) {
1669  addParm(keyIn, nowIn, false, false, 0., 0.);
1670  }
1671 }
1672 
1673 void Settings::word(string keyIn, string nowIn, bool force) {
1674  if (isWord(keyIn)) words[toLower(keyIn)].valNow = nowIn;
1675  else if (force) addWord(keyIn, nowIn);
1676 }
1677 
1678 void Settings::fvec(string keyIn, vector<bool> nowIn, bool force) {
1679  if (isFVec(keyIn)) {
1680  FVec& fvecNow = fvecs[toLower(keyIn)];
1681  fvecNow.valNow.clear();
1682  for (vector<bool>::iterator now = nowIn.begin();
1683  now != nowIn.end(); now++)
1684  fvecNow.valNow.push_back(*now);
1685  }
1686  else if (force) addFVec(keyIn, nowIn);
1687 }
1688 
1689 void Settings::mvec(string keyIn, vector<int> nowIn, bool force) {
1690  if (isMVec(keyIn)) {
1691  MVec& mvecNow = mvecs[toLower(keyIn)];
1692  mvecNow.valNow.clear();
1693  for (vector<int>::iterator now = nowIn.begin();
1694  now != nowIn.end(); now++) {
1695  if (!force && mvecNow.hasMin && *now < mvecNow.valMin)
1696  mvecNow.valNow.push_back(mvecNow.valMin);
1697  else if (!force && mvecNow.hasMax && *now > mvecNow.valMax)
1698  mvecNow.valNow.push_back(mvecNow.valMax);
1699  else mvecNow.valNow.push_back(*now);
1700  }
1701  }
1702  else if (force) addMVec(keyIn, nowIn, false, false, 0, 0);
1703 }
1704 
1705 void Settings::pvec(string keyIn, vector<double> nowIn, bool force) {
1706  if (isPVec(keyIn)) {
1707  PVec& pvecNow = pvecs[toLower(keyIn)];
1708  pvecNow.valNow.clear();
1709  for (vector<double>::iterator now = nowIn.begin();
1710  now != nowIn.end(); now++) {
1711  if (!force && pvecNow.hasMin && *now < pvecNow.valMin)
1712  pvecNow.valNow.push_back(pvecNow.valMin);
1713  else if (!force && pvecNow.hasMax && *now > pvecNow.valMax)
1714  pvecNow.valNow.push_back(pvecNow.valMax);
1715  else pvecNow.valNow.push_back(*now);
1716  }
1717  }
1718  else if (force) addPVec(keyIn, nowIn, false, false, 0., 0.);
1719 }
1720 
1721 void Settings::wvec(string keyIn, vector<string> nowIn, bool force) {
1722  if (isWVec(keyIn)) {
1723  WVec& wvecNow = wvecs[toLower(keyIn)];
1724  wvecNow.valNow.clear();
1725  for (vector<string>::iterator now = nowIn.begin();
1726  now != nowIn.end(); now++)
1727  wvecNow.valNow.push_back(*now);
1728  }
1729  else if (force) addWVec(keyIn, nowIn);
1730 }
1731 
1732 //--------------------------------------------------------------------------
1733 
1734 // Restore current value to default.
1735 
1736 void Settings::resetFlag(string keyIn) {
1737  if (isFlag(keyIn)) flags[toLower(keyIn)].valNow
1738  = flags[toLower(keyIn)].valDefault ;
1739 }
1740 
1741 void Settings::resetMode(string keyIn) {
1742  string keyLower = toLower(keyIn);
1743  if (isMode(keyIn)) modes[keyLower].valNow
1744  = modes[toLower(keyIn)].valDefault ;
1745  // For Tune:ee and Tune:pp must also restore variables involved in tunes.
1746  if (keyLower == "tune:ee") resetTuneEE();
1747  if (keyLower == "tune:pp") resetTunePP();
1748 }
1749 
1750 void Settings::resetParm(string keyIn) {
1751  if (isParm(keyIn)) parms[toLower(keyIn)].valNow
1752  = parms[toLower(keyIn)].valDefault ;
1753 }
1754 
1755 void Settings::resetWord(string keyIn) {
1756  if (isWord(keyIn)) words[toLower(keyIn)].valNow
1757  = words[toLower(keyIn)].valDefault ;
1758 }
1759 
1760 void Settings::resetFVec(string keyIn) {
1761  if (isFVec(keyIn)) fvecs[toLower(keyIn)].valNow
1762  = fvecs[toLower(keyIn)].valDefault ;
1763 }
1764 
1765 void Settings::resetMVec(string keyIn) {
1766  if (isMVec(keyIn)) mvecs[toLower(keyIn)].valNow
1767  = mvecs[toLower(keyIn)].valDefault ;
1768 }
1769 
1770 void Settings::resetPVec(string keyIn) {
1771  if (isPVec(keyIn)) pvecs[toLower(keyIn)].valNow
1772  = pvecs[toLower(keyIn)].valDefault ;
1773 }
1774 
1775 void Settings::resetWVec(string keyIn) {
1776  if (isWVec(keyIn)) wvecs[toLower(keyIn)].valNow
1777  = wvecs[toLower(keyIn)].valDefault ;
1778 }
1779 
1780 //--------------------------------------------------------------------------
1781 
1782 // Check whether any other processes than SoftQCD and LowEnergyQCD are
1783 // switched on. Note that Les Houches input has to be checked separately.
1784 
1785 bool Settings::hasHardProc() {
1786 
1787  // List of (most?) process name groups, in lowercase. Special cases.
1788  string flagList[26] = { "hardqcd", "promptphoton", "weakbosonexchange",
1789  "weaksingleboson", "weakdoubleboson", "weakbosonandparton",
1790  "photoncollision", "photonparton", "onia:all", "charmonium:all",
1791  "bottomonium:all", "top", "fourthbottom", "fourthtop", "fourthpair",
1792  "higgssm", "higgsbsm", "susy", "newgaugeboson", "leftrightsymmetry",
1793  "leptoquark", "excitedfermion", "contactinteractions", "hiddenvalley",
1794  "extradimensions", "dm:" };
1795  int sizeList = 26;
1796  string flagExclude[2] = { "extradimensionsg*:vlvl", "higgssm:nlowidths"};
1797  int sizeExclude = 2;
1798 
1799  // Loop over the flag map (using iterator), and process names.
1800  for (map<string,Flag>::iterator flagEntry = flags.begin();
1801  flagEntry != flags.end(); ++flagEntry) {
1802  string flagName = flagEntry->first;
1803  bool doExclude = false;
1804  for (int i = 0; i < sizeExclude; ++i)
1805  if (flagName.find( flagExclude[i]) != string::npos) doExclude = true;
1806  if (doExclude) continue;
1807  for (int i = 0; i < sizeList; ++i)
1808  if (flagName.find( flagList[i]) != string::npos
1809  && flagEntry->second.valNow == true) return true;
1810  }
1811 
1812  // Done without having found a non-SoftQCD/LowEnergyQCD process on.
1813  return false;
1814 
1815 }
1816 
1817 //--------------------------------------------------------------------------
1818 
1819 // Regulate level of printout by overall change of settings.
1820 
1821 void Settings::printQuiet(bool quiet) {
1822 
1823  // Switch off as much output as possible.
1824  if (quiet) {
1825  flag("Init:showProcesses", false );
1826  flag("Init:showMultipartonInteractions", false );
1827  flag("Init:showChangedSettings", false );
1828  flag("Init:showAllSettings", false );
1829  flag("Init:showChangedParticleData", false );
1830  flag("Init:showChangedResonanceData", false );
1831  flag("Init:showAllParticleData", false );
1832  mode("Init:showOneParticleData", 0 );
1833  mode("Next:numberCount", 0 );
1834  mode("Next:numberShowLHA", 0 );
1835  mode("Next:numberShowInfo", 0 );
1836  mode("Next:numberShowProcess", 0 );
1837  mode("Next:numberShowEvent", 0 );
1838 
1839  // Restore ouput settings to default.
1840  } else {
1841  resetFlag("Init:showProcesses");
1842  resetFlag("Init:showMultipartonInteractions");
1843  resetFlag("Init:showChangedSettings");
1844  resetFlag("Init:showAllSettings");
1845  resetFlag("Init:showChangedParticleData");
1846  resetFlag("Init:showChangedResonanceData");
1847  resetFlag("Init:showAllParticleData");
1848  resetMode("Init:showOneParticleData");
1849  resetMode("Next:numberCount");
1850  resetMode("Next:numberShowLHA");
1851  resetMode("Next:numberShowInfo");
1852  resetMode("Next:numberShowProcess");
1853  resetMode("Next:numberShowEvent");
1854  }
1855 
1856 }
1857 
1858 //--------------------------------------------------------------------------
1859 
1860 // Restore all e+e- settings to their original values.
1861 
1862 void Settings::resetTuneEE() {
1863 
1864  // Flavour composition.
1865  resetParm("StringFlav:probStoUD");
1866  resetParm("StringFlav:probQQtoQ");
1867  resetParm("StringFlav:probSQtoQQ");
1868  resetParm("StringFlav:probQQ1toQQ0");
1869  resetParm("StringFlav:mesonUDvector");
1870  resetParm("StringFlav:mesonSvector");
1871  resetParm("StringFlav:mesonCvector");
1872  resetParm("StringFlav:mesonBvector");
1873  resetParm("StringFlav:etaSup");
1874  resetParm("StringFlav:etaPrimeSup");
1875  resetParm("StringFlav:popcornSpair");
1876  resetParm("StringFlav:popcornSmeson");
1877  resetFlag("StringFlav:suppressLeadingB");
1878 
1879  // String breaks: z.
1880  resetParm("StringZ:aLund");
1881  resetParm("StringZ:bLund");
1882  resetParm("StringZ:aExtraSquark");
1883  resetParm("StringZ:aExtraDiquark");
1884  resetParm("StringZ:rFactC");
1885  resetParm("StringZ:rFactB");
1886 
1887  // String breaks: pT.
1888  resetParm("StringPT:sigma");
1889  resetParm("StringPT:enhancedFraction");
1890  resetParm("StringPT:enhancedWidth");
1891 
1892  // FSR: strong coupling, IR cutoff.
1893  resetParm("TimeShower:alphaSvalue");
1894  resetMode("TimeShower:alphaSorder");
1895  resetFlag("TimeShower:alphaSuseCMW");
1896  resetParm("TimeShower:pTmin");
1897  resetParm("TimeShower:pTminChgQ");
1898 
1899 }
1900 
1901 //--------------------------------------------------------------------------
1902 
1903 // Restore all pp settings to their original values.
1904 
1905 void Settings::resetTunePP() {
1906 
1907  // PDF set.
1908  resetWord("PDF:pSet");
1909 
1910  // Hard matrix elements alpha_s value.
1911  resetParm("SigmaProcess:alphaSvalue");
1912 
1913  // Diffraction: cross sections and mass distributions.
1914  resetFlag("SigmaTotal:zeroAXB");
1915  resetFlag("SigmaDiffractive:dampen");
1916  resetParm("SigmaDiffractive:maxXB");
1917  resetParm("SigmaDiffractive:maxAX");
1918  resetParm("SigmaDiffractive:maxXX");
1919  resetParm("Diffraction:largeMassSuppress");
1920 
1921  // FSR: dipoles to beam, spin correlations.
1922  resetFlag("TimeShower:dampenBeamRecoil");
1923  resetFlag("TimeShower:phiPolAsym");
1924 
1925  // ISR: strong coupling, IR cutoff, coherence and spin correlations.
1926  resetParm("SpaceShower:alphaSvalue");
1927  resetMode("SpaceShower:alphaSorder");
1928  resetParm("SpaceShower:alphaSuseCMW");
1929  resetFlag("SpaceShower:samePTasMPI");
1930  resetParm("SpaceShower:pT0Ref");
1931  resetParm("SpaceShower:ecmRef");
1932  resetParm("SpaceShower:ecmPow");
1933  resetParm("SpaceShower:pTmaxFudge");
1934  resetParm("SpaceShower:pTdampFudge");
1935  resetFlag("SpaceShower:rapidityOrder");
1936  resetFlag("SpaceShower:rapidityOrderMPI");
1937  resetFlag("SpaceShower:phiPolAsym");
1938  resetFlag("SpaceShower:phiIntAsym");
1939 
1940  // MPI: strong coupling, IR regularization, energy scaling.
1941  resetParm("MultipartonInteractions:alphaSvalue");
1942  resetParm("MultipartonInteractions:pT0Ref");
1943  resetParm("MultipartonInteractions:ecmRef");
1944  resetParm("MultipartonInteractions:ecmPow");
1945  resetMode("MultipartonInteractions:bProfile");
1946  resetParm("MultipartonInteractions:expPow");
1947  resetParm("MultipartonInteractions:a1");
1948 
1949  // Beam remnant parameters.
1950  resetParm("BeamRemnants:primordialKTsoft");
1951  resetParm("BeamRemnants:primordialKThard");
1952  resetParm("BeamRemnants:halfScaleForKT");
1953  resetParm("BeamRemnants:halfMassForKT");
1954 
1955  // Colour reconnection parameters.
1956  resetMode("ColourReconnection:mode");
1957  resetParm("ColourReconnection:range");
1958 
1959 }
1960 
1961 //--------------------------------------------------------------------------
1962 
1963 // Set the values related to a tune of e+e- data,
1964 // i.e. mainly for final-state radiation and hadronization.
1965 
1966 void Settings::initTuneEE( int eeTune) {
1967 
1968  // Do nothing for tune 0.
1969  if (eeTune == 0) return;
1970 
1971  // Restore all e+e- settings to their original values.
1972  // Is first step for setting up a specific tune.
1973  resetTuneEE();
1974 
1975  // Old flavour and FSR defaults carried over from very old JETSET tune,
1976  // only with alphaS roughly tuned for "new" pT-ordered shower.
1977  if (eeTune == 1) {
1978  parm("StringFlav:probStoUD", 0.30 );
1979  parm("StringFlav:probQQtoQ", 0.10 );
1980  parm("StringFlav:probSQtoQQ", 0.40 );
1981  parm("StringFlav:probQQ1toQQ0", 0.05 );
1982  parm("StringFlav:mesonUDvector", 1.00 );
1983  parm("StringFlav:mesonSvector", 1.50 );
1984  parm("StringFlav:mesonCvector", 2.50 );
1985  parm("StringFlav:mesonBvector", 3.00 );
1986  parm("StringFlav:etaSup", 1.00 );
1987  parm("StringFlav:etaPrimeSup", 0.40 );
1988  parm("StringFlav:popcornSpair", 0.50 );
1989  parm("StringFlav:popcornSmeson", 0.50 );
1990  flag("StringFlav:suppressLeadingB", false );
1991  parm("StringZ:aLund", 0.30 );
1992  parm("StringZ:bLund", 0.58 );
1993  parm("StringZ:aExtraSquark", 0.00 );
1994  parm("StringZ:aExtraDiquark", 0.50 );
1995  parm("StringZ:rFactC", 1.00 );
1996  parm("StringZ:rFactB", 1.00 );
1997  parm("StringPT:sigma", 0.36 );
1998  parm("StringPT:enhancedFraction", 0.01 );
1999  parm("StringPT:enhancedWidth", 2.0 );
2000  parm("TimeShower:alphaSvalue", 0.137 );
2001  mode("TimeShower:alphaSorder", 1 );
2002  flag("TimeShower:alphaSuseCMW", false );
2003  parm("TimeShower:pTmin", 0.5 );
2004  parm("TimeShower:pTminChgQ", 0.5 );
2005  }
2006 
2007  // Marc Montull's tune to particle composition at LEP1 (August 2007).
2008  else if (eeTune == 2) {
2009  parm("StringFlav:probStoUD", 0.22 );
2010  parm("StringFlav:probQQtoQ", 0.08 );
2011  parm("StringFlav:probSQtoQQ", 0.75 );
2012  parm("StringFlav:probQQ1toQQ0", 0.025 );
2013  parm("StringFlav:mesonUDvector", 0.5 );
2014  parm("StringFlav:mesonSvector", 0.6 );
2015  parm("StringFlav:mesonCvector", 1.5 );
2016  parm("StringFlav:mesonBvector", 2.5 );
2017  parm("StringFlav:etaSup", 0.60 );
2018  parm("StringFlav:etaPrimeSup", 0.15 );
2019  parm("StringFlav:popcornSpair", 1.0 );
2020  parm("StringFlav:popcornSmeson", 1.0 );
2021  flag("StringFlav:suppressLeadingB", false ); // kept fixed
2022  parm("StringZ:aLund", 0.76 );
2023  parm("StringZ:bLund", 0.58 ); // kept fixed
2024  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
2025  parm("StringZ:aExtraDiquark", 0.50 ); // kept fixed
2026  parm("StringZ:rFactC", 1.00 ); // kept fixed
2027  parm("StringZ:rFactB", 1.00 ); // kept fixed
2028  parm("StringPT:sigma", 0.36 ); // kept fixed
2029  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
2030  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
2031  parm("TimeShower:alphaSvalue", 0.137 ); // kept fixed
2032  mode("TimeShower:alphaSorder", 1 ); // kept fixed
2033  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
2034  parm("TimeShower:pTmin", 0.5 ); // kept fixed
2035  parm("TimeShower:pTminChgQ", 0.5 ); // kept fixed
2036  }
2037 
2038  // Full e+e- tune of flavours and FSR to LEP1 data within the
2039  // Rivet + Professor framework, by Hendrik Hoeth (June 2009).
2040  else if (eeTune == 3) {
2041  parm("StringFlav:probStoUD", 0.19 );
2042  parm("StringFlav:probQQtoQ", 0.09 );
2043  parm("StringFlav:probSQtoQQ", 1.00 );
2044  parm("StringFlav:probQQ1toQQ0", 0.027 );
2045  parm("StringFlav:mesonUDvector", 0.62 );
2046  parm("StringFlav:mesonSvector", 0.725 );
2047  parm("StringFlav:mesonCvector", 1.06 );
2048  parm("StringFlav:mesonBvector", 3.0 );
2049  parm("StringFlav:etaSup", 0.63 );
2050  parm("StringFlav:etaPrimeSup", 0.12 );
2051  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
2052  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
2053  flag("StringFlav:suppressLeadingB", false ); // kept fixed
2054  parm("StringZ:aLund", 0.3 ); // kept fixed
2055  parm("StringZ:bLund", 0.8 );
2056  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
2057  parm("StringZ:aExtraDiquark", 0.50 ); // kept fixed
2058  parm("StringZ:rFactC", 1.00 ); // kept fixed
2059  parm("StringZ:rFactB", 0.67 );
2060  parm("StringPT:sigma", 0.304 );
2061  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
2062  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
2063  parm("TimeShower:alphaSvalue", 0.1383);
2064  mode("TimeShower:alphaSorder", 1 ); // kept fixed
2065  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
2066  parm("TimeShower:pTmin", 0.4 ); // kept fixed (near limit)
2067  parm("TimeShower:pTminChgQ", 0.4 ); // kept same as pTmin
2068  }
2069 
2070  // Full e+e- tune of flavours and FSR to LEP1 data, by Peter Skands
2071  // (September 2013). Note use of CMW convention for shower.
2072  else if (eeTune == 4) {
2073  parm("StringFlav:probStoUD", 0.21 );
2074  parm("StringFlav:probQQtoQ", 0.086 );
2075  parm("StringFlav:probSQtoQQ", 1.00 );
2076  parm("StringFlav:probQQ1toQQ0", 0.031 );
2077  parm("StringFlav:mesonUDvector", 0.45 );
2078  parm("StringFlav:mesonSvector", 0.60 );
2079  parm("StringFlav:mesonCvector", 0.95 );
2080  parm("StringFlav:mesonBvector", 3.0 ); // kept fixed
2081  parm("StringFlav:etaSup", 0.65 );
2082  parm("StringFlav:etaPrimeSup", 0.08 );
2083  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
2084  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
2085  flag("StringFlav:suppressLeadingB", false ); // kept fixed
2086  parm("StringZ:aLund", 0.55 );
2087  parm("StringZ:bLund", 1.08 );
2088  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
2089  parm("StringZ:aExtraDiquark", 1.00 );
2090  parm("StringZ:rFactC", 1.00 ); // kept fixed
2091  parm("StringZ:rFactB", 0.85 );
2092  parm("StringPT:sigma", 0.305 );
2093  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
2094  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
2095  parm("TimeShower:alphaSvalue", 0.127 );
2096  mode("TimeShower:alphaSorder", 1 ); // kept fixed
2097  flag("TimeShower:alphaSuseCMW", true );
2098  parm("TimeShower:pTmin", 0.4 );
2099  parm("TimeShower:pTminChgQ", 0.4 ); // kept same as pTmin
2100  }
2101 
2102  // First e+e- tune by Nadine Fischer, using eeTune = 3 for flavour
2103  // composition (September 2013).
2104  else if (eeTune == 5) {
2105  parm("StringFlav:probStoUD", 0.19 ); // kept fixed
2106  parm("StringFlav:probQQtoQ", 0.09 ); // kept fixed
2107  parm("StringFlav:probSQtoQQ", 1.00 ); // kept fixed
2108  parm("StringFlav:probQQ1toQQ0", 0.027 ); // kept fixed
2109  parm("StringFlav:mesonUDvector", 0.62 ); // kept fixed
2110  parm("StringFlav:mesonSvector", 0.725 ); // kept fixed
2111  parm("StringFlav:mesonCvector", 1.06 ); // kept fixed
2112  parm("StringFlav:mesonBvector", 3.0 ); // kept fixed
2113  parm("StringFlav:etaSup", 0.63 ); // kept fixed
2114  parm("StringFlav:etaPrimeSup", 0.12 ); // kept fixed
2115  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
2116  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
2117  flag("StringFlav:suppressLeadingB", false ); // kept fixed
2118  parm("StringZ:aLund", 0.386 );
2119  parm("StringZ:bLund", 0.977 );
2120  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
2121  parm("StringZ:aExtraDiquark", 0.940 );
2122  parm("StringZ:rFactC", 1.00 ); // kept fixed
2123  parm("StringZ:rFactB", 0.67 ); // kept fixed
2124  parm("StringPT:sigma", 0.286 );
2125  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
2126  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
2127  parm("TimeShower:alphaSvalue", 0.139 );
2128  mode("TimeShower:alphaSorder", 1 ); // kept fixed
2129  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
2130  parm("TimeShower:pTmin", 0.409 );
2131  parm("TimeShower:pTminChgQ", 0.409 ); // kept same as pTmin
2132  }
2133 
2134  // Second e+e- tune by Nadine Fischer, using eeTune = 3 for flavour
2135  // composition (September 2013).
2136  else if (eeTune == 6) {
2137  parm("StringFlav:probStoUD", 0.19 ); // kept fixed
2138  parm("StringFlav:probQQtoQ", 0.09 ); // kept fixed
2139  parm("StringFlav:probSQtoQQ", 1.00 ); // kept fixed
2140  parm("StringFlav:probQQ1toQQ0", 0.027 ); // kept fixed
2141  parm("StringFlav:mesonUDvector", 0.62 ); // kept fixed
2142  parm("StringFlav:mesonSvector", 0.725 ); // kept fixed
2143  parm("StringFlav:mesonCvector", 1.06 ); // kept fixed
2144  parm("StringFlav:mesonBvector", 3.0 ); // kept fixed
2145  parm("StringFlav:etaSup", 0.63 ); // kept fixed
2146  parm("StringFlav:etaPrimeSup", 0.12 ); // kept fixed
2147  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
2148  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
2149  flag("StringFlav:suppressLeadingB", false ); // kept fixed
2150  parm("StringZ:aLund", 0.351 );
2151  parm("StringZ:bLund", 0.942 );
2152  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
2153  parm("StringZ:aExtraDiquark", 0.547 );
2154  parm("StringZ:rFactC", 1.00 ); // kept fixed
2155  parm("StringZ:rFactB", 0.67 ); // kept fixed
2156  parm("StringPT:sigma", 0.283 );
2157  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
2158  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
2159  parm("TimeShower:alphaSvalue", 0.139);
2160  mode("TimeShower:alphaSorder", 1 ); // kept fixed
2161  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
2162  parm("TimeShower:pTmin", 0.406 );
2163  parm("TimeShower:pTminChgQ", 0.406 ); // kept same as pTmin
2164  }
2165 
2166  // The Monash 2013 tune by Peter Skands, the e+e- part (January 2014).
2167  else if (eeTune == 7) {
2168  parm("StringFlav:probStoUD", 0.217 );
2169  parm("StringFlav:probQQtoQ", 0.081 );
2170  parm("StringFlav:probSQtoQQ", 0.915 );
2171  parm("StringFlav:probQQ1toQQ0", 0.0275);
2172  parm("StringFlav:mesonUDvector", 0.50 );
2173  parm("StringFlav:mesonSvector", 0.55 );
2174  parm("StringFlav:mesonCvector", 0.88 );
2175  parm("StringFlav:mesonBvector", 2.20 );
2176  parm("StringFlav:etaSup", 0.60 );
2177  parm("StringFlav:etaPrimeSup", 0.12 );
2178  parm("StringFlav:popcornSpair", 0.90 );
2179  parm("StringFlav:popcornSmeson", 0.50 );
2180  flag("StringFlav:suppressLeadingB", false ); // kept fixed
2181  parm("StringZ:aLund", 0.68 );
2182  parm("StringZ:bLund", 0.98 );
2183  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
2184  parm("StringZ:aExtraDiquark", 0.97 );
2185  parm("StringZ:rFactC", 1.32 );
2186  parm("StringZ:rFactB", 0.855 );
2187  parm("StringPT:sigma", 0.335 );
2188  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
2189  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
2190  parm("TimeShower:alphaSvalue", 0.1365);
2191  mode("TimeShower:alphaSorder", 1 ); // kept fixed
2192  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
2193  parm("TimeShower:pTmin", 0.5 ); // kept fixed
2194  parm("TimeShower:pTminChgQ", 0.5 ); // kept fixed
2195  }
2196 
2197 }
2198 
2199 //--------------------------------------------------------------------------
2200 
2201 // Set the values related to a tune of pp/ppbar data,
2202 // i.e. mainly for initial-state radiation and multiparton interactions.
2203 
2204 void Settings::initTunePP( int ppTune) {
2205 
2206  // Do nothing for tune 0.
2207  if (ppTune == 0) return;
2208 
2209  // Restore all pp/ppbar settings to their original values.
2210  // Is first step for setting up a specific tune.
2211  resetTunePP();
2212 
2213  // Set up e+e- tune that goes with the corresponding pp tune.
2214  if (ppTune > 0) {
2215  int eeTune = 3;
2216  if (ppTune == 14 || ppTune >= 18) eeTune = 7;
2217  // The mode setting is for documentation, the real action is by initTuneEE.
2218  mode("Tune:ee", eeTune );
2219  initTuneEE( eeTune);
2220  }
2221 
2222  // Decide whether to use LHAPFD where possible.
2223  int preferLHAPDF = mode("Tune:preferLHAPDF");
2224 
2225  // Old ISR and MPI defaults from early and primitive comparisons with data.
2226  if (ppTune == 1) {
2227  word("PDF:pSet", "2" );
2228  parm("SigmaProcess:alphaSvalue", 0.1265);
2229  flag("SigmaTotal:zeroAXB", true );
2230  flag("SigmaDiffractive:dampen", false );
2231  parm("Diffraction:largeMassSuppress", 2.0 );
2232  flag("TimeShower:dampenBeamRecoil", false );
2233  flag("TimeShower:phiPolAsym", false );
2234  parm("SpaceShower:alphaSvalue", 0.127 );
2235  mode("SpaceShower:alphaSorder", 1 );
2236  flag("SpaceShower:alphaSuseCMW", false );
2237  flag("SpaceShower:samePTasMPI", true );
2238  parm("SpaceShower:pT0Ref", 2.2 );
2239  parm("SpaceShower:ecmRef", 1800.0);
2240  parm("SpaceShower:ecmPow", 0.16 );
2241  parm("SpaceShower:pTmaxFudge", 1.0 );
2242  parm("SpaceShower:pTdampFudge", 1.0 );
2243  flag("SpaceShower:rapidityOrder", false );
2244  flag("SpaceShower:rapidityOrderMPI", false );
2245  flag("SpaceShower:phiPolAsym", false );
2246  flag("SpaceShower:phiIntAsym", false );
2247  parm("MultipartonInteractions:alphaSvalue", 0.127 );
2248  parm("MultipartonInteractions:pT0Ref", 2.15 );
2249  parm("MultipartonInteractions:ecmRef", 1800. );
2250  parm("MultipartonInteractions:ecmPow", 0.16 );
2251  mode("MultipartonInteractions:bProfile", 2 );
2252  parm("MultipartonInteractions:expPow", 1.0 );
2253  parm("MultipartonInteractions:a1", 0.15 );
2254  parm("BeamRemnants:primordialKTsoft", 0.4 );
2255  parm("BeamRemnants:primordialKThard", 2.1 );
2256  parm("BeamRemnants:halfScaleForKT", 7.0 );
2257  parm("BeamRemnants:halfMassForKT", 2.0 );
2258  mode("ColourReconnection:mode", 0 );
2259  parm("ColourReconnection:range", 2.5 );
2260  }
2261 
2262  // "Tune 1" simple first tune by Peter Skands to ISR and MPI, July 2009.
2263  else if (ppTune == 2) {
2264  word("PDF:pSet", "2" );
2265  parm("SigmaProcess:alphaSvalue", 0.1265);
2266  flag("SigmaTotal:zeroAXB", true );
2267  flag("SigmaDiffractive:dampen", false );
2268  parm("Diffraction:largeMassSuppress", 2.0 );
2269  flag("TimeShower:dampenBeamRecoil", false );
2270  flag("TimeShower:phiPolAsym", false );
2271  parm("SpaceShower:alphaSvalue", 0.137 );
2272  mode("SpaceShower:alphaSorder", 1 );
2273  flag("SpaceShower:alphaSuseCMW", false );
2274  flag("SpaceShower:samePTasMPI", false );
2275  parm("SpaceShower:pT0Ref", 2.0 );
2276  parm("SpaceShower:ecmRef", 1800.0);
2277  parm("SpaceShower:ecmPow", 0.0 );
2278  parm("SpaceShower:pTmaxFudge", 1.0 );
2279  parm("SpaceShower:pTdampFudge", 1.0 );
2280  flag("SpaceShower:rapidityOrder", false );
2281  flag("SpaceShower:rapidityOrderMPI", false );
2282  flag("SpaceShower:phiPolAsym", false );
2283  flag("SpaceShower:phiIntAsym", false );
2284  parm("MultipartonInteractions:alphaSvalue", 0.127 );
2285  parm("MultipartonInteractions:pT0Ref", 2.25 );
2286  parm("MultipartonInteractions:ecmRef", 1800. );
2287  parm("MultipartonInteractions:ecmPow", 0.24 );
2288  mode("MultipartonInteractions:bProfile", 1 );
2289  parm("MultipartonInteractions:expPow", 1.0 );
2290  parm("MultipartonInteractions:a1", 0.15 );
2291  parm("BeamRemnants:primordialKTsoft", 0.5 );
2292  parm("BeamRemnants:primordialKThard", 2.0 );
2293  parm("BeamRemnants:halfScaleForKT", 1.0 );
2294  parm("BeamRemnants:halfMassForKT", 1.0 );
2295  mode("ColourReconnection:mode", 0 );
2296  parm("ColourReconnection:range", 10.0 );
2297  }
2298 
2299  // Tune 2C, July 2010.
2300  else if (ppTune == 3) {
2301  word("PDF:pSet", "8" );
2302  parm("SigmaProcess:alphaSvalue", 0.135 );
2303  flag("SigmaTotal:zeroAXB", true );
2304  flag("SigmaDiffractive:dampen", false );
2305  parm("Diffraction:largeMassSuppress", 2.0 );
2306  flag("TimeShower:dampenBeamRecoil", true );
2307  flag("TimeShower:phiPolAsym", true );
2308  parm("SpaceShower:alphaSvalue", 0.137 );
2309  mode("SpaceShower:alphaSorder", 1 );
2310  flag("SpaceShower:alphaSuseCMW", false );
2311  flag("SpaceShower:samePTasMPI", false );
2312  parm("SpaceShower:pT0Ref", 2.0 );
2313  parm("SpaceShower:ecmRef", 1800.0);
2314  parm("SpaceShower:ecmPow", 0.0 );
2315  parm("SpaceShower:pTmaxFudge", 1.0 );
2316  parm("SpaceShower:pTdampFudge", 1.0 );
2317  flag("SpaceShower:rapidityOrder", true );
2318  flag("SpaceShower:rapidityOrderMPI", true );
2319  flag("SpaceShower:phiPolAsym", true );
2320  flag("SpaceShower:phiIntAsym", true );
2321  parm("MultipartonInteractions:alphaSvalue", 0.135 );
2322  parm("MultipartonInteractions:pT0Ref", 2.32 );
2323  parm("MultipartonInteractions:ecmRef", 1800. );
2324  parm("MultipartonInteractions:ecmPow", 0.21 );
2325  mode("MultipartonInteractions:bProfile", 3 );
2326  parm("MultipartonInteractions:expPow", 1.6 );
2327  parm("MultipartonInteractions:a1", 0.15 );
2328  parm("BeamRemnants:primordialKTsoft", 0.5 );
2329  parm("BeamRemnants:primordialKThard", 2.0 );
2330  parm("BeamRemnants:halfScaleForKT", 1.0 );
2331  parm("BeamRemnants:halfMassForKT", 1.0 );
2332  mode("ColourReconnection:mode", 0 );
2333  parm("ColourReconnection:range", 3.0 );
2334  }
2335 
2336  // Tune 2M, July 2010.
2337  else if (ppTune == 4) {
2338  word("PDF:pSet", "4" );
2339  parm("SigmaProcess:alphaSvalue", 0.1265);
2340  flag("SigmaTotal:zeroAXB", true );
2341  flag("SigmaDiffractive:dampen", false );
2342  parm("Diffraction:largeMassSuppress", 2.0 );
2343  flag("TimeShower:dampenBeamRecoil", true );
2344  flag("TimeShower:phiPolAsym", true );
2345  parm("SpaceShower:alphaSvalue", 0.130 );
2346  mode("SpaceShower:alphaSorder", 1 );
2347  flag("SpaceShower:alphaSuseCMW", false );
2348  flag("SpaceShower:samePTasMPI", false );
2349  parm("SpaceShower:pT0Ref", 2.0 );
2350  parm("SpaceShower:ecmRef", 1800.0);
2351  parm("SpaceShower:ecmPow", 0.0 );
2352  parm("SpaceShower:pTmaxFudge", 1.0 );
2353  parm("SpaceShower:pTdampFudge", 1.0 );
2354  flag("SpaceShower:rapidityOrder", true );
2355  flag("SpaceShower:rapidityOrderMPI", true );
2356  flag("SpaceShower:phiPolAsym", true );
2357  flag("SpaceShower:phiIntAsym", true );
2358  parm("MultipartonInteractions:alphaSvalue", 0.127 );
2359  parm("MultipartonInteractions:pT0Ref", 2.455 );
2360  parm("MultipartonInteractions:ecmRef", 1800. );
2361  parm("MultipartonInteractions:ecmPow", 0.26 );
2362  mode("MultipartonInteractions:bProfile", 3 );
2363  parm("MultipartonInteractions:expPow", 1.15 );
2364  parm("MultipartonInteractions:a1", 0.15 );
2365  parm("BeamRemnants:primordialKTsoft", 0.5 );
2366  parm("BeamRemnants:primordialKThard", 2.0 );
2367  parm("BeamRemnants:halfScaleForKT", 1.0 );
2368  parm("BeamRemnants:halfMassForKT", 1.0 );
2369  mode("ColourReconnection:mode", 0 );
2370  parm("ColourReconnection:range", 3.0 );
2371  }
2372 
2373  // Tune 4C, October 2010.
2374  else if (ppTune == 5) {
2375  word("PDF:pSet", "8" );
2376  parm("SigmaProcess:alphaSvalue", 0.135 );
2377  flag("SigmaTotal:zeroAXB", true );
2378  flag("SigmaDiffractive:dampen", true );
2379  parm("SigmaDiffractive:maxXB", 65.0 );
2380  parm("SigmaDiffractive:maxAX", 65.0 );
2381  parm("SigmaDiffractive:maxXX", 65.0 );
2382  parm("Diffraction:largeMassSuppress", 2.0 );
2383  flag("TimeShower:dampenBeamRecoil", true );
2384  flag("TimeShower:phiPolAsym", true );
2385  parm("SpaceShower:alphaSvalue", 0.137 );
2386  mode("SpaceShower:alphaSorder", 1 );
2387  flag("SpaceShower:alphaSuseCMW", false );
2388  flag("SpaceShower:samePTasMPI", false );
2389  parm("SpaceShower:pT0Ref", 2.0 );
2390  parm("SpaceShower:ecmRef", 1800.0);
2391  parm("SpaceShower:ecmPow", 0.0 );
2392  parm("SpaceShower:pTmaxFudge", 1.0 );
2393  parm("SpaceShower:pTdampFudge", 1.0 );
2394  flag("SpaceShower:rapidityOrder", true );
2395  flag("SpaceShower:rapidityOrderMPI", true );
2396  flag("SpaceShower:phiPolAsym", true );
2397  flag("SpaceShower:phiIntAsym", true );
2398  parm("MultipartonInteractions:alphaSvalue", 0.135 );
2399  parm("MultipartonInteractions:pT0Ref", 2.085 );
2400  parm("MultipartonInteractions:ecmRef", 1800. );
2401  parm("MultipartonInteractions:ecmPow", 0.19 );
2402  mode("MultipartonInteractions:bProfile", 3 );
2403  parm("MultipartonInteractions:expPow", 2.0 );
2404  parm("MultipartonInteractions:a1", 0.15 );
2405  parm("BeamRemnants:primordialKTsoft", 0.5 );
2406  parm("BeamRemnants:primordialKThard", 2.0 );
2407  parm("BeamRemnants:halfScaleForKT", 1.0 );
2408  parm("BeamRemnants:halfMassForKT", 1.0 );
2409  mode("ColourReconnection:mode", 0 );
2410  parm("ColourReconnection:range", 1.5 );
2411  }
2412 
2413  // Tune 4Cx, January 2011.
2414  else if (ppTune == 6) {
2415  word("PDF:pSet", "8" );
2416  parm("SigmaProcess:alphaSvalue", 0.135 );
2417  flag("SigmaTotal:zeroAXB", true );
2418  flag("SigmaDiffractive:dampen", true );
2419  parm("SigmaDiffractive:maxXB", 65.0 );
2420  parm("SigmaDiffractive:maxAX", 65.0 );
2421  parm("SigmaDiffractive:maxXX", 65.0 );
2422  parm("Diffraction:largeMassSuppress", 2.0 );
2423  flag("TimeShower:dampenBeamRecoil", true );
2424  flag("TimeShower:phiPolAsym", true );
2425  parm("SpaceShower:alphaSvalue", 0.137 );
2426  mode("SpaceShower:alphaSorder", 1 );
2427  flag("SpaceShower:alphaSuseCMW", false );
2428  flag("SpaceShower:samePTasMPI", false );
2429  parm("SpaceShower:pT0Ref", 2.0 );
2430  parm("SpaceShower:ecmRef", 1800.0);
2431  parm("SpaceShower:ecmPow", 0.0 );
2432  parm("SpaceShower:pTmaxFudge", 1.0 );
2433  parm("SpaceShower:pTdampFudge", 1.0 );
2434  flag("SpaceShower:rapidityOrder", true );
2435  flag("SpaceShower:rapidityOrderMPI", true );
2436  flag("SpaceShower:phiPolAsym", true );
2437  flag("SpaceShower:phiIntAsym", true );
2438  parm("MultipartonInteractions:alphaSvalue", 0.135 );
2439  parm("MultipartonInteractions:pT0Ref", 2.15 );
2440  parm("MultipartonInteractions:ecmRef", 1800. );
2441  parm("MultipartonInteractions:ecmPow", 0.19 );
2442  mode("MultipartonInteractions:bProfile", 4 );
2443  parm("MultipartonInteractions:expPow", 1.0 );
2444  parm("MultipartonInteractions:a1", 0.15 );
2445  parm("BeamRemnants:primordialKTsoft", 0.5 );
2446  parm("BeamRemnants:primordialKThard", 2.0 );
2447  parm("BeamRemnants:halfScaleForKT", 1.0 );
2448  parm("BeamRemnants:halfMassForKT", 1.0 );
2449  mode("ColourReconnection:mode", 0 );
2450  parm("ColourReconnection:range", 1.5 );
2451  }
2452 
2453  // The Monash 2013 tune by Peter Skands, the pp part (January 2014).
2454  else if (ppTune == 14) {
2455  word("PDF:pSet", "13" ); // NNPDF
2456  parm("SigmaProcess:alphaSvalue", 0.130 ); // same as PDF
2457  flag("SigmaTotal:zeroAXB", true );
2458  flag("SigmaDiffractive:dampen", true );
2459  parm("SigmaDiffractive:maxXB", 65.0 );
2460  parm("SigmaDiffractive:maxAX", 65.0 );
2461  parm("SigmaDiffractive:maxXX", 65.0 );
2462  parm("Diffraction:largeMassSuppress", 4.0 );
2463  flag("TimeShower:dampenBeamRecoil", true );
2464  flag("TimeShower:phiPolAsym", true );
2465  parm("SpaceShower:alphaSvalue", 0.1365); // same as FSR
2466  mode("SpaceShower:alphaSorder", 1 );
2467  flag("SpaceShower:alphaSuseCMW", false );
2468  flag("SpaceShower:samePTasMPI", false );
2469  parm("SpaceShower:pT0Ref", 2.0 );
2470  parm("SpaceShower:ecmRef", 7000.0);
2471  parm("SpaceShower:ecmPow", 0.0 );
2472  parm("SpaceShower:pTmaxFudge", 1.0 );
2473  parm("SpaceShower:pTdampFudge", 1.0 );
2474  flag("SpaceShower:rapidityOrder", true );
2475  flag("SpaceShower:rapidityOrderMPI", true );
2476  flag("SpaceShower:phiPolAsym", true );
2477  flag("SpaceShower:phiIntAsym", true );
2478  parm("MultipartonInteractions:alphaSvalue", 0.130 ); // same as PDF
2479  parm("MultipartonInteractions:pT0Ref", 2.28 );
2480  parm("MultipartonInteractions:ecmRef", 7000. );
2481  parm("MultipartonInteractions:ecmPow", 0.215 );
2482  mode("MultipartonInteractions:bProfile", 3 );
2483  parm("MultipartonInteractions:expPow", 1.85 );
2484  parm("MultipartonInteractions:a1", 0.15 );
2485  parm("BeamRemnants:primordialKTsoft", 0.9 );
2486  parm("BeamRemnants:primordialKThard", 1.8 );
2487  parm("BeamRemnants:halfScaleForKT", 1.5 );
2488  parm("BeamRemnants:halfMassForKT", 1.0 );
2489  mode("ColourReconnection:mode", 0 );
2490  parm("ColourReconnection:range", 1.80 );
2491  }
2492 
2493  // Several ATLAS and CMS tunes start out from Tune 4C.
2494  else if (ppTune > 0 && ppTune < 18) {
2495  parm("SigmaProcess:alphaSvalue", 0.135 );
2496  flag("SigmaTotal:zeroAXB", true );
2497  flag("SigmaDiffractive:dampen", true );
2498  parm("SigmaDiffractive:maxXB", 65.0 );
2499  parm("SigmaDiffractive:maxAX", 65.0 );
2500  parm("SigmaDiffractive:maxXX", 65.0 );
2501  parm("Diffraction:largeMassSuppress", 2.0 );
2502  flag("TimeShower:dampenBeamRecoil", true );
2503  flag("TimeShower:phiPolAsym", true );
2504  parm("SpaceShower:alphaSvalue", 0.137 );
2505  mode("SpaceShower:alphaSorder", 1 );
2506  flag("SpaceShower:alphaSuseCMW", false );
2507  flag("SpaceShower:samePTasMPI", false );
2508  parm("SpaceShower:pT0Ref", 2.0 );
2509  parm("SpaceShower:ecmRef", 1800.0);
2510  parm("SpaceShower:ecmPow", 0.0 );
2511  parm("SpaceShower:pTmaxFudge", 1.0 );
2512  parm("SpaceShower:pTdampFudge", 1.0 );
2513  flag("SpaceShower:rapidityOrder", true );
2514  flag("SpaceShower:rapidityOrderMPI", true );
2515  flag("SpaceShower:phiPolAsym", true );
2516  flag("SpaceShower:phiIntAsym", true );
2517  parm("MultipartonInteractions:alphaSvalue", 0.135 );
2518  parm("MultipartonInteractions:pT0Ref", 2.085 );
2519  parm("MultipartonInteractions:ecmRef", 1800. );
2520  parm("MultipartonInteractions:ecmPow", 0.19 );
2521  mode("MultipartonInteractions:bProfile", 3 );
2522  parm("MultipartonInteractions:expPow", 2.0 );
2523  parm("MultipartonInteractions:a1", 0.15 );
2524  parm("BeamRemnants:primordialKTsoft", 0.5 );
2525  parm("BeamRemnants:primordialKThard", 2.0 );
2526  parm("BeamRemnants:halfScaleForKT", 1.0 );
2527  parm("BeamRemnants:halfMassForKT", 1.0 );
2528  mode("ColourReconnection:mode", 0 );
2529  parm("ColourReconnection:range", 1.5 );
2530 
2531  // Several ATLAS tunes in the A2 and AU2 series, see
2532  // ATLAS note ATL-PHYS-PUB-2012-003 (August 2012).
2533  // ATLAS MB tune A2-CTEQ6L1.
2534  if (ppTune == 7) {
2535  if (preferLHAPDF == 1)
2536  word("PDF:pSet", "LHAPDF5:cteq6ll.LHpdf");
2537  else if (preferLHAPDF == 2)
2538  word("PDF:pSet", "LHAPDF6:cteq6l1");
2539  else word("PDF:pSet", "8" );
2540  flag("SpaceShower:rapidityOrder", false );
2541  flag("SpaceShower:rapidityOrderMPI", false );
2542  parm("MultipartonInteractions:pT0Ref", 2.18 );
2543  parm("MultipartonInteractions:ecmPow", 0.22 );
2544  mode("MultipartonInteractions:bProfile", 4 );
2545  parm("MultipartonInteractions:expPow", 1.0 );
2546  parm("MultipartonInteractions:a1", 0.06 );
2547  parm("ColourReconnection:range", 1.55 );
2548  }
2549 
2550  // ATLAS MB tune A2-MSTW2008LO.
2551  else if (ppTune == 8) {
2552  if (preferLHAPDF == 1)
2553  word("PDF:pSet", "LHAPDF5:MSTW2008lo68cl.LHgrid");
2554  else if (preferLHAPDF == 2)
2555  word("PDF:pSet", "LHAPDF6:MSTW2008lo68cl");
2556  else word("PDF:pSet", "5" );
2557  flag("SpaceShower:rapidityOrder", false );
2558  flag("SpaceShower:rapidityOrderMPI", false );
2559  parm("MultipartonInteractions:pT0Ref", 1.90 );
2560  parm("MultipartonInteractions:ecmPow", 0.30 );
2561  mode("MultipartonInteractions:bProfile", 4 );
2562  parm("MultipartonInteractions:expPow", 1.0 );
2563  parm("MultipartonInteractions:a1", 0.03 );
2564  parm("ColourReconnection:range", 2.28 );
2565  }
2566 
2567  // ATLAS UE tune AU2-CTEQ6L1.
2568  if (ppTune == 9) {
2569  if (preferLHAPDF == 1)
2570  word("PDF:pSet", "LHAPDF5:cteq6ll.LHpdf");
2571  else if (preferLHAPDF == 2)
2572  word("PDF:pSet", "LHAPDF6:cteq6l1");
2573  else word("PDF:pSet", "8" );
2574  flag("SpaceShower:rapidityOrder", false );
2575  flag("SpaceShower:rapidityOrderMPI", false );
2576  parm("MultipartonInteractions:pT0Ref", 2.13 );
2577  parm("MultipartonInteractions:ecmPow", 0.21 );
2578  mode("MultipartonInteractions:bProfile", 4 );
2579  parm("MultipartonInteractions:expPow", 1.0 );
2580  parm("MultipartonInteractions:a1", 0.00 );
2581  parm("ColourReconnection:range", 2.21 );
2582  }
2583 
2584  // ATLAS UE tune AU2-MSTW2008LO.
2585  else if (ppTune == 10) {
2586  if (preferLHAPDF == 1)
2587  word("PDF:pSet", "LHAPDF5:MSTW2008lo68cl.LHgrid");
2588  else if (preferLHAPDF == 2)
2589  word("PDF:pSet", "LHAPDF6:MSTW2008lo68cl");
2590  else word("PDF:pSet", "5" );
2591  flag("SpaceShower:rapidityOrder", false );
2592  flag("SpaceShower:rapidityOrderMPI", false );
2593  parm("MultipartonInteractions:pT0Ref", 1.87 );
2594  parm("MultipartonInteractions:ecmPow", 0.28 );
2595  mode("MultipartonInteractions:bProfile", 4 );
2596  parm("MultipartonInteractions:expPow", 1.0 );
2597  parm("MultipartonInteractions:a1", 0.01 );
2598  parm("ColourReconnection:range", 5.32 );
2599  }
2600 
2601  // ATLAS UE tune AU2-CT10.
2602  else if (ppTune == 11) {
2603  if (preferLHAPDF == 2)
2604  word("PDF:pSet", "LHAPDF6:CT10");
2605  else
2606  word("PDF:pSet", "LHAPDF5:CT10.LHgrid");
2607  flag("SpaceShower:rapidityOrder", false );
2608  flag("SpaceShower:rapidityOrderMPI", false );
2609  parm("MultipartonInteractions:pT0Ref", 1.70 );
2610  parm("MultipartonInteractions:ecmPow", 0.16 );
2611  mode("MultipartonInteractions:bProfile", 4 );
2612  parm("MultipartonInteractions:expPow", 1.0 );
2613  parm("MultipartonInteractions:a1", 0.10 );
2614  parm("ColourReconnection:range", 4.67 );
2615  }
2616 
2617  // ATLAS UE tune AU2-MRST2007LO*.
2618  else if (ppTune == 12) {
2619  if (preferLHAPDF == 1)
2620  word("PDF:pSet", "LHAPDF5:MRST2007lomod.LHgrid");
2621  else if (preferLHAPDF == 2)
2622  word("PDF:pSet", "LHAPDF6:MRST2007lomod");
2623  else word("PDF:pSet", "3" );
2624  flag("SpaceShower:rapidityOrder", false );
2625  flag("SpaceShower:rapidityOrderMPI", false );
2626  parm("MultipartonInteractions:pT0Ref", 2.39 );
2627  parm("MultipartonInteractions:ecmPow", 0.24 );
2628  mode("MultipartonInteractions:bProfile", 4 );
2629  parm("MultipartonInteractions:expPow", 1.0 );
2630  parm("MultipartonInteractions:a1", 0.01 );
2631  parm("ColourReconnection:range", 1.76 );
2632  }
2633 
2634  // ATLAS UE tune AU2-MRST2007LO**.
2635  else if (ppTune == 13) {
2636  if (preferLHAPDF == 1)
2637  word("PDF:pSet", "LHAPDF5:MRSTMCal.LHgrid");
2638  else if (preferLHAPDF == 2)
2639  word("PDF:pSet", "LHAPDF6:MRSTMCal");
2640  else word("PDF:pSet", "4" );
2641  flag("SpaceShower:rapidityOrder", false );
2642  flag("SpaceShower:rapidityOrderMPI", false );
2643  parm("MultipartonInteractions:pT0Ref", 2.57 );
2644  parm("MultipartonInteractions:ecmPow", 0.23 );
2645  mode("MultipartonInteractions:bProfile", 4 );
2646  parm("MultipartonInteractions:expPow", 1.0 );
2647  parm("MultipartonInteractions:a1", 0.01 );
2648  parm("ColourReconnection:range", 1.47 );
2649  }
2650 
2651  // The CMS UE tunes CUETP8S1-CTEQ6L1 and CUETP8S1-HERAPDF1.5LO,
2652  // see the note CMS PAS GEN-14-001 (April 2014).
2653  // CMS UE tune CUETP8S1-CTEQ6L1.
2654  else if (ppTune == 15) {
2655  if (preferLHAPDF == 1)
2656  word("PDF:pSet", "LHAPDF5:cteq6ll.LHpdf");
2657  else if (preferLHAPDF == 2)
2658  word("PDF:pSet", "LHAPDF6:cteq6l1");
2659  else word("PDF:pSet", "8" );
2660  parm("MultipartonInteractions:pT0Ref", 2.1006);
2661  parm("MultipartonInteractions:ecmPow", 0.2106);
2662  parm("MultipartonInteractions:expPow", 1.6089);
2663  parm("MultipartonInteractions:a1", 0.00 );
2664  parm("ColourReconnection:range", 3.3126);
2665  }
2666 
2667  // CMS UE tune CUETP8S1-HERAPDF1.5LO.
2668  else if (ppTune == 16) {
2669  if (preferLHAPDF == 2)
2670  word("PDF:pSet", "LHAPDF6:HERAPDF15LO_EIG");
2671  else
2672  word("PDF:pSet", "LHAPDF5:HERAPDF1.5LO_EIG.LHgrid");
2673  parm("MultipartonInteractions:pT0Ref", 2.0001);
2674  parm("MultipartonInteractions:ecmPow", 0.2499);
2675  parm("MultipartonInteractions:expPow", 1.6905);
2676  parm("MultipartonInteractions:a1", 0.00 );
2677  parm("ColourReconnection:range", 6.0964);
2678  }
2679 
2680  // ATLAS tune AZ to the Z0/gamma* pTspectrum, see the note
2681  // CERN-PH-EP-2014-075 [arXiv:1406.3660 [hep-ex]] (June 2014).
2682  else if (ppTune == 17) {
2683  parm("SpaceShower:alphaSvalue", 0.1237);
2684  parm("SpaceShower:pT0Ref", 0.59 );
2685  parm("MultipartonInteractions:pT0Ref", 2.18 );
2686  parm("BeamRemnants:primordialKThard", 1.71 );
2687  }
2688  }
2689 
2690  // Several ATLAS and CMS tunes and tunes close-packing of strings
2691  // and hadron rescattering with start out from Monash 2013 tune.
2692  else if (ppTune >= 18) {
2693  word("PDF:pSet", "13" ); // NNPDF
2694  parm("SigmaProcess:alphaSvalue", 0.130 ); // same as PDF
2695  flag("SigmaTotal:zeroAXB", true );
2696  flag("SigmaDiffractive:dampen", true );
2697  parm("SigmaDiffractive:maxXB", 65.0 );
2698  parm("SigmaDiffractive:maxAX", 65.0 );
2699  parm("SigmaDiffractive:maxXX", 65.0 );
2700  parm("Diffraction:largeMassSuppress", 4.0 );
2701  flag("TimeShower:dampenBeamRecoil", true );
2702  flag("TimeShower:phiPolAsym", true );
2703  parm("SpaceShower:alphaSvalue", 0.1365); // same as FSR
2704  mode("SpaceShower:alphaSorder", 1 );
2705  flag("SpaceShower:alphaSuseCMW", false );
2706  flag("SpaceShower:samePTasMPI", false );
2707  parm("SpaceShower:pT0Ref", 2.0 );
2708  parm("SpaceShower:ecmRef", 7000.0);
2709  parm("SpaceShower:ecmPow", 0.0 );
2710  parm("SpaceShower:pTmaxFudge", 1.0 );
2711  parm("SpaceShower:pTdampFudge", 1.0 );
2712  flag("SpaceShower:rapidityOrder", true );
2713  flag("SpaceShower:rapidityOrderMPI", true );
2714  flag("SpaceShower:phiPolAsym", true );
2715  flag("SpaceShower:phiIntAsym", true );
2716  parm("MultipartonInteractions:alphaSvalue", 0.130 ); // same as PDF
2717  parm("MultipartonInteractions:pT0Ref", 2.28 );
2718  parm("MultipartonInteractions:ecmRef", 7000. );
2719  parm("MultipartonInteractions:ecmPow", 0.215 );
2720  mode("MultipartonInteractions:bProfile", 3 );
2721  parm("MultipartonInteractions:expPow", 1.85 );
2722  parm("MultipartonInteractions:a1", 0.15 );
2723  parm("BeamRemnants:primordialKTsoft", 0.9 );
2724  parm("BeamRemnants:primordialKThard", 1.8 );
2725  parm("BeamRemnants:halfScaleForKT", 1.5 );
2726  parm("BeamRemnants:halfMassForKT", 1.0 );
2727  mode("ColourReconnection:mode", 0 );
2728  parm("ColourReconnection:range", 1.80 );
2729 
2730  // CMS tune MonashStar = CUETP8M1-NNPDF2.3LO.
2731  // See R.D. Field, presentation at MPI@LHC 2014, Krakow, Poland.
2732  if (ppTune == 18) {
2733  parm("MultipartonInteractions:pT0Ref", 2.4024);
2734  parm("MultipartonInteractions:ecmPow", 0.25208);
2735  parm("MultipartonInteractions:expPow", 1.60 );
2736  }
2737 
2738  // The ATLAS A14 tunes, central tune with CTEQL1.
2739  // See ATL-PHYS-PUB-2014-021 (November 2014).
2740  // Warning: note that TimeShower:alphaSvalue is set here, although
2741  // normally it would be in the domain of ee tunes. This makes the
2742  // order of Tune:ee and Tune:pp commands relevant.
2743  else if (ppTune == 19) {
2744  if (preferLHAPDF == 1)
2745  word("PDF:pSet", "LHAPDF5:cteq6ll.LHpdf");
2746  else if (preferLHAPDF == 2)
2747  word("PDF:pSet", "LHAPDF6:cteq6l1");
2748  else word("PDF:pSet", "8" );
2749  parm("SigmaProcess:alphaSvalue", 0.144 );
2750  parm("TimeShower:alphaSvalue", 0.126 );
2751  parm("SpaceShower:alphaSvalue", 0.125 );
2752  parm("SpaceShower:pT0Ref", 1.3 );
2753  parm("SpaceShower:pTmaxFudge", 0.95 );
2754  parm("SpaceShower:pTdampFudge", 1.21 );
2755  parm("MultipartonInteractions:alphaSvalue",0.118);
2756  parm("MultipartonInteractions:pT0Ref", 1.98 );
2757  parm("BeamRemnants:primordialKThard", 1.72 );
2758  parm("ColourReconnection:range", 2.08 );
2759  }
2760 
2761  // The ATLAS A14 tunes, central tune with MSTW2008LO.
2762  else if (ppTune == 20) {
2763  if (preferLHAPDF == 1)
2764  word("PDF:pSet", "LHAPDF5:MSTW2008lo68cl.LHgrid");
2765  else if (preferLHAPDF == 2)
2766  word("PDF:pSet", "LHAPDF6:MSTW2008lo68cl");
2767  else word("PDF:pSet", "5" );
2768  parm("SigmaProcess:alphaSvalue", 0.140 );
2769  parm("TimeShower:alphaSvalue", 0.129 );
2770  parm("SpaceShower:alphaSvalue", 0.129 );
2771  parm("SpaceShower:pT0Ref", 1.62 );
2772  parm("SpaceShower:pTmaxFudge", 0.92 );
2773  parm("SpaceShower:pTdampFudge", 1.14 );
2774  parm("MultipartonInteractions:alphaSvalue",0.130);
2775  parm("MultipartonInteractions:pT0Ref", 2.28 );
2776  parm("BeamRemnants:primordialKThard", 1.82 );
2777  parm("ColourReconnection:range", 1.87 );
2778  }
2779 
2780  // The ATLAS A14 tunes, central tune with NNPDF2.3LO.
2781  else if (ppTune == 21) {
2782  word("PDF:pSet", "13" );
2783  parm("SigmaProcess:alphaSvalue", 0.140 );
2784  parm("TimeShower:alphaSvalue", 0.127 );
2785  parm("SpaceShower:alphaSvalue", 0.127 );
2786  parm("SpaceShower:pT0Ref", 1.56 );
2787  parm("SpaceShower:pTmaxFudge", 0.91 );
2788  parm("SpaceShower:pTdampFudge", 1.05 );
2789  parm("MultipartonInteractions:alphaSvalue",0.126);
2790  parm("MultipartonInteractions:pT0Ref", 2.09 );
2791  parm("BeamRemnants:primordialKThard", 1.88 );
2792  parm("ColourReconnection:range", 1.71 );
2793  }
2794 
2795  // The ATLAS A14 tunes, central tune with HERAPDF1.5LO.
2796  else if (ppTune == 22) {
2797  if (preferLHAPDF == 2)
2798  word("PDF:pSet", "LHAPDF6:HERAPDF15LO_EIG");
2799  else
2800  word("PDF:pSet", "LHAPDF5:HERAPDF1.5LO_EIG.LHgrid");
2801  parm("SigmaProcess:alphaSvalue", 0.141 );
2802  parm("TimeShower:alphaSvalue", 0.130 );
2803  parm("SpaceShower:alphaSvalue", 0.128);
2804  parm("SpaceShower:pT0Ref", 1.61 );
2805  parm("SpaceShower:pTmaxFudge", 0.95 );
2806  parm("SpaceShower:pTdampFudge", 1.10 );
2807  parm("MultipartonInteractions:alphaSvalue",0.123);
2808  parm("MultipartonInteractions:pT0Ref", 2.14 );
2809  parm("BeamRemnants:primordialKThard", 1.83 );
2810  parm("ColourReconnection:range", 1.78 );
2811  }
2812 
2813  // The ATLAS A14 tunes, variation 1+.
2814  else if (ppTune == 23) {
2815  word("PDF:pSet", "13" );
2816  parm("SigmaProcess:alphaSvalue", 0.140 );
2817  parm("TimeShower:alphaSvalue", 0.127 );
2818  parm("SpaceShower:alphaSvalue", 0.127 );
2819  parm("SpaceShower:pT0Ref", 1.56 );
2820  parm("SpaceShower:pTmaxFudge", 0.91 );
2821  parm("SpaceShower:pTdampFudge", 1.05 );
2822  parm("MultipartonInteractions:alphaSvalue",0.131);
2823  parm("MultipartonInteractions:pT0Ref", 2.09 );
2824  parm("BeamRemnants:primordialKThard", 1.88 );
2825  parm("ColourReconnection:range", 1.73 );
2826  }
2827 
2828  // The ATLAS A14 tunes, variation 1-.
2829  else if (ppTune == 24) {
2830  word("PDF:pSet", "13" );
2831  parm("SigmaProcess:alphaSvalue", 0.140 );
2832  parm("TimeShower:alphaSvalue", 0.127 );
2833  parm("SpaceShower:alphaSvalue", 0.127 );
2834  parm("SpaceShower:pT0Ref", 1.56 );
2835  parm("SpaceShower:pTmaxFudge", 0.91 );
2836  parm("SpaceShower:pTdampFudge", 1.05 );
2837  parm("MultipartonInteractions:alphaSvalue",0.121);
2838  parm("MultipartonInteractions:pT0Ref", 2.09 );
2839  parm("BeamRemnants:primordialKThard", 1.88 );
2840  parm("ColourReconnection:range", 1.69 );
2841  }
2842 
2843  // The ATLAS A14 tunes, variation 2+.
2844  else if (ppTune == 25) {
2845  word("PDF:pSet", "13" );
2846  parm("SigmaProcess:alphaSvalue", 0.140 );
2847  parm("TimeShower:alphaSvalue", 0.139 );
2848  parm("SpaceShower:alphaSvalue", 0.127 );
2849  parm("SpaceShower:pT0Ref", 1.60 );
2850  parm("SpaceShower:pTmaxFudge", 0.91 );
2851  parm("SpaceShower:pTdampFudge", 1.04 );
2852  parm("MultipartonInteractions:alphaSvalue",0.126);
2853  parm("MultipartonInteractions:pT0Ref", 2.09 );
2854  parm("BeamRemnants:primordialKThard", 1.88 );
2855  parm("ColourReconnection:range", 1.71 );
2856  }
2857 
2858  // The ATLAS A14 tunes, variation 2-.
2859  else if (ppTune == 26) {
2860  word("PDF:pSet", "13" );
2861  parm("SigmaProcess:alphaSvalue", 0.140 );
2862  parm("TimeShower:alphaSvalue", 0.111 );
2863  parm("SpaceShower:alphaSvalue", 0.127 );
2864  parm("SpaceShower:pT0Ref", 1.50 );
2865  parm("SpaceShower:pTmaxFudge", 0.91 );
2866  parm("SpaceShower:pTdampFudge", 1.08 );
2867  parm("MultipartonInteractions:alphaSvalue",0.126);
2868  parm("MultipartonInteractions:pT0Ref", 2.09 );
2869  parm("BeamRemnants:primordialKThard", 1.88 );
2870  parm("ColourReconnection:range", 1.71 );
2871  }
2872 
2873  // The ATLAS A14 tunes, variation 3a+.
2874  else if (ppTune == 27) {
2875  word("PDF:pSet", "13" );
2876  parm("SigmaProcess:alphaSvalue", 0.140 );
2877  parm("TimeShower:alphaSvalue", 0.136 );
2878  parm("SpaceShower:alphaSvalue", 0.127 );
2879  parm("SpaceShower:pT0Ref", 1.67 );
2880  parm("SpaceShower:pTmaxFudge", 0.98 );
2881  parm("SpaceShower:pTdampFudge", 1.36 );
2882  parm("MultipartonInteractions:alphaSvalue",0.125);
2883  parm("MultipartonInteractions:pT0Ref", 2.09 );
2884  parm("BeamRemnants:primordialKThard", 1.88 );
2885  parm("ColourReconnection:range", 1.71 );
2886  }
2887 
2888  // The ATLAS A14 tunes, variation 3a-.
2889  else if (ppTune == 28) {
2890  word("PDF:pSet", "13" );
2891  parm("SigmaProcess:alphaSvalue", 0.140 );
2892  parm("TimeShower:alphaSvalue", 0.124 );
2893  parm("SpaceShower:alphaSvalue", 0.127 );
2894  parm("SpaceShower:pT0Ref", 1.51 );
2895  parm("SpaceShower:pTmaxFudge", 0.88 );
2896  parm("SpaceShower:pTdampFudge", 0.93 );
2897  parm("MultipartonInteractions:alphaSvalue",0.127);
2898  parm("MultipartonInteractions:pT0Ref", 2.09 );
2899  parm("BeamRemnants:primordialKThard", 1.88 );
2900  parm("ColourReconnection:range", 1.71 );
2901  }
2902 
2903  // The ATLAS A14 tunes, variation 3b+.
2904  else if (ppTune == 29) {
2905  word("PDF:pSet", "13" );
2906  parm("SigmaProcess:alphaSvalue", 0.140 );
2907  parm("TimeShower:alphaSvalue", 0.114 );
2908  parm("SpaceShower:alphaSvalue", 0.129 );
2909  parm("SpaceShower:pT0Ref", 1.56 );
2910  parm("SpaceShower:pTmaxFudge", 1.00 );
2911  parm("SpaceShower:pTdampFudge", 1.04 );
2912  parm("MultipartonInteractions:alphaSvalue",0.126);
2913  parm("MultipartonInteractions:pT0Ref", 2.09 );
2914  parm("BeamRemnants:primordialKThard", 1.88 );
2915  parm("ColourReconnection:range", 1.71 );
2916  }
2917 
2918  // The ATLAS A14 tunes, variation 3b-.
2919  else if (ppTune == 30) {
2920  word("PDF:pSet", "13" );
2921  parm("SigmaProcess:alphaSvalue", 0.140 );
2922  parm("TimeShower:alphaSvalue", 0.138 );
2923  parm("SpaceShower:alphaSvalue", 0.126 );
2924  parm("SpaceShower:pT0Ref", 1.56 );
2925  parm("SpaceShower:pTmaxFudge", 0.83 );
2926  parm("SpaceShower:pTdampFudge", 1.07 );
2927  parm("MultipartonInteractions:alphaSvalue",0.126);
2928  parm("MultipartonInteractions:pT0Ref", 2.09 );
2929  parm("BeamRemnants:primordialKThard", 1.88 );
2930  parm("ColourReconnection:range", 1.71 );
2931  }
2932 
2933  // The ATLAS A14 tunes, variation 3c+.
2934  else if (ppTune == 31) {
2935  word("PDF:pSet", "13" );
2936  parm("SigmaProcess:alphaSvalue", 0.140 );
2937  parm("TimeShower:alphaSvalue", 0.127 );
2938  parm("SpaceShower:alphaSvalue", 0.140 );
2939  parm("SpaceShower:pT0Ref", 1.56 );
2940  parm("SpaceShower:pTmaxFudge", 0.91 );
2941  parm("SpaceShower:pTdampFudge", 1.05 );
2942  parm("MultipartonInteractions:alphaSvalue",0.126);
2943  parm("MultipartonInteractions:pT0Ref", 2.09 );
2944  parm("BeamRemnants:primordialKThard", 1.88 );
2945  parm("ColourReconnection:range", 1.71 );
2946  }
2947 
2948  // The ATLAS A14 tunes, variation 3c-.
2949  else if (ppTune == 32) {
2950  word("PDF:pSet", "13" );
2951  parm("SigmaProcess:alphaSvalue", 0.140 );
2952  parm("TimeShower:alphaSvalue", 0.127 );
2953  parm("SpaceShower:alphaSvalue", 0.115 );
2954  parm("SpaceShower:pT0Ref", 1.56 );
2955  parm("SpaceShower:pTmaxFudge", 0.91 );
2956  parm("SpaceShower:pTdampFudge", 1.05 );
2957  parm("MultipartonInteractions:alphaSvalue",0.126);
2958  parm("MultipartonInteractions:pT0Ref", 2.09 );
2959  parm("BeamRemnants:primordialKThard", 1.88 );
2960  parm("ColourReconnection:range", 1.71 );
2961  }
2962 
2963  }
2964 
2965 }
2966 
2967 //--------------------------------------------------------------------------
2968 
2969 // Allow several alternative inputs for true/false.
2970 
2971 bool Settings::boolString(string tag) {
2972 
2973  string tagLow = toLower(tag);
2974  return ( tagLow == "true" || tagLow == "1" || tagLow == "on"
2975  || tagLow == "yes" || tagLow == "ok" );
2976 
2977 }
2978 
2979 //--------------------------------------------------------------------------
2980 
2981 // Extract XML value string following XML attribute.
2982 
2983 string Settings::attributeValue(string line, string attribute) {
2984 
2985  if (line.find(attribute) == string::npos) return "";
2986  int iBegAttri = line.find(attribute);
2987  int iBegQuote = line.find("\"", iBegAttri + 1);
2988  int iEndQuote = line.find("\"", iBegQuote + 1);
2989  return line.substr(iBegQuote + 1, iEndQuote - iBegQuote - 1);
2990 
2991 }
2992 
2993 //--------------------------------------------------------------------------
2994 
2995 // Extract XML bool value following XML attribute.
2996 
2997 bool Settings::boolAttributeValue(string line, string attribute) {
2998 
2999  string valString = attributeValue(line, attribute);
3000  if (valString == "") return false;
3001  return boolString(valString);
3002 
3003 }
3004 
3005 //--------------------------------------------------------------------------
3006 
3007 // Extract XML int value following XML attribute.
3008 
3009 int Settings::intAttributeValue(string line, string attribute) {
3010  string valString = attributeValue(line, attribute);
3011  if (valString == "") return 0;
3012  istringstream valStream(valString);
3013  int intVal;
3014  valStream >> intVal;
3015  return intVal;
3016 
3017 }
3018 
3019 //--------------------------------------------------------------------------
3020 
3021 // Extract XML double value following XML attribute.
3022 
3023 double Settings::doubleAttributeValue(string line, string attribute) {
3024  string valString = attributeValue(line, attribute);
3025  if (valString == "") return 0.;
3026  istringstream valStream(valString);
3027  double doubleVal;
3028  valStream >> doubleVal;
3029  return doubleVal;
3030 
3031 }
3032 
3033 //--------------------------------------------------------------------------
3034 
3035 // Extract XML bool vector value following XML attribute.
3036 
3037 vector<bool> Settings::boolVectorAttributeValue(string line,
3038  string attribute) {
3039  string valString = attributeValue(line, attribute);
3040  size_t openBrace = valString.find_first_of("{");
3041  size_t closeBrace = valString.find_last_of("}");
3042  if (openBrace != string::npos)
3043  valString = valString.substr(openBrace + 1, closeBrace - openBrace - 1);
3044  if (valString == "") return vector<bool>();
3045  vector<bool> vectorVal;
3046  size_t stringPos(0);
3047  while (stringPos != string::npos) {
3048  stringPos = valString.find(",");
3049  istringstream valStream(valString.substr(0, stringPos));
3050  valString = valString.substr(stringPos + 1);
3051  vectorVal.push_back(boolString(valStream.str()));
3052  }
3053  return vectorVal;
3054 
3055 }
3056 
3057 //--------------------------------------------------------------------------
3058 
3059 // Extract XML int vector value following XML attribute.
3060 
3061 vector<int> Settings::intVectorAttributeValue(string line,
3062  string attribute) {
3063  string valString = attributeValue(line, attribute);
3064  size_t openBrace = valString.find_first_of("{");
3065  size_t closeBrace = valString.find_last_of("}");
3066  if (openBrace != string::npos)
3067  valString = valString.substr(openBrace + 1, closeBrace - openBrace - 1);
3068  if (valString == "") return vector<int>();
3069  int intVal;
3070  vector<int> vectorVal;
3071  size_t stringPos(0);
3072  while (stringPos != string::npos) {
3073  stringPos = valString.find(",");
3074  istringstream valStream(valString.substr(0, stringPos));
3075  valString = valString.substr(stringPos + 1);
3076  valStream >> intVal;
3077  vectorVal.push_back(intVal);
3078  }
3079  return vectorVal;
3080 
3081 }
3082 
3083 //--------------------------------------------------------------------------
3084 
3085 // Extract XML double vector value following XML attribute.
3086 
3087 vector<double> Settings::doubleVectorAttributeValue(string line,
3088  string attribute) {
3089  string valString = attributeValue(line, attribute);
3090  size_t openBrace = valString.find_first_of("{");
3091  size_t closeBrace = valString.find_last_of("}");
3092  if (openBrace != string::npos)
3093  valString = valString.substr(openBrace + 1, closeBrace - openBrace - 1);
3094  if (valString == "") return vector<double>();
3095  double doubleVal;
3096  vector<double> vectorVal;
3097  size_t stringPos(0);
3098  while (stringPos != string::npos) {
3099  stringPos = valString.find(",");
3100  istringstream valStream(valString.substr(0, stringPos));
3101  valString = valString.substr(stringPos + 1);
3102  valStream >> doubleVal;
3103  vectorVal.push_back(doubleVal);
3104  }
3105  return vectorVal;
3106 
3107 }
3108 
3109 //--------------------------------------------------------------------------
3110 
3111 // Extract XML string vector value following XML attribute.
3112 
3113 vector<string> Settings::stringVectorAttributeValue(string line,
3114  string attribute) {
3115  string valString = attributeValue(line, attribute);
3116  size_t openBrace = valString.find_first_of("{");
3117  size_t closeBrace = valString.find_last_of("}");
3118  if (openBrace != string::npos)
3119  valString = valString.substr(openBrace + 1, closeBrace - openBrace - 1);
3120  if (valString == "") return vector<string>();
3121  string stringVal;
3122  vector<string> vectorVal;
3123  size_t stringPos(0);
3124  while (stringPos != string::npos) {
3125  stringPos = valString.find(",");
3126  if (stringPos != string::npos) {
3127  vectorVal.push_back(valString.substr(0, stringPos));
3128  valString = valString.substr(stringPos + 1);
3129  } else vectorVal.push_back(valString);
3130  }
3131  return vectorVal;
3132 
3133 }
3134 
3135 //==========================================================================
3136 
3137 } // end namespace Pythia8