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) 2014 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, 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, ostream& os) {
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  // List of files to be checked. Start with input file.
31  vector<string> files;
32  files.push_back(startFile);
33 
34  // If nontrivial startfile path, then use that for other files as well.
35  string pathName = "";
36  if (startFile.rfind("/") != string::npos)
37  pathName = startFile.substr(0, startFile.rfind("/") + 1);
38 
39  // Loop over files. Open them for read.
40  for (int i = 0; i < int(files.size()); ++i) {
41  const char* cstring = files[i].c_str();
42  ifstream is(cstring);
43 
44  // Check that instream is OK.
45  if (!is.good()) {
46  os << "\n PYTHIA Error: settings file " << files[i]
47  << " not found" << endl;
48  return false;
49  }
50 
51  // Read in one line at a time.
52  string line;
53  while ( getline(is, line) ) {
54 
55  // Get first word of a line, to interpret it as tag.
56  istringstream getfirst(line);
57  string tag;
58  getfirst >> tag;
59 
60  // Skip ahead if not interesting. Only look for new files in startfile.
61  if (tag != "<flag" && tag != "<flagfix" && tag != "<mode"
62  && tag != "<modeopen" && tag != "<modepick" && tag != "<modefix"
63  && tag != "<parm" && tag != "<parmfix" && tag != "<word"
64  && tag != "<wordfix" && tag != "<fvec" && tag != "<fvecfix"
65  && tag != "<mvec" && tag != "<mvecfix"
66  && tag != "<pvec" && tag != "<pvecfix" && tag != "<aidx") continue;
67 
68  // Read and append continuation line(s) if line does not contain >.
69  while (line.find(">") == string::npos) {
70  string addLine;
71  getline(is, addLine);
72  line += " " + addLine;
73  }
74 
75  // Remove extra blanks before an = sign.
76  while (line.find(" =") != string::npos) line.erase( line.find(" ="), 1);
77 
78  // Add file also to be read.
79  if (tag == "<aidx") {
80  string name = attributeValue( line, "href");
81  if (name == "") {
82  os << " PYTHIA Error: failed to find name attribute in line "
83  << line << endl;
84  ++nError;
85  continue;
86  }
87  files.push_back(pathName + name + ".xml");
88  continue;
89  }
90 
91  // Find name attribute.
92  string name = attributeValue( line, "name=");
93  if (name == "") {
94  os << " PYTHIA Error: failed to find name attribute in line "
95  << line << endl;
96  ++nError;
97  continue;
98  }
99 
100  // Check that default value attribute present, and whether max and min.
101  if (line.find("default=") == string::npos) {
102  os << " PYTHIA Error: failed to find default value token in line "
103  << line << endl;
104  ++nError;
105  continue;
106  }
107  bool hasMin = (line.find("min=") != string::npos);
108  bool hasMax = (line.find("max=") != string::npos);
109 
110  // Check for occurence of a bool and add to flag map.
111  if (tag == "<flag" || tag == "<flagfix") {
112  bool value = boolAttributeValue( line, "default=");
113  addFlag( name, value);
114 
115  // Check for occurence of an int and add to mode map.
116  } else if (tag == "<mode" || tag == "<modeopen"
117  || tag == "<modepick" || tag == "<modefix") {
118  int value = intAttributeValue( line, "default=");
119  int minVal = intAttributeValue( line, "min=");
120  int maxVal = intAttributeValue( line, "max=");
121  addMode( name, value, hasMin, hasMax, minVal, maxVal);
122 
123  // Check for occurence of a double and add to parm map.
124  } else if (tag == "<parm" || tag == "<parmfix") {
125  double value = doubleAttributeValue( line, "default=");
126  double minVal = doubleAttributeValue( line, "min=");
127  double maxVal = doubleAttributeValue( line, "max=");
128  addParm( name, value, hasMin, hasMax, minVal, maxVal);
129 
130  // Check for occurence of a string and add to word map.
131  } else if (tag == "<word" || tag == "<wordfix") {
132  string value = attributeValue( line, "default=");
133  addWord( name, value);
134 
135  // Check for occurence of a bool vector and add to fvec map.
136  } else if (tag == "<fvec" || tag == "<fvecfix") {
137  vector<bool> value = boolVectorAttributeValue( line, "default=");
138  addFVec( name, value);
139 
140  // Check for occurence of an int vector and add to mvec map.
141  } else if (tag == "<mvec" || tag == "<mvecfix") {
142  vector<int> value = intVectorAttributeValue( line, "default=");
143  int minVal = intAttributeValue( line, "min=");
144  int maxVal = intAttributeValue( line, "max=");
145  addMVec( name, value, hasMin, hasMax, minVal, maxVal);
146 
147  // Check for occurence of a double vector and add to pvec map.
148  } else if (tag == "<pvec" || tag == "<pvecfix") {
149  vector<double> value = doubleVectorAttributeValue( line, "default=");
150  double minVal = doubleAttributeValue( line, "min=");
151  double maxVal = doubleAttributeValue( line, "max=");
152  addPVec( name, value, hasMin, hasMax, minVal, maxVal);
153  }
154 
155  // End of loop over lines in input file and loop over files.
156  };
157  };
158 
159  // Set up default e+e- and pp tunes, if positive.
160  int eeTune = mode("Tune:ee");
161  if (eeTune > 0) initTuneEE( eeTune);
162  int ppTune = mode("Tune:pp");
163  if (ppTune > 0) initTunePP( ppTune);
164 
165  // Done.
166  if (nError > 0) return false;
167  isInit = true;
168  return true;
169 
170 }
171 
172 //--------------------------------------------------------------------------
173 
174 // Overwrite existing database by reading from specific file.
175 
176 bool Settings::reInit(string startFile, ostream& os) {
177 
178  // Reset maps to empty.
179  flags.clear();
180  modes.clear();
181  parms.clear();
182  words.clear();
183  fvecs.clear();
184  mvecs.clear();
185  pvecs.clear();
186 
187  // Then let normal init do the rest.
188  isInit = false;
189  return init(startFile, false, os);
190 
191 }
192 
193 //--------------------------------------------------------------------------
194 
195 // Read in updates from a character string, like a line of a file.
196 // Is used by readString (and readFile) in Pythia.
197 
198 bool Settings::readString(string line, bool warn, ostream& os) {
199 
200  // If empty line then done.
201  if (line.find_first_not_of(" \n\t\v\b\r\f\a") == string::npos) return true;
202 
203  // If first character is not a letter, then taken to be a comment line.
204  string lineNow = line;
205  int firstChar = lineNow.find_first_not_of(" \n\t\v\b\r\f\a");
206  if (!isalpha(lineNow[firstChar])) return true;
207 
208  // Replace an equal sign by a blank to make parsing simpler.
209  while (lineNow.find("=") != string::npos) {
210  int firstEqual = lineNow.find_first_of("=");
211  lineNow.replace(firstEqual, 1, " ");
212  }
213 
214  // Get first word of a line.
215  istringstream splitLine(lineNow);
216  string name;
217  splitLine >> name;
218 
219  // Replace two colons by one (:: -> :) to allow for such mistakes.
220  while (name.find("::") != string::npos) {
221  int firstColonColon = name.find_first_of("::");
222  name.replace(firstColonColon, 2, ":");
223  }
224 
225  // Check whether this is in the database.
226  int inDataBase = 0;
227  if (isFlag(name)) inDataBase = 1;
228  else if (isMode(name)) inDataBase = 2;
229  else if (isParm(name)) inDataBase = 3;
230  else if (isWord(name)) inDataBase = 4;
231  else if (isFVec(name)) inDataBase = 5;
232  else if (isMVec(name)) inDataBase = 6;
233  else if (isPVec(name)) inDataBase = 7;
234 
235  // For backwards compatibility: multiple -> multiparton, MI -> MPI,
236  // minBias -> nonDiffractive.
237  if (inDataBase == 0) {
238  bool retry = false;
239  string nameLower = toLower(name);
240  if (nameLower.find("multiple") != string::npos) {
241  int firstMI = nameLower.find_first_of("multiple");
242  name.replace(firstMI, 8, "Multiparton");
243  retry = true;
244  }
245  if (!retry && nameLower.find("mi") != string::npos) {
246  int firstMI = nameLower.find_first_of("mi");
247  name.replace(firstMI, 2, "MPI");
248  retry = true;
249  }
250  if (!retry && nameLower.find("minbias") != string::npos) {
251  int firstMB = nameLower.find_first_of("minbias");
252  name.replace(firstMB, 7, "nonDiffractive");
253  retry = true;
254  }
255  if (retry) {
256  if (isFlag(name)) inDataBase = 1;
257  else if (isMode(name)) inDataBase = 2;
258  else if (isParm(name)) inDataBase = 3;
259  else if (isWord(name)) inDataBase = 4;
260  else if (isFVec(name)) inDataBase = 5;
261  else if (isMVec(name)) inDataBase = 6;
262  else if (isPVec(name)) inDataBase = 7;
263  }
264  }
265 
266  // Warn and done if not in database.
267  if (inDataBase == 0) {
268  if (warn) os << "\n PYTHIA Error: input string not found in settings"
269  << " databases::\n " << line << endl;
270  readingFailedSave = true;
271  return false;
272  }
273 
274  // Find value. Warn if none found.
275  string valueString;
276  splitLine >> valueString;
277  if (!splitLine) {
278  if (warn) os << "\n PYTHIA Error: variable recognized, but its value"
279  << " not meaningful:\n " << line << endl;
280  readingFailedSave = true;
281  return false;
282  }
283 
284  // Update flag map; allow many ways to say yes.
285  if (inDataBase == 1) {
286  bool value = boolString(valueString);
287  flag(name, value);
288 
289  // Update mode map.
290  } else if (inDataBase == 2) {
291  istringstream modeData(valueString);
292  int value;
293  modeData >> value;
294  if (!modeData) {
295  if (warn) os << "\n PYTHIA Error: variable recognized, but its value"
296  << " not meaningful:\n " << line << endl;
297  readingFailedSave = true;
298  return false;
299  }
300  mode(name, value);
301 
302  // Update parm map.
303  } else if (inDataBase == 3) {
304  istringstream parmData(valueString);
305  double value;
306  parmData >> value;
307  if (!parmData) {
308  if (warn) os << "\n PYTHIA Error: variable recognized, but its value"
309  << " not meaningful:\n " << line << endl;
310  readingFailedSave = true;
311  return false;
312  }
313  parm(name, value);
314 
315  // Update word map.
316  } else if (inDataBase == 4) {
317  word(name, valueString);
318 
319  // Update fvec map.
320  } else if (inDataBase == 5) {
321  istringstream fvecData(valueString);
322  vector<bool> value(boolVectorAttributeValue(
323  "value=\"" + valueString + "\"", "value="));
324  if (!fvecData) {
325  if (warn) os << "\n PYTHIA Error: variable recognized, but its value"
326  << " not meaningful:\n " << line << endl;
327  readingFailedSave = true;
328  return false;
329  }
330  fvec(name, value);
331 
332  // Update mvec map.
333  } else if (inDataBase == 6) {
334  istringstream mvecData(valueString);
335  vector<int> value(intVectorAttributeValue(
336  "value=\"" + valueString + "\"", "value="));
337  if (!mvecData) {
338  if (warn) os << "\n PYTHIA Error: variable recognized, but its value"
339  << " not meaningful:\n " << line << endl;
340  readingFailedSave = true;
341  return false;
342  }
343  mvec(name, value);
344 
345  // Update pvec map.
346  } else if (inDataBase == 7) {
347  istringstream pvecData(valueString);
348  vector<double> value(doubleVectorAttributeValue(
349  "value=\"" + valueString + "\"", "value="));
350  if (!pvecData) {
351  if (warn) os << "\n PYTHIA Error: variable recognized, but its value"
352  << " not meaningful:\n " << line << endl;
353  readingFailedSave = true;
354  return false;
355  }
356  pvec(name, value);
357  }
358 
359  // Done.
360  return true;
361 }
362 
363 //--------------------------------------------------------------------------
364 
365 // Write updates or everything to user-defined file.
366 
367 bool Settings::writeFile(string toFile, bool writeAll) {
368 
369  // Open file for writing.
370  const char* cstring = toFile.c_str();
371  ofstream os(cstring);
372  if (!os) {
373  infoPtr->errorMsg("Error in Settings::writeFile:"
374  " could not open file", toFile);
375  return false;
376  }
377 
378  // Hand over real work to next method.
379  return writeFile( os, writeAll);
380 
381 }
382 
383 //--------------------------------------------------------------------------
384 
385 // Write updates or everything to user-defined stream (or file).
386 
387 bool Settings::writeFile(ostream& os, bool writeAll) {
388 
389  // Write simple header as comment.
390  if (writeAll) os << "! List of all current PYTHIA ";
391  else os << "! List of all modified PYTHIA ";
392  os << fixed << setprecision(3) << parm("Pythia:versionNumber")
393  << " settings.\n";
394 
395  // Iterators for the flag, mode and parm tables.
396  map<string, Flag>::iterator flagEntry = flags.begin();
397  map<string, Mode>::iterator modeEntry = modes.begin();
398  map<string, Parm>::iterator parmEntry = parms.begin();
399  map<string, Word>::iterator wordEntry = words.begin();
400  map<string, FVec>::iterator fvecEntry = fvecs.begin();
401  map<string, MVec>::iterator mvecEntry = mvecs.begin();
402  map<string, PVec>::iterator pvecEntry = pvecs.begin();
403 
404  // Loop while there is something left to do.
405  while (flagEntry != flags.end() || modeEntry != modes.end()
406  || parmEntry != parms.end() || wordEntry != words.end()
407  || fvecEntry != fvecs.end() || mvecEntry != mvecs.end()
408  || pvecEntry != pvecs.end() ) {
409 
410  // Check if a flag is next in lexigraphical order; if so print it.
411  if ( flagEntry != flags.end()
412  && ( modeEntry == modes.end() || flagEntry->first < modeEntry->first )
413  && ( parmEntry == parms.end() || flagEntry->first < parmEntry->first )
414  && ( wordEntry == words.end() || flagEntry->first < wordEntry->first )
415  && ( fvecEntry == fvecs.end() || flagEntry->first < fvecEntry->first )
416  && ( mvecEntry == mvecs.end() || flagEntry->first < mvecEntry->first )
417  && ( pvecEntry == pvecs.end() || flagEntry->first < pvecEntry->first )
418  ) {
419  string state[2] = {"off", "on"};
420  bool valNow = flagEntry->second.valNow;
421  bool valDefault = flagEntry->second.valDefault;
422  if ( writeAll || valNow != valDefault )
423  os << flagEntry->second.name << " = " << state[valNow] << "\n";
424  ++flagEntry;
425 
426  // Else check if mode is next, and if so print it.
427  } else if ( modeEntry != modes.end()
428  && ( parmEntry == parms.end() || modeEntry->first < parmEntry->first )
429  && ( wordEntry == words.end() || modeEntry->first < wordEntry->first )
430  && ( fvecEntry == fvecs.end() || modeEntry->first < fvecEntry->first )
431  && ( mvecEntry == mvecs.end() || modeEntry->first < mvecEntry->first )
432  && ( pvecEntry == pvecs.end() || modeEntry->first < pvecEntry->first )
433  ) {
434  int valNow = modeEntry->second.valNow;
435  int valDefault = modeEntry->second.valDefault;
436  if ( writeAll || valNow != valDefault )
437  os << modeEntry->second.name << " = " << valNow << "\n";
438  ++modeEntry;
439 
440  // Else check if parm is next, and if so print it;
441  // fixed or scientific depending on value.
442  } else if ( parmEntry != parms.end()
443  && ( wordEntry == words.end() || parmEntry->first < wordEntry->first )
444  && ( fvecEntry == fvecs.end() || parmEntry->first < fvecEntry->first )
445  && ( mvecEntry == mvecs.end() || parmEntry->first < mvecEntry->first )
446  && ( pvecEntry == pvecs.end() || parmEntry->first < pvecEntry->first )
447  ) {
448  double valNow = parmEntry->second.valNow;
449  double valDefault = parmEntry->second.valDefault;
450  if ( writeAll || valNow != valDefault ) {
451  os << parmEntry->second.name << " = ";
452  if ( valNow == 0. ) os << fixed << setprecision(1);
453  else if ( abs(valNow) < 0.001 ) os << scientific << setprecision(4);
454  else if ( abs(valNow) < 0.1 ) os << fixed << setprecision(7);
455  else if ( abs(valNow) < 1000. ) os << fixed << setprecision(5);
456  else if ( abs(valNow) < 1000000. ) os << fixed << setprecision(3);
457  else os << scientific << setprecision(4);
458  os << valNow << "\n";
459  }
460  ++parmEntry;
461 
462  // Else check if word is next, and if so print it.
463  } else if ( wordEntry != words.end()
464  && ( fvecEntry == fvecs.end() || wordEntry->first < fvecEntry->first )
465  && ( mvecEntry == mvecs.end() || wordEntry->first < mvecEntry->first )
466  && ( pvecEntry == pvecs.end() || wordEntry->first < pvecEntry->first )
467  ) {
468  string valNow = wordEntry->second.valNow;
469  string valDefault = wordEntry->second.valDefault;
470  if ( writeAll || valNow != valDefault )
471  os << wordEntry->second.name << " = " << valNow << "\n";
472  ++wordEntry;
473 
474  // Else check if fvec is next, and if so print it.
475  } else if ( fvecEntry != fvecs.end()
476  && ( mvecEntry == mvecs.end() || fvecEntry->first < mvecEntry->first )
477  && ( pvecEntry == pvecs.end() || fvecEntry->first < pvecEntry->first )
478  ) {
479  string state[2] = {"off", "on"};
480  vector<bool> valNow = fvecEntry->second.valNow;
481  vector<bool> valDefault = fvecEntry->second.valDefault;
482  if ( writeAll || valNow != valDefault ) {
483  os << fvecEntry->second.name << " = ";
484  for (vector<bool>::iterator val = valNow.begin();
485  val != --valNow.end(); ++val) os << state[*val] << ",";
486  os << *(--valNow.end()) << "\n";
487  }
488  ++fvecEntry;
489 
490  // Else check if mvec is next, and if so print it.
491  } else if ( mvecEntry != mvecs.end()
492  && ( pvecEntry == pvecs.end() || mvecEntry->first < pvecEntry->first )
493  ) {
494  vector<int> valNow = mvecEntry->second.valNow;
495  vector<int> valDefault = mvecEntry->second.valDefault;
496  if ( writeAll || valNow != valDefault ) {
497  os << mvecEntry->second.name << " = ";
498  for (vector<int>::iterator val = valNow.begin();
499  val != --valNow.end(); ++val) os << *val << ",";
500  os << *(--valNow.end()) << "\n";
501  }
502  ++mvecEntry;
503 
504  // Else print pvec; fixed or scientific depending on value.
505  } else {
506  vector<double> valNow = pvecEntry->second.valNow;
507  vector<double> valDefault = pvecEntry->second.valDefault;
508  if ( writeAll || valNow != valDefault ) {
509  os << pvecEntry->second.name << " = ";
510  for (vector<double>::iterator val = valNow.begin();
511  val != --valNow.end(); ++val) {
512  if ( *val == 0. ) os << fixed << setprecision(1);
513  else if ( abs(*val) < 0.001 ) os << scientific << setprecision(4);
514  else if ( abs(*val) < 0.1 ) os << fixed << setprecision(7);
515  else if ( abs(*val) < 1000. ) os << fixed << setprecision(5);
516  else if ( abs(*val) < 1000000. ) os << fixed << setprecision(3);
517  else os << scientific << setprecision(4);
518  os << *val << ",";
519  } os << *(--valNow.end()) << "\n";
520  }
521  ++pvecEntry;
522  }
523  } ;
524 
525  // Done.
526  return true;
527 }
528 
529 //--------------------------------------------------------------------------
530 
531 // Print out table of database in lexigraphical order.
532 
533 void Settings::list(bool doListAll, bool doListString, string match,
534  ostream& os) {
535 
536  // Table header; output for bool as off/on.
537  if (doListAll)
538  os << "\n *------- PYTHIA Flag + Mode + Parm + Word + FVec + MVec + PVec "
539  << "Settings (all) ----------------------------------* \n";
540  else if (!doListString)
541  os << "\n *------- PYTHIA Flag + Mode + Parm + Word + FVec + MVec + PVec "
542  << "Settings (changes only) -------------------------* \n" ;
543  else
544  os << "\n *------- PYTHIA Flag + Mode + Parm + Word + FVec + MVec + PVec "
545  << "Settings (with requested string) -----------------* \n" ;
546  os << " | "
547  << " | \n"
548  << " | Name | "
549  << " Now | Default Min Max | \n"
550  << " | | "
551  << " | | \n";
552 
553  // Convert input string to lowercase for match.
554  match = toLower(match);
555  if (match == "") match = " ";
556 
557  // Iterators for the flag, mode and parm tables.
558  map<string, Flag>::iterator flagEntry = flags.begin();
559  map<string, Mode>::iterator modeEntry = modes.begin();
560  map<string, Parm>::iterator parmEntry = parms.begin();
561  map<string, Word>::iterator wordEntry = words.begin();
562  map<string, FVec>::iterator fvecEntry = fvecs.begin();
563  map<string, MVec>::iterator mvecEntry = mvecs.begin();
564  map<string, PVec>::iterator pvecEntry = pvecs.begin();
565 
566  // Loop while there is something left to do.
567  while (flagEntry != flags.end() || modeEntry != modes.end()
568  || parmEntry != parms.end() || wordEntry != words.end()
569  || fvecEntry != fvecs.end() || mvecEntry != mvecs.end()
570  || pvecEntry != pvecs.end() ) {
571 
572  // Check if a flag is next in lexigraphical order; if so print it.
573  if ( flagEntry != flags.end()
574  && ( modeEntry == modes.end() || flagEntry->first < modeEntry->first )
575  && ( parmEntry == parms.end() || flagEntry->first < parmEntry->first )
576  && ( wordEntry == words.end() || flagEntry->first < wordEntry->first )
577  && ( fvecEntry == fvecs.end() || flagEntry->first < fvecEntry->first )
578  && ( mvecEntry == mvecs.end() || flagEntry->first < mvecEntry->first )
579  && ( pvecEntry == pvecs.end() || flagEntry->first < pvecEntry->first )
580  ) {
581  string state[2] = {"off", "on"};
582  bool valNow = flagEntry->second.valNow;
583  bool valDefault = flagEntry->second.valDefault;
584  if ( doListAll || (!doListString && valNow != valDefault)
585  || (doListString && flagEntry->first.find(match) != string::npos) )
586  os << " | " << setw(45) << left
587  << flagEntry->second.name << " | " << setw(24) << right
588  << state[valNow] << " | " << setw(12) << state[valDefault]
589  << " | \n";
590  ++flagEntry;
591 
592  // Else check if mode is next, and if so print it.
593  } else if ( modeEntry != modes.end()
594  && ( parmEntry == parms.end() || modeEntry->first < parmEntry->first )
595  && ( wordEntry == words.end() || modeEntry->first < wordEntry->first )
596  && ( fvecEntry == fvecs.end() || modeEntry->first < fvecEntry->first )
597  && ( mvecEntry == mvecs.end() || modeEntry->first < mvecEntry->first )
598  && ( pvecEntry == pvecs.end() || modeEntry->first < pvecEntry->first )
599  ) {
600  int valNow = modeEntry->second.valNow;
601  int valDefault = modeEntry->second.valDefault;
602  if ( doListAll || (!doListString && valNow != valDefault)
603  || (doListString && modeEntry->first.find(match) != string::npos) ) {
604  os << " | " << setw(45) << left
605  << modeEntry->second.name << " | " << setw(24) << right
606  << valNow << " | " << setw(12) << valDefault;
607  if (modeEntry->second.hasMin)
608  os << setw(12) << modeEntry->second.valMin;
609  else os << " ";
610  if (modeEntry->second.hasMax)
611  os << setw(12) << modeEntry->second.valMax;
612  else os << " ";
613  os << " | \n";
614  }
615  ++modeEntry;
616 
617  // Else check if parm is next, and if so print it;
618  // fixed or scientific depending on value.
619  } else if ( parmEntry != parms.end()
620  && ( wordEntry == words.end() || parmEntry->first < wordEntry->first )
621  && ( fvecEntry == fvecs.end() || parmEntry->first < fvecEntry->first )
622  && ( mvecEntry == mvecs.end() || parmEntry->first < mvecEntry->first )
623  && ( pvecEntry == pvecs.end() || parmEntry->first < pvecEntry->first )
624  ) {
625  double valNow = parmEntry->second.valNow;
626  double valDefault = parmEntry->second.valDefault;
627  if ( doListAll || (!doListString && valNow != valDefault )
628  || (doListString && parmEntry->first.find(match) != string::npos) ) {
629  os << " | " << setw(45) << left
630  << parmEntry->second.name << right << " | ";
631  for (int i = 0; i < 4; ++i) {
632  if (i == 1) valNow = valDefault;
633  if (i == 2) valNow = parmEntry->second.valMin;
634  if (i == 3) valNow = parmEntry->second.valMax;
635  if ( (i == 2 && !parmEntry->second.hasMin)
636  || (i == 3 && !parmEntry->second.hasMax) )
637  os << " ";
638  else if ( valNow == 0. )
639  os << fixed << setprecision(1) << setw(12) << valNow;
640  else if ( abs(valNow) < 0.001 )
641  os << scientific << setprecision(4) << setw(12) << valNow;
642  else if ( abs(valNow) < 0.1 )
643  os << fixed << setprecision(7) << setw(12) << valNow;
644  else if ( abs(valNow) < 1000. )
645  os << fixed << setprecision(5) << setw(12) << valNow;
646  else if ( abs(valNow) < 1000000. )
647  os << fixed << setprecision(3) << setw(12) << valNow;
648  else
649  os << scientific << setprecision(4) << setw(12) << valNow;
650  if (i == 0) os << " | ";
651  }
652  os << " | \n";
653  }
654  ++parmEntry;
655 
656  // Else check if word is next, and if so print it.
657  } else if ( wordEntry != words.end()
658  && ( fvecEntry == fvecs.end() || wordEntry->first < fvecEntry->first )
659  && ( mvecEntry == mvecs.end() || wordEntry->first < mvecEntry->first )
660  && ( pvecEntry == pvecs.end() || wordEntry->first < pvecEntry->first )
661  ) {
662  string valNow = wordEntry->second.valNow;
663  string valDefault = wordEntry->second.valDefault;
664  int blankLeft = max(0, 60 - max(24, int(valNow.length()) )
665  - max(12, int(valDefault.length()) ) );
666  string blankPad( blankLeft, ' ');
667  if ( doListAll || (!doListString && valNow != valDefault)
668  || (doListString && wordEntry->first.find(match) != string::npos) )
669  os << " | " << setw(45) << left
670  << wordEntry->second.name << " | " << setw(24) << right
671  << valNow << " | " << setw(12) << valDefault << blankPad
672  << " | \n";
673  ++wordEntry;
674 
675  // Else check if fvec is next, and if so print it.
676  } else if ( fvecEntry != fvecs.end()
677  && ( mvecEntry == mvecs.end() || fvecEntry->first < mvecEntry->first )
678  && ( pvecEntry == pvecs.end() || fvecEntry->first < pvecEntry->first )
679  ) {
680  string state[2] = {"off", "on"};
681  vector<bool> valsNow = fvecEntry->second.valNow;
682  vector<bool> valsDefault = fvecEntry->second.valDefault;
683  bool valNow(false), valDefault(false);
684  if ( doListAll || (!doListString && valsNow != valsDefault )
685  || (doListString && fvecEntry->first.find(match) != string::npos) ) {
686  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
687  ++i) {
688  if ( i == 0 )
689  os << " | " << setw(45) << left
690  << fvecEntry->second.name << right << " | ";
691  else
692  os << " | " << setw(45) << " " << right << " | ";
693  for (int j = 0; j < 4; ++j) {
694  if (i < valsNow.size()) valNow = valsNow[i];
695  if (i < valsDefault.size()) valDefault = valsDefault[i];
696  if (j == 1) valNow = valDefault;
697  if ( (j == 0 && i >= valsNow.size())
698  || (j == 1 && i >= valsDefault.size()) || (j > 1) )
699  os << " ";
700  else os << setw(12) << state[valNow];
701  if (j == 0) os << " | ";
702  }
703  os << " | \n";
704  }
705  }
706  ++fvecEntry;
707 
708  // Else check if mvec is next, and if so print it.
709  } else if ( mvecEntry != mvecs.end()
710  && ( pvecEntry == pvecs.end() || mvecEntry->first < pvecEntry->first )
711  ) {
712  vector<int> valsNow = mvecEntry->second.valNow;
713  vector<int> valsDefault = mvecEntry->second.valDefault;
714  int valNow(0), valDefault(0);
715  if ( doListAll || (!doListString && valsNow != valsDefault )
716  || (doListString && mvecEntry->first.find(match) != string::npos) ) {
717  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
718  ++i) {
719  if ( i == 0 )
720  os << " | " << setw(45) << left
721  << mvecEntry->second.name << right << " | ";
722  else
723  os << " | " << setw(45) << " " << right << " | ";
724  for (int j = 0; j < 4; ++j) {
725  if (i < valsNow.size()) valNow = valsNow[i];
726  if (i < valsDefault.size()) valDefault = valsDefault[i];
727  if (j == 1) valNow = valDefault;
728  if (j == 2) valNow = mvecEntry->second.valMin;
729  if (j == 3) valNow = mvecEntry->second.valMax;
730  if ( (j == 0 && i >= valsNow.size())
731  || (j == 1 && i >= valsDefault.size())
732  || (j == 2 && !mvecEntry->second.hasMin)
733  || (j == 3 && !mvecEntry->second.hasMax) )
734  os << " ";
735  else os << setw(12) << valNow;
736  if (j == 0) os << " | ";
737  }
738  os << " | \n";
739  }
740  }
741  ++mvecEntry;
742 
743  // Else print pvec; fixed or scientific depending on value.
744  } else {
745  vector<double> valsNow = pvecEntry->second.valNow;
746  vector<double> valsDefault = pvecEntry->second.valDefault;
747  double valNow(0), valDefault(0);
748  if ( doListAll || (!doListString && valsNow != valsDefault )
749  || (doListString && pvecEntry->first.find(match) != string::npos) ) {
750  for (unsigned int i = 0; i < valsNow.size() || i < valsDefault.size();
751  ++i) {
752  if ( i == 0 )
753  os << " | " << setw(45) << left
754  << pvecEntry->second.name << right << " | ";
755  else
756  os << " | " << setw(45) << " " << right << " | ";
757  for (int j = 0; j < 4; ++j) {
758  if (i < valsNow.size()) valNow = valsNow[i];
759  if (i < valsDefault.size()) valDefault = valsDefault[i];
760  if (j == 1) valNow = valDefault;
761  if (j == 2) valNow = pvecEntry->second.valMin;
762  if (j == 3) valNow = pvecEntry->second.valMax;
763  if ( (j == 0 && i >= valsNow.size())
764  || (j == 1 && i >= valsDefault.size())
765  || (j == 2 && !pvecEntry->second.hasMin)
766  || (j == 3 && !pvecEntry->second.hasMax) )
767  os << " ";
768  else if ( valNow == 0. )
769  os << fixed << setprecision(1) << setw(12) << valNow;
770  else if ( abs(valNow) < 0.001 )
771  os << scientific << setprecision(4) << setw(12) << valNow;
772  else if ( abs(valNow) < 0.1 )
773  os << fixed << setprecision(7) << setw(12) << valNow;
774  else if ( abs(valNow) < 1000. )
775  os << fixed << setprecision(5) << setw(12) << valNow;
776  else if ( abs(valNow) < 1000000. )
777  os << fixed << setprecision(3) << setw(12) << valNow;
778  else
779  os << scientific << setprecision(4) << setw(12) << valNow;
780  if (j == 0) os << " | ";
781  }
782  os << " | \n";
783  }
784  }
785  ++pvecEntry;
786 
787  }
788  } ;
789 
790  // End of loop over database contents.
791  os << " | "
792  << " | \n"
793  << " *------- End PYTHIA Flag + Mode + Parm + Word + FVec + MVec + PVec "
794  << "Settings ------------------------------------* " << endl;
795 
796 }
797 
798 //--------------------------------------------------------------------------
799 
800 // Reset all values to their defaults.
801 
802 void Settings::resetAll() {
803 
804  // Loop through the flags table, resetting all entries.
805  for (map<string, Flag>::iterator flagEntry = flags.begin();
806  flagEntry != flags.end(); ++flagEntry) {
807  string name = flagEntry->first;
808  resetFlag(name);
809  }
810 
811  // Loop through the modes table, resetting all entries.
812  for (map<string, Mode>::iterator modeEntry = modes.begin();
813  modeEntry != modes.end(); ++modeEntry) {
814  string name = modeEntry->first;
815  resetMode(name);
816  }
817 
818  // Loop through the parms table, resetting all entries.
819  for (map<string, Parm>::iterator parmEntry = parms.begin();
820  parmEntry != parms.end(); ++parmEntry) {
821  string name = parmEntry->first;
822  resetParm(name);
823  }
824 
825  // Loop through the words table, resetting all entries.
826  for (map<string, Word>::iterator wordEntry = words.begin();
827  wordEntry != words.end(); ++wordEntry) {
828  string name = wordEntry->first;
829  resetWord(name);
830  }
831 
832  // Loop through the fvecs table, resetting all entries.
833  for (map<string, FVec>::iterator fvecEntry = fvecs.begin();
834  fvecEntry != fvecs.end(); ++fvecEntry) {
835  string name = fvecEntry->first;
836  resetFVec(name);
837  }
838 
839  // Loop through the mvecs table, resetting all entries.
840  for (map<string, MVec>::iterator mvecEntry = mvecs.begin();
841  mvecEntry != mvecs.end(); ++mvecEntry) {
842  string name = mvecEntry->first;
843  resetMVec(name);
844  }
845 
846  // Loop through the pvecs table, resetting all entries.
847  for (map<string, PVec>::iterator pvecEntry = pvecs.begin();
848  pvecEntry != pvecs.end(); ++pvecEntry) {
849  string name = pvecEntry->first;
850  resetPVec(name);
851  }
852 
853 }
854 
855 //--------------------------------------------------------------------------
856 
857 // Give back current value, with check that key exists.
858 
859 bool Settings::flag(string keyIn) {
860  if (isFlag(keyIn)) return flags[toLower(keyIn)].valNow;
861  infoPtr->errorMsg("Error in Settings::flag: unknown key", keyIn);
862  return false;
863 }
864 
865 int Settings::mode(string keyIn) {
866  if (isMode(keyIn)) return modes[toLower(keyIn)].valNow;
867  infoPtr->errorMsg("Error in Settings::mode: unknown key", keyIn);
868  return 0;
869 }
870 
871 double Settings::parm(string keyIn) {
872  if (isParm(keyIn)) return parms[toLower(keyIn)].valNow;
873  infoPtr->errorMsg("Error in Settings::parm: unknown key", keyIn);
874  return 0.;
875 }
876 
877 string Settings::word(string keyIn) {
878  if (isWord(keyIn)) return words[toLower(keyIn)].valNow;
879  infoPtr->errorMsg("Error in Settings::word: unknown key", keyIn);
880  return " ";
881 }
882 
883 vector<bool> Settings::fvec(string keyIn) {
884  if (isFVec(keyIn)) return fvecs[toLower(keyIn)].valNow;
885  infoPtr->errorMsg("Error in Settings::fvec: unknown key", keyIn);
886  return vector<bool>(1, false);
887 }
888 
889 vector<int> Settings::mvec(string keyIn) {
890  if (isMVec(keyIn)) return mvecs[toLower(keyIn)].valNow;
891  infoPtr->errorMsg("Error in Settings::mvec: unknown key", keyIn);
892  return vector<int>(1, 0);
893 }
894 
895 vector<double> Settings::pvec(string keyIn) {
896  if (isPVec(keyIn)) return pvecs[toLower(keyIn)].valNow;
897  infoPtr->errorMsg("Error in Settings::pvec: unknown key", keyIn);
898  return vector<double>(1, 0.);
899 }
900 
901 //--------------------------------------------------------------------------
902 
903 // Give back default value, with check that key exists.
904 
905 bool Settings::flagDefault(string keyIn) {
906  if (isFlag(keyIn)) return flags[toLower(keyIn)].valDefault;
907  infoPtr->errorMsg("Error in Settings::flagDefault: unknown key", keyIn);
908  return false;
909 }
910 
911 int Settings::modeDefault(string keyIn) {
912  if (isMode(keyIn)) return modes[toLower(keyIn)].valDefault;
913  infoPtr->errorMsg("Error in Settings::modeDefault: unknown key", keyIn);
914  return 0;
915 }
916 
917 double Settings::parmDefault(string keyIn) {
918  if (isParm(keyIn)) return parms[toLower(keyIn)].valDefault;
919  infoPtr->errorMsg("Error in Settings::parmDefault: unknown key", keyIn);
920  return 0.;
921 }
922 
923 string Settings::wordDefault(string keyIn) {
924  if (isWord(keyIn)) return words[toLower(keyIn)].valDefault;
925  infoPtr->errorMsg("Error in Settings::wordDefault: unknown key", keyIn);
926  return " ";
927 }
928 
929 vector<bool> Settings::fvecDefault(string keyIn) {
930  if (isFVec(keyIn)) return fvecs[toLower(keyIn)].valDefault;
931  infoPtr->errorMsg("Error in Settings::fvecDefault: unknown key", keyIn);
932  return vector<bool>(1, false);
933 }
934 
935 vector<int> Settings::mvecDefault(string keyIn) {
936  if (isMVec(keyIn)) return mvecs[toLower(keyIn)].valDefault;
937  infoPtr->errorMsg("Error in Settings::mvecDefault: unknown key", keyIn);
938  return vector<int>(1, 0);
939 }
940 
941 vector<double> Settings::pvecDefault(string keyIn) {
942  if (isPVec(keyIn)) return pvecs[toLower(keyIn)].valDefault;
943  infoPtr->errorMsg("Error in Settings::pvecDefault: unknown key", keyIn);
944  return vector<double>(1, 0.);
945 }
946 
947 //--------------------------------------------------------------------------
948 
949 // Get a map of entries whose names contain the string "match".
950 
951 map<string, Flag> Settings::getFlagMap(string match) {
952  // Make the match string lower case. Start with an empty map.
953  match = toLower(match);
954  map<string, Flag> flagMap;
955  // Loop over the flag map (using iterator).
956  for (map<string,Flag>::iterator flagEntry = flags.begin();
957  flagEntry != flags.end(); ++flagEntry)
958  if (flagEntry->first.find(match) != string::npos)
959  flagMap[flagEntry->first] = flagEntry->second;
960  return flagMap;
961 }
962 
963 map<string, Mode> Settings::getModeMap(string match) {
964  // Make the match string lower case. Start with an empty map.
965  match = toLower(match);
966  map<string, Mode> modeMap;
967  // Loop over the mode map (using iterator).
968  for (map<string,Mode>::iterator modeEntry = modes.begin();
969  modeEntry != modes.end(); ++modeEntry)
970  if (modeEntry->first.find(match) != string::npos)
971  modeMap[modeEntry->first] = modeEntry->second;
972  return modeMap;
973 }
974 
975 map<string, Parm> Settings::getParmMap(string match) {
976  // Make the match string lower case. Start with an empty map.
977  match = toLower(match);
978  map<string, Parm> parmMap;
979  // Loop over the parm map (using iterator).
980  for (map<string,Parm>::iterator parmEntry = parms.begin();
981  parmEntry != parms.end(); ++parmEntry)
982  if (parmEntry->first.find(match) != string::npos)
983  parmMap[parmEntry->first] = parmEntry->second;
984  return parmMap;
985 }
986 
987 map<string, Word> Settings::getWordMap(string match) {
988  // Make the match string lower case. Start with an empty map.
989  match = toLower(match);
990  map<string, Word> wordMap;
991  // Loop over the word map (using iterator).
992  for (map<string,Word>::iterator wordEntry = words.begin();
993  wordEntry != words.end(); ++wordEntry)
994  if (wordEntry->first.find(match) != string::npos)
995  wordMap[wordEntry->first] = wordEntry->second;
996  return wordMap;
997 }
998 
999 map<string, FVec> Settings::getFVecMap(string match) {
1000  // Make the match string lower case. Start with an empty map.
1001  match = toLower(match);
1002  map<string, FVec> fvecMap;
1003  // Loop over the fvec map (using iterator).
1004  for (map<string,FVec>::iterator fvecEntry = fvecs.begin();
1005  fvecEntry != fvecs.end(); ++fvecEntry)
1006  if (fvecEntry->first.find(match) != string::npos)
1007  fvecMap[fvecEntry->first] = fvecEntry->second;
1008  return fvecMap;
1009 }
1010 
1011 map<string, MVec> Settings::getMVecMap(string match) {
1012  // Make the match string lower case. Start with an empty map.
1013  match = toLower(match);
1014  map<string, MVec> mvecMap;
1015  // Loop over the mvec map (using iterator).
1016  for (map<string,MVec>::iterator mvecEntry = mvecs.begin();
1017  mvecEntry != mvecs.end(); ++mvecEntry)
1018  if (mvecEntry->first.find(match) != string::npos)
1019  mvecMap[mvecEntry->first] = mvecEntry->second;
1020  return mvecMap;
1021 }
1022 
1023 map<string, PVec> Settings::getPVecMap(string match) {
1024  // Make the match string lower case. Start with an empty map.
1025  match = toLower(match);
1026  map<string, PVec> pvecMap;
1027  // Loop over the pvec map (using iterator).
1028  for (map<string,PVec>::iterator pvecEntry = pvecs.begin();
1029  pvecEntry != pvecs.end(); ++pvecEntry)
1030  if (pvecEntry->first.find(match) != string::npos)
1031  pvecMap[pvecEntry->first] = pvecEntry->second;
1032  return pvecMap;
1033 }
1034 
1035 //--------------------------------------------------------------------------
1036 
1037 // Change current value, respecting limits.
1038 
1039 void Settings::flag(string keyIn, bool nowIn) {
1040  string keyLower = toLower(keyIn);
1041  if (isFlag(keyIn)) flags[keyLower].valNow = nowIn;
1042  // Print:quiet triggers a whole set of changes.
1043  if (keyLower == "print:quiet") printQuiet( nowIn);
1044 }
1045 
1046 void Settings:: mode(string keyIn, int nowIn) {
1047  if (isMode(keyIn)) {
1048  string keyLower = toLower(keyIn);
1049  Mode& modeNow = modes[keyLower];
1050  if (modeNow.hasMin && nowIn < modeNow.valMin)
1051  modeNow.valNow = modeNow.valMin;
1052  else if (modeNow.hasMax && nowIn > modeNow.valMax)
1053  modeNow.valNow = modeNow.valMax;
1054  else modeNow.valNow = nowIn;
1055  // Tune:ee and Tune:pp each trigger a whole set of changes.
1056  if (keyLower == "tune:ee") initTuneEE( modeNow.valNow);
1057  if (keyLower == "tune:pp") initTunePP( modeNow.valNow);
1058  }
1059 }
1060 
1061 void Settings::parm(string keyIn, double nowIn) {
1062  if (isParm(keyIn)) {
1063  Parm& parmNow = parms[toLower(keyIn)];
1064  if (parmNow.hasMin && nowIn < parmNow.valMin)
1065  parmNow.valNow = parmNow.valMin;
1066  else if (parmNow.hasMax && nowIn > parmNow.valMax)
1067  parmNow.valNow = parmNow.valMax;
1068  else parmNow.valNow = nowIn;
1069  }
1070 }
1071 
1072 void Settings::word(string keyIn, string nowIn) {
1073  if (isWord(keyIn)) words[toLower(keyIn)].valNow = nowIn;
1074 }
1075 
1076 void Settings::fvec(string keyIn, vector<bool> nowIn) {
1077  if (isFVec(keyIn)) {
1078  FVec& fvecNow = fvecs[toLower(keyIn)];
1079  fvecNow.valNow.clear();
1080  for(vector<bool>::iterator now = nowIn.begin();
1081  now != nowIn.end(); now++)
1082  fvecNow.valNow.push_back(*now);
1083  }
1084 }
1085 
1086 void Settings::mvec(string keyIn, vector<int> nowIn) {
1087  if (isMVec(keyIn)) {
1088  MVec& mvecNow = mvecs[toLower(keyIn)];
1089  mvecNow.valNow.clear();
1090  for(vector<int>::iterator now = nowIn.begin();
1091  now != nowIn.end(); now++) {
1092  if (mvecNow.hasMin && *now < mvecNow.valMin)
1093  mvecNow.valNow.push_back(mvecNow.valMin);
1094  else if (mvecNow.hasMax && *now > mvecNow.valMax)
1095  mvecNow.valNow.push_back(mvecNow.valMax);
1096  else mvecNow.valNow.push_back(*now);
1097  }
1098  }
1099 }
1100 
1101 void Settings::pvec(string keyIn, vector<double> nowIn) {
1102  if (isPVec(keyIn)) {
1103  PVec& pvecNow = pvecs[toLower(keyIn)];
1104  pvecNow.valNow.clear();
1105  for(vector<double>::iterator now = nowIn.begin();
1106  now != nowIn.end(); now++) {
1107  if (pvecNow.hasMin && *now < pvecNow.valMin)
1108  pvecNow.valNow.push_back(pvecNow.valMin);
1109  else if (pvecNow.hasMax && *now > pvecNow.valMax)
1110  pvecNow.valNow.push_back(pvecNow.valMax);
1111  else pvecNow.valNow.push_back(*now);
1112  }
1113  }
1114 }
1115 
1116 //--------------------------------------------------------------------------
1117 
1118 // Change current value, disregarding limits.
1119 
1120 void Settings::forceMode(string keyIn, int nowIn) {
1121  if (isMode(keyIn)) {
1122  string keyLower = toLower(keyIn);
1123  Mode& modeNow = modes[keyLower];
1124  modeNow.valNow = nowIn;
1125  // Tune:ee and Tune:pp each trigger a whole set of changes.
1126  if (keyLower == "tune:ee") initTuneEE( modeNow.valNow);
1127  if (keyLower == "tune:pp") initTunePP( modeNow.valNow);
1128  }
1129 }
1130 
1131 void Settings::forceParm(string keyIn, double nowIn) {
1132  if (isParm(keyIn)) parms[toLower(keyIn)].valNow = nowIn;
1133 }
1134 
1135 void Settings::forceMVec(string keyIn, vector<int> nowIn) {
1136  if (isMVec(keyIn)) mvecs[toLower(keyIn)].valNow = nowIn;
1137 }
1138 
1139 void Settings::forcePVec(string keyIn, vector<double> nowIn) {
1140  if (isPVec(keyIn)) pvecs[toLower(keyIn)].valNow = nowIn;
1141 }
1142 
1143 //--------------------------------------------------------------------------
1144 
1145 // Restore current value to default.
1146 
1147 void Settings::resetFlag(string keyIn) {
1148  if (isFlag(keyIn)) flags[toLower(keyIn)].valNow
1149  = flags[toLower(keyIn)].valDefault ;
1150 }
1151 
1152 void Settings::resetMode(string keyIn) {
1153  string keyLower = toLower(keyIn);
1154  if (isMode(keyIn)) modes[keyLower].valNow
1155  = modes[toLower(keyIn)].valDefault ;
1156  // For Tune:ee and Tune:pp must also restore variables involved in tunes.
1157  if (keyLower == "tune:ee") resetTuneEE();
1158  if (keyLower == "tune:pp") resetTunePP();
1159 }
1160 
1161 void Settings::resetParm(string keyIn) {
1162  if (isParm(keyIn)) parms[toLower(keyIn)].valNow
1163  = parms[toLower(keyIn)].valDefault ;
1164 }
1165 
1166 void Settings::resetWord(string keyIn) {
1167  if (isWord(keyIn)) words[toLower(keyIn)].valNow
1168  = words[toLower(keyIn)].valDefault ;
1169 }
1170 
1171 void Settings::resetFVec(string keyIn) {
1172  if (isFVec(keyIn)) fvecs[toLower(keyIn)].valNow
1173  = fvecs[toLower(keyIn)].valDefault ;
1174 }
1175 
1176 void Settings::resetMVec(string keyIn) {
1177  if (isMVec(keyIn)) mvecs[toLower(keyIn)].valNow
1178  = mvecs[toLower(keyIn)].valDefault ;
1179 }
1180 
1181 void Settings::resetPVec(string keyIn) {
1182  if (isPVec(keyIn)) pvecs[toLower(keyIn)].valNow
1183  = pvecs[toLower(keyIn)].valDefault ;
1184 }
1185 
1186 //--------------------------------------------------------------------------
1187 
1188 // Regulate level of printout by overall change of settings.
1189 
1190 void Settings::printQuiet(bool quiet) {
1191 
1192  // Switch off as much output as possible.
1193  if (quiet) {
1194  flag("Init:showProcesses", false );
1195  flag("Init:showMultipartonInteractions", false );
1196  flag("Init:showChangedSettings", false );
1197  flag("Init:showAllSettings", false );
1198  flag("Init:showChangedParticleData", false );
1199  flag("Init:showChangedResonanceData", false );
1200  flag("Init:showAllParticleData", false );
1201  mode("Init:showOneParticleData", 0 );
1202  mode("Next:numberCount", 0 );
1203  mode("Next:numberShowLHA", 0 );
1204  mode("Next:numberShowInfo", 0 );
1205  mode("Next:numberShowProcess", 0 );
1206  mode("Next:numberShowEvent", 0 );
1207 
1208  // Restore ouput settings to default.
1209  } else {
1210  resetFlag("Init:showProcesses");
1211  resetFlag("Init:showMultipartonInteractions");
1212  resetFlag("Init:showChangedSettings");
1213  resetFlag("Init:showAllSettings");
1214  resetFlag("Init:showChangedParticleData");
1215  resetFlag("Init:showChangedResonanceData");
1216  resetFlag("Init:showAllParticleData");
1217  resetMode("Init:showOneParticleData");
1218  resetMode("Next:numberCount");
1219  resetMode("Next:numberShowLHA");
1220  resetMode("Next:numberShowInfo");
1221  resetMode("Next:numberShowProcess");
1222  resetMode("Next:numberShowEvent");
1223  }
1224 
1225 }
1226 
1227 //--------------------------------------------------------------------------
1228 
1229 // Restore all e+e- settings to their original values.
1230 
1231 void Settings::resetTuneEE() {
1232 
1233  // Flavour composition.
1234  resetParm("StringFlav:probStoUD");
1235  resetParm("StringFlav:probQQtoQ");
1236  resetParm("StringFlav:probSQtoQQ");
1237  resetParm("StringFlav:probQQ1toQQ0");
1238  resetParm("StringFlav:mesonUDvector");
1239  resetParm("StringFlav:mesonSvector");
1240  resetParm("StringFlav:mesonCvector");
1241  resetParm("StringFlav:mesonBvector");
1242  resetParm("StringFlav:etaSup");
1243  resetParm("StringFlav:etaPrimeSup");
1244  resetParm("StringFlav:popcornSpair");
1245  resetParm("StringFlav:popcornSmeson");
1246  resetFlag("StringFlav:suppressLeadingB");
1247 
1248  // String breaks: z.
1249  resetParm("StringZ:aLund");
1250  resetParm("StringZ:bLund");
1251  resetParm("StringZ:aExtraSquark");
1252  resetParm("StringZ:aExtraDiquark");
1253  resetParm("StringZ:rFactC");
1254  resetParm("StringZ:rFactB");
1255 
1256  // String breaks: pT.
1257  resetParm("StringPT:sigma");
1258  resetParm("StringPT:enhancedFraction");
1259  resetParm("StringPT:enhancedWidth");
1260 
1261  // FSR: strong coupling, IR cutoff.
1262  resetParm("TimeShower:alphaSvalue");
1263  resetMode("TimeShower:alphaSorder");
1264  resetFlag("TimeShower:alphaSuseCMW");
1265  resetParm("TimeShower:pTmin");
1266  resetParm("TimeShower:pTminChgQ");
1267 
1268 }
1269 
1270 //--------------------------------------------------------------------------
1271 
1272 // Restore all pp settings to their original values.
1273 
1274 void Settings::resetTunePP() {
1275 
1276  // PDF set.
1277  resetMode("PDF:pSet");
1278  resetFlag("PDF:useLHAPDF");
1279 
1280  // Hard matrix elements alpha_s value.
1281  resetParm("SigmaProcess:alphaSvalue");
1282 
1283  // Diffraction: cross sections and mass distributions.
1284  resetFlag("SigmaTotal:zeroAXB");
1285  resetFlag("SigmaDiffractive:dampen");
1286  resetParm("SigmaDiffractive:maxXB");
1287  resetParm("SigmaDiffractive:maxAX");
1288  resetParm("SigmaDiffractive:maxXX");
1289  resetParm("Diffraction:largeMassSuppress");
1290 
1291  // FSR: dipoles to beam, spin correlations.
1292  resetFlag("TimeShower:dampenBeamRecoil");
1293  resetFlag("TimeShower:phiPolAsym");
1294 
1295  // ISR: strong coupling, IR cutoff, coherence and spin correlations.
1296  resetParm("SpaceShower:alphaSvalue");
1297  resetMode("SpaceShower:alphaSorder");
1298  resetParm("SpaceShower:alphaSuseCMW");
1299  resetFlag("SpaceShower:samePTasMPI");
1300  resetParm("SpaceShower:pT0Ref");
1301  resetParm("SpaceShower:ecmRef");
1302  resetParm("SpaceShower:ecmPow");
1303  resetFlag("SpaceShower:rapidityOrder");
1304  resetFlag("SpaceShower:phiPolAsym");
1305  resetFlag("SpaceShower:phiIntAsym");
1306 
1307  // MPI: strong coupling, IR regularization, energy scaling.
1308  resetParm("MultipartonInteractions:alphaSvalue");
1309  resetParm("MultipartonInteractions:pT0Ref");
1310  resetParm("MultipartonInteractions:ecmRef");
1311  resetParm("MultipartonInteractions:ecmPow");
1312  resetMode("MultipartonInteractions:bProfile");
1313  resetParm("MultipartonInteractions:expPow");
1314  resetParm("MultipartonInteractions:a1");
1315 
1316  // Beam remnant parameters.
1317  resetParm("BeamRemnants:primordialKTsoft");
1318  resetParm("BeamRemnants:primordialKThard");
1319  resetParm("BeamRemnants:halfScaleForKT");
1320  resetParm("BeamRemnants:halfMassForKT");
1321  resetParm("BeamRemnants:reconnectRange");
1322 
1323 }
1324 
1325 //--------------------------------------------------------------------------
1326 
1327 // Set the values related to a tune of e+e- data,
1328 // i.e. mainly for final-state radiation and hadronization.
1329 
1330 void Settings::initTuneEE( int eeTune) {
1331 
1332  // Restore all e+e- settings to their original values.
1333  // Is first step for setting up a specific tune.
1334  if (eeTune != 0) resetTuneEE();
1335 
1336  // Old flavour and FSR defaults carried over from very old JETSET tune,
1337  // only with alphaS roughly tuned for "new" pT-ordered shower.
1338  if (eeTune == 1) {
1339  parm("StringFlav:probStoUD", 0.30 );
1340  parm("StringFlav:probQQtoQ", 0.10 );
1341  parm("StringFlav:probSQtoQQ", 0.40 );
1342  parm("StringFlav:probQQ1toQQ0", 0.05 );
1343  parm("StringFlav:mesonUDvector", 1.00 );
1344  parm("StringFlav:mesonSvector", 1.50 );
1345  parm("StringFlav:mesonCvector", 2.50 );
1346  parm("StringFlav:mesonBvector", 3.00 );
1347  parm("StringFlav:etaSup", 1.00 );
1348  parm("StringFlav:etaPrimeSup", 0.40 );
1349  parm("StringFlav:popcornSpair", 0.50 );
1350  parm("StringFlav:popcornSmeson", 0.50 );
1351  flag("StringFlav:suppressLeadingB", false );
1352  parm("StringZ:aLund", 0.30 );
1353  parm("StringZ:bLund", 0.58 );
1354  parm("StringZ:aExtraSquark", 0.00 );
1355  parm("StringZ:aExtraDiquark", 0.50 );
1356  parm("StringZ:rFactC", 1.00 );
1357  parm("StringZ:rFactB", 1.00 );
1358  parm("StringPT:sigma", 0.36 );
1359  parm("StringPT:enhancedFraction", 0.01 );
1360  parm("StringPT:enhancedWidth", 2.0 );
1361  parm("TimeShower:alphaSvalue", 0.137 );
1362  mode("TimeShower:alphaSorder", 1 );
1363  flag("TimeShower:alphaSuseCMW", false );
1364  parm("TimeShower:pTmin", 0.5 );
1365  parm("TimeShower:pTminChgQ", 0.5 );
1366  }
1367 
1368  // Marc Montull's tune to particle composition at LEP1 (August 2007).
1369  else if (eeTune == 2) {
1370  parm("StringFlav:probStoUD", 0.22 );
1371  parm("StringFlav:probQQtoQ", 0.08 );
1372  parm("StringFlav:probSQtoQQ", 0.75 );
1373  parm("StringFlav:probQQ1toQQ0", 0.025 );
1374  parm("StringFlav:mesonUDvector", 0.5 );
1375  parm("StringFlav:mesonSvector", 0.6 );
1376  parm("StringFlav:mesonCvector", 1.5 );
1377  parm("StringFlav:mesonBvector", 2.5 );
1378  parm("StringFlav:etaSup", 0.60 );
1379  parm("StringFlav:etaPrimeSup", 0.15 );
1380  parm("StringFlav:popcornSpair", 1.0 );
1381  parm("StringFlav:popcornSmeson", 1.0 );
1382  flag("StringFlav:suppressLeadingB", false ); // kept fixed
1383  parm("StringZ:aLund", 0.76 );
1384  parm("StringZ:bLund", 0.58 ); // kept fixed
1385  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
1386  parm("StringZ:aExtraDiquark", 0.50 ); // kept fixed
1387  parm("StringZ:rFactC", 1.00 ); // kept fixed
1388  parm("StringZ:rFactB", 1.00 ); // kept fixed
1389  parm("StringPT:sigma", 0.36 ); // kept fixed
1390  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
1391  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
1392  parm("TimeShower:alphaSvalue", 0.137 ); // kept fixed
1393  mode("TimeShower:alphaSorder", 1 ); // kept fixed
1394  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
1395  parm("TimeShower:pTmin", 0.5 ); // kept fixed
1396  parm("TimeShower:pTminChgQ", 0.5 ); // kept fixed
1397  }
1398 
1399  // Full e+e- tune of flavours and FSR to LEP1 data within the
1400  // Rivet + Professor framework, by Hendrik Hoeth (June 2009).
1401  else if (eeTune == 3) {
1402  parm("StringFlav:probStoUD", 0.19 );
1403  parm("StringFlav:probQQtoQ", 0.09 );
1404  parm("StringFlav:probSQtoQQ", 1.00 );
1405  parm("StringFlav:probQQ1toQQ0", 0.027 );
1406  parm("StringFlav:mesonUDvector", 0.62 );
1407  parm("StringFlav:mesonSvector", 0.725 );
1408  parm("StringFlav:mesonCvector", 1.06 );
1409  parm("StringFlav:mesonBvector", 3.0 );
1410  parm("StringFlav:etaSup", 0.63 );
1411  parm("StringFlav:etaPrimeSup", 0.12 );
1412  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
1413  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
1414  flag("StringFlav:suppressLeadingB", false ); // kept fixed
1415  parm("StringZ:aLund", 0.3 ); // kept fixed
1416  parm("StringZ:bLund", 0.8 );
1417  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
1418  parm("StringZ:aExtraDiquark", 0.50 ); // kept fixed
1419  parm("StringZ:rFactC", 1.00 ); // kept fixed
1420  parm("StringZ:rFactB", 0.67 );
1421  parm("StringPT:sigma", 0.304 );
1422  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
1423  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
1424  parm("TimeShower:alphaSvalue", 0.1383);
1425  mode("TimeShower:alphaSorder", 1 ); // kept fixed
1426  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
1427  parm("TimeShower:pTmin", 0.4 ); // kept fixed (near limit)
1428  parm("TimeShower:pTminChgQ", 0.4 ); // kept same as pTmin
1429  }
1430 
1431  // Full e+e- tune of flavours and FSR to LEP1 data, by Peter Skands
1432  // (September 2013). Note use of CMW convention for shower.
1433  else if (eeTune == 4) {
1434  parm("StringFlav:probStoUD", 0.21 );
1435  parm("StringFlav:probQQtoQ", 0.086 );
1436  parm("StringFlav:probSQtoQQ", 1.00 );
1437  parm("StringFlav:probQQ1toQQ0", 0.031 );
1438  parm("StringFlav:mesonUDvector", 0.45 );
1439  parm("StringFlav:mesonSvector", 0.60 );
1440  parm("StringFlav:mesonCvector", 0.95 );
1441  parm("StringFlav:mesonBvector", 3.0 ); // kept fixed
1442  parm("StringFlav:etaSup", 0.65 );
1443  parm("StringFlav:etaPrimeSup", 0.08 );
1444  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
1445  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
1446  flag("StringFlav:suppressLeadingB", false ); // kept fixed
1447  parm("StringZ:aLund", 0.55 );
1448  parm("StringZ:bLund", 1.08 );
1449  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
1450  parm("StringZ:aExtraDiquark", 1.00 );
1451  parm("StringZ:rFactC", 1.00 ); // kept fixed
1452  parm("StringZ:rFactB", 0.85 );
1453  parm("StringPT:sigma", 0.305 );
1454  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
1455  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
1456  parm("TimeShower:alphaSvalue", 0.127 );
1457  mode("TimeShower:alphaSorder", 1 ); // kept fixed
1458  flag("TimeShower:alphaSuseCMW", true );
1459  parm("TimeShower:pTmin", 0.4 );
1460  parm("TimeShower:pTminChgQ", 0.4 ); // kept same as pTmin
1461  }
1462 
1463  // First e+e- tune by Nadine Fischer, using eeTune = 3 for flavour
1464  // composition (September 2013).
1465  else if (eeTune == 5) {
1466  parm("StringFlav:probStoUD", 0.19 ); // kept fixed
1467  parm("StringFlav:probQQtoQ", 0.09 ); // kept fixed
1468  parm("StringFlav:probSQtoQQ", 1.00 ); // kept fixed
1469  parm("StringFlav:probQQ1toQQ0", 0.027 ); // kept fixed
1470  parm("StringFlav:mesonUDvector", 0.62 ); // kept fixed
1471  parm("StringFlav:mesonSvector", 0.725 ); // kept fixed
1472  parm("StringFlav:mesonCvector", 1.06 ); // kept fixed
1473  parm("StringFlav:mesonBvector", 3.0 ); // kept fixed
1474  parm("StringFlav:etaSup", 0.63 ); // kept fixed
1475  parm("StringFlav:etaPrimeSup", 0.12 ); // kept fixed
1476  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
1477  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
1478  flag("StringFlav:suppressLeadingB", false ); // kept fixed
1479  parm("StringZ:aLund", 0.386 );
1480  parm("StringZ:bLund", 0.977 );
1481  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
1482  parm("StringZ:aExtraDiquark", 0.940 );
1483  parm("StringZ:rFactC", 1.00 ); // kept fixed
1484  parm("StringZ:rFactB", 0.67 ); // kept fixed
1485  parm("StringPT:sigma", 0.286 );
1486  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
1487  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
1488  parm("TimeShower:alphaSvalue", 0.139 );
1489  mode("TimeShower:alphaSorder", 1 ); // kept fixed
1490  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
1491  parm("TimeShower:pTmin", 0.409 );
1492  parm("TimeShower:pTminChgQ", 0.409 ); // kept same as pTmin
1493  }
1494 
1495  // Second e+e- tune by Nadine Fischer, using eeTune = 3 for flavour
1496  // composition (September 2013).
1497  else if (eeTune == 6) {
1498  parm("StringFlav:probStoUD", 0.19 ); // kept fixed
1499  parm("StringFlav:probQQtoQ", 0.09 ); // kept fixed
1500  parm("StringFlav:probSQtoQQ", 1.00 ); // kept fixed
1501  parm("StringFlav:probQQ1toQQ0", 0.027 ); // kept fixed
1502  parm("StringFlav:mesonUDvector", 0.62 ); // kept fixed
1503  parm("StringFlav:mesonSvector", 0.725 ); // kept fixed
1504  parm("StringFlav:mesonCvector", 1.06 ); // kept fixed
1505  parm("StringFlav:mesonBvector", 3.0 ); // kept fixed
1506  parm("StringFlav:etaSup", 0.63 ); // kept fixed
1507  parm("StringFlav:etaPrimeSup", 0.12 ); // kept fixed
1508  parm("StringFlav:popcornSpair", 0.5 ); // kept fixed
1509  parm("StringFlav:popcornSmeson", 0.5 ); // kept fixed
1510  flag("StringFlav:suppressLeadingB", false ); // kept fixed
1511  parm("StringZ:aLund", 0.351 );
1512  parm("StringZ:bLund", 0.942 );
1513  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
1514  parm("StringZ:aExtraDiquark", 0.547 );
1515  parm("StringZ:rFactC", 1.00 ); // kept fixed
1516  parm("StringZ:rFactB", 0.67 ); // kept fixed
1517  parm("StringPT:sigma", 0.283 );
1518  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
1519  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
1520  parm("TimeShower:alphaSvalue", 0.139);
1521  mode("TimeShower:alphaSorder", 1 ); // kept fixed
1522  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
1523  parm("TimeShower:pTmin", 0.406 );
1524  parm("TimeShower:pTminChgQ", 0.406 ); // kept same as pTmin
1525  }
1526 
1527  // The Monash 2013 tune by Peter Skands, the e+e- part (January 2014).
1528  else if (eeTune == 7) {
1529  parm("StringFlav:probStoUD", 0.217 );
1530  parm("StringFlav:probQQtoQ", 0.081 );
1531  parm("StringFlav:probSQtoQQ", 0.915 );
1532  parm("StringFlav:probQQ1toQQ0", 0.0275);
1533  parm("StringFlav:mesonUDvector", 0.50 );
1534  parm("StringFlav:mesonSvector", 0.55 );
1535  parm("StringFlav:mesonCvector", 0.88 );
1536  parm("StringFlav:mesonBvector", 2.20 );
1537  parm("StringFlav:etaSup", 0.60 );
1538  parm("StringFlav:etaPrimeSup", 0.12 );
1539  parm("StringFlav:popcornSpair", 0.90 );
1540  parm("StringFlav:popcornSmeson", 0.50 );
1541  flag("StringFlav:suppressLeadingB", false ); // kept fixed
1542  parm("StringZ:aLund", 0.68 );
1543  parm("StringZ:bLund", 0.98 );
1544  parm("StringZ:aExtraSquark", 0.00 ); // kept fixed
1545  parm("StringZ:aExtraDiquark", 0.97 );
1546  parm("StringZ:rFactC", 1.32 );
1547  parm("StringZ:rFactB", 0.855 );
1548  parm("StringPT:sigma", 0.335 );
1549  parm("StringPT:enhancedFraction", 0.01 ); // kept fixed
1550  parm("StringPT:enhancedWidth", 2.0 ); // kept fixed
1551  parm("TimeShower:alphaSvalue", 0.1365);
1552  mode("TimeShower:alphaSorder", 1 ); // kept fixed
1553  flag("TimeShower:alphaSuseCMW", false ); // kept fixed
1554  parm("TimeShower:pTmin", 0.5 ); // kept fixed
1555  parm("TimeShower:pTminChgQ", 0.5 ); // kept fixed
1556  }
1557 
1558 }
1559 
1560 //--------------------------------------------------------------------------
1561 
1562 // Set the values related to a tune of pp/ppbar data,
1563 // i.e. mainly for initial-state radiation and multiparton interactions.
1564 
1565 void Settings::initTunePP( int ppTune) {
1566 
1567  // Restore all pp/ppbar settings to their original values.
1568  // Is first step for setting up a specific tune.
1569  if (ppTune != 0) resetTunePP();
1570 
1571  // Decide whether to use LHAPFD where possible.
1572  bool preferLHAPDF = flag("Tune:preferLHAPDF");
1573 
1574  // Old ISR and MPI defaults from early and primitive comparisons with data.
1575  if (ppTune == 1) {
1576  mode("PDF:pSet", 2 );
1577  parm("SigmaProcess:alphaSvalue", 0.1265);
1578  flag("SigmaTotal:zeroAXB", true );
1579  flag("SigmaDiffractive:dampen", false );
1580  parm("Diffraction:largeMassSuppress", 2.0 );
1581  flag("TimeShower:dampenBeamRecoil", false );
1582  flag("TimeShower:phiPolAsym", false );
1583  parm("SpaceShower:alphaSvalue", 0.127 );
1584  mode("SpaceShower:alphaSorder", 1 );
1585  flag("SpaceShower:alphaSuseCMW", false );
1586  flag("SpaceShower:samePTasMPI", true );
1587  parm("SpaceShower:pT0Ref", 2.2 );
1588  parm("SpaceShower:ecmRef", 1800.0);
1589  parm("SpaceShower:ecmPow", 0.16 );
1590  flag("SpaceShower:rapidityOrder", false );
1591  flag("SpaceShower:phiPolAsym", false );
1592  flag("SpaceShower:phiIntAsym", false );
1593  parm("MultipartonInteractions:alphaSvalue", 0.127 );
1594  parm("MultipartonInteractions:pT0Ref", 2.15 );
1595  parm("MultipartonInteractions:ecmRef", 1800. );
1596  parm("MultipartonInteractions:ecmPow", 0.16 );
1597  mode("MultipartonInteractions:bProfile", 2 );
1598  parm("MultipartonInteractions:expPow", 1.0 );
1599  parm("MultipartonInteractions:a1", 0.15 );
1600  parm("BeamRemnants:primordialKTsoft", 0.4 );
1601  parm("BeamRemnants:primordialKThard", 2.1 );
1602  parm("BeamRemnants:halfScaleForKT", 7.0 );
1603  parm("BeamRemnants:halfMassForKT", 2.0 );
1604  parm("BeamRemnants:reconnectRange", 2.5 );
1605  }
1606 
1607  // "Tune 1" simple first tune by Peter Skands to ISR and MPI, July 2009.
1608  else if (ppTune == 2) {
1609  mode("PDF:pSet", 2 );
1610  parm("SigmaProcess:alphaSvalue", 0.1265);
1611  flag("SigmaTotal:zeroAXB", true );
1612  flag("SigmaDiffractive:dampen", false );
1613  parm("Diffraction:largeMassSuppress", 2.0 );
1614  flag("TimeShower:dampenBeamRecoil", false );
1615  flag("TimeShower:phiPolAsym", false );
1616  parm("SpaceShower:alphaSvalue", 0.137 );
1617  mode("SpaceShower:alphaSorder", 1 );
1618  flag("SpaceShower:alphaSuseCMW", false );
1619  flag("SpaceShower:samePTasMPI", false );
1620  parm("SpaceShower:pT0Ref", 2.0 );
1621  parm("SpaceShower:ecmRef", 1800.0);
1622  parm("SpaceShower:ecmPow", 0.0 );
1623  flag("SpaceShower:rapidityOrder", false );
1624  flag("SpaceShower:phiPolAsym", false );
1625  flag("SpaceShower:phiIntAsym", false );
1626  parm("MultipartonInteractions:alphaSvalue", 0.127 );
1627  parm("MultipartonInteractions:pT0Ref", 2.25 );
1628  parm("MultipartonInteractions:ecmRef", 1800. );
1629  parm("MultipartonInteractions:ecmPow", 0.24 );
1630  mode("MultipartonInteractions:bProfile", 1 );
1631  parm("MultipartonInteractions:expPow", 1.0 );
1632  parm("MultipartonInteractions:a1", 0.15 );
1633  parm("BeamRemnants:primordialKTsoft", 0.5 );
1634  parm("BeamRemnants:primordialKThard", 2.0 );
1635  parm("BeamRemnants:halfScaleForKT", 1.0 );
1636  parm("BeamRemnants:halfMassForKT", 1.0 );
1637  parm("BeamRemnants:reconnectRange", 10.0 );
1638  }
1639 
1640  // Tune 2C, July 2010.
1641  else if (ppTune == 3) {
1642  mode("PDF:pSet", 8 );
1643  parm("SigmaProcess:alphaSvalue", 0.135 );
1644  flag("SigmaTotal:zeroAXB", true );
1645  flag("SigmaDiffractive:dampen", false );
1646  parm("Diffraction:largeMassSuppress", 2.0 );
1647  flag("TimeShower:dampenBeamRecoil", true );
1648  flag("TimeShower:phiPolAsym", true );
1649  parm("SpaceShower:alphaSvalue", 0.137 );
1650  mode("SpaceShower:alphaSorder", 1 );
1651  flag("SpaceShower:alphaSuseCMW", false );
1652  flag("SpaceShower:samePTasMPI", false );
1653  parm("SpaceShower:pT0Ref", 2.0 );
1654  parm("SpaceShower:ecmRef", 1800.0);
1655  parm("SpaceShower:ecmPow", 0.0 );
1656  flag("SpaceShower:rapidityOrder", true );
1657  flag("SpaceShower:phiPolAsym", true );
1658  flag("SpaceShower:phiIntAsym", true );
1659  parm("MultipartonInteractions:alphaSvalue", 0.135 );
1660  parm("MultipartonInteractions:pT0Ref", 2.32 );
1661  parm("MultipartonInteractions:ecmRef", 1800. );
1662  parm("MultipartonInteractions:ecmPow", 0.21 );
1663  mode("MultipartonInteractions:bProfile", 3 );
1664  parm("MultipartonInteractions:expPow", 1.6 );
1665  parm("MultipartonInteractions:a1", 0.15 );
1666  parm("BeamRemnants:primordialKTsoft", 0.5 );
1667  parm("BeamRemnants:primordialKThard", 2.0 );
1668  parm("BeamRemnants:halfScaleForKT", 1.0 );
1669  parm("BeamRemnants:halfMassForKT", 1.0 );
1670  parm("BeamRemnants:reconnectRange", 3.0 );
1671  }
1672 
1673  // Tune 2M, July 2010.
1674  else if (ppTune == 4) {
1675  mode("PDF:pSet", 4 );
1676  parm("SigmaProcess:alphaSvalue", 0.1265);
1677  flag("SigmaTotal:zeroAXB", true );
1678  flag("SigmaDiffractive:dampen", false );
1679  parm("Diffraction:largeMassSuppress", 2.0 );
1680  flag("TimeShower:dampenBeamRecoil", true );
1681  flag("TimeShower:phiPolAsym", true );
1682  parm("SpaceShower:alphaSvalue", 0.130 );
1683  mode("SpaceShower:alphaSorder", 1 );
1684  flag("SpaceShower:alphaSuseCMW", false );
1685  flag("SpaceShower:samePTasMPI", false );
1686  parm("SpaceShower:pT0Ref", 2.0 );
1687  parm("SpaceShower:ecmRef", 1800.0);
1688  parm("SpaceShower:ecmPow", 0.0 );
1689  flag("SpaceShower:rapidityOrder", true );
1690  flag("SpaceShower:phiPolAsym", true );
1691  flag("SpaceShower:phiIntAsym", true );
1692  parm("MultipartonInteractions:alphaSvalue", 0.127 );
1693  parm("MultipartonInteractions:pT0Ref", 2.455 );
1694  parm("MultipartonInteractions:ecmRef", 1800. );
1695  parm("MultipartonInteractions:ecmPow", 0.26 );
1696  mode("MultipartonInteractions:bProfile", 3 );
1697  parm("MultipartonInteractions:expPow", 1.15 );
1698  parm("MultipartonInteractions:a1", 0.15 );
1699  parm("BeamRemnants:primordialKTsoft", 0.5 );
1700  parm("BeamRemnants:primordialKThard", 2.0 );
1701  parm("BeamRemnants:halfScaleForKT", 1.0 );
1702  parm("BeamRemnants:halfMassForKT", 1.0 );
1703  parm("BeamRemnants:reconnectRange", 3.0 );
1704  }
1705 
1706  // Tune 4C, October 2010.
1707  else if (ppTune == 5) {
1708  mode("PDF:pSet", 8 );
1709  parm("SigmaProcess:alphaSvalue", 0.135 );
1710  flag("SigmaTotal:zeroAXB", true );
1711  flag("SigmaDiffractive:dampen", true );
1712  parm("SigmaDiffractive:maxXB", 65.0 );
1713  parm("SigmaDiffractive:maxAX", 65.0 );
1714  parm("SigmaDiffractive:maxXX", 65.0 );
1715  parm("Diffraction:largeMassSuppress", 2.0 );
1716  flag("TimeShower:dampenBeamRecoil", true );
1717  flag("TimeShower:phiPolAsym", true );
1718  parm("SpaceShower:alphaSvalue", 0.137 );
1719  mode("SpaceShower:alphaSorder", 1 );
1720  flag("SpaceShower:alphaSuseCMW", false );
1721  flag("SpaceShower:samePTasMPI", false );
1722  parm("SpaceShower:pT0Ref", 2.0 );
1723  parm("SpaceShower:ecmRef", 1800.0);
1724  parm("SpaceShower:ecmPow", 0.0 );
1725  flag("SpaceShower:rapidityOrder", true );
1726  flag("SpaceShower:phiPolAsym", true );
1727  flag("SpaceShower:phiIntAsym", true );
1728  parm("MultipartonInteractions:alphaSvalue", 0.135 );
1729  parm("MultipartonInteractions:pT0Ref", 2.085 );
1730  parm("MultipartonInteractions:ecmRef", 1800. );
1731  parm("MultipartonInteractions:ecmPow", 0.19 );
1732  mode("MultipartonInteractions:bProfile", 3 );
1733  parm("MultipartonInteractions:expPow", 2.0 );
1734  parm("MultipartonInteractions:a1", 0.15 );
1735  parm("BeamRemnants:primordialKTsoft", 0.5 );
1736  parm("BeamRemnants:primordialKThard", 2.0 );
1737  parm("BeamRemnants:halfScaleForKT", 1.0 );
1738  parm("BeamRemnants:halfMassForKT", 1.0 );
1739  parm("BeamRemnants:reconnectRange", 1.5 );
1740  }
1741 
1742  // Tune 4Cx, January 2011.
1743  else if (ppTune == 6) {
1744  mode("PDF:pSet", 8 );
1745  parm("SigmaProcess:alphaSvalue", 0.135 );
1746  flag("SigmaTotal:zeroAXB", true );
1747  flag("SigmaDiffractive:dampen", true );
1748  parm("SigmaDiffractive:maxXB", 65.0 );
1749  parm("SigmaDiffractive:maxAX", 65.0 );
1750  parm("SigmaDiffractive:maxXX", 65.0 );
1751  parm("Diffraction:largeMassSuppress", 2.0 );
1752  flag("TimeShower:dampenBeamRecoil", true );
1753  flag("TimeShower:phiPolAsym", true );
1754  parm("SpaceShower:alphaSvalue", 0.137 );
1755  mode("SpaceShower:alphaSorder", 1 );
1756  flag("SpaceShower:alphaSuseCMW", false );
1757  flag("SpaceShower:samePTasMPI", false );
1758  parm("SpaceShower:pT0Ref", 2.0 );
1759  parm("SpaceShower:ecmRef", 1800.0);
1760  parm("SpaceShower:ecmPow", 0.0 );
1761  flag("SpaceShower:rapidityOrder", true );
1762  flag("SpaceShower:phiPolAsym", true );
1763  flag("SpaceShower:phiIntAsym", true );
1764  parm("MultipartonInteractions:alphaSvalue", 0.135 );
1765  parm("MultipartonInteractions:pT0Ref", 2.15 );
1766  parm("MultipartonInteractions:ecmRef", 1800. );
1767  parm("MultipartonInteractions:ecmPow", 0.19 );
1768  mode("MultipartonInteractions:bProfile", 4 );
1769  parm("MultipartonInteractions:expPow", 1.0 );
1770  parm("MultipartonInteractions:a1", 0.15 );
1771  parm("BeamRemnants:primordialKTsoft", 0.5 );
1772  parm("BeamRemnants:primordialKThard", 2.0 );
1773  parm("BeamRemnants:halfScaleForKT", 1.0 );
1774  parm("BeamRemnants:halfMassForKT", 1.0 );
1775  parm("BeamRemnants:reconnectRange", 1.5 );
1776  }
1777 
1778  // Several ATLAS tunes in the A2 and AU2 series, see
1779  // ATLAS note ATL-PHYS-PUB-2012-003 (August 2012).
1780  else if (ppTune < 14) {
1781  parm("SigmaProcess:alphaSvalue", 0.135 );
1782  flag("SigmaTotal:zeroAXB", true );
1783  flag("SigmaDiffractive:dampen", true );
1784  parm("SigmaDiffractive:maxXB", 65.0 );
1785  parm("SigmaDiffractive:maxAX", 65.0 );
1786  parm("SigmaDiffractive:maxXX", 65.0 );
1787  parm("Diffraction:largeMassSuppress", 2.0 );
1788  flag("TimeShower:dampenBeamRecoil", true );
1789  flag("TimeShower:phiPolAsym", true );
1790  parm("SpaceShower:alphaSvalue", 0.137 );
1791  mode("SpaceShower:alphaSorder", 1 );
1792  flag("SpaceShower:alphaSuseCMW", false );
1793  flag("SpaceShower:samePTasMPI", false );
1794  parm("SpaceShower:pT0Ref", 2.0 );
1795  parm("SpaceShower:ecmRef", 1800.0);
1796  parm("SpaceShower:ecmPow", 0.0 );
1797  flag("SpaceShower:rapidityOrder", false );
1798  flag("SpaceShower:phiPolAsym", true );
1799  flag("SpaceShower:phiIntAsym", true );
1800  parm("MultipartonInteractions:alphaSvalue", 0.135 );
1801  parm("MultipartonInteractions:ecmRef", 1800. );
1802  mode("MultipartonInteractions:bProfile", 4 );
1803  parm("MultipartonInteractions:expPow", 1.0 );
1804  parm("MultipartonInteractions:a1", 0.15 );
1805  parm("BeamRemnants:primordialKTsoft", 0.5 );
1806  parm("BeamRemnants:primordialKThard", 2.0 );
1807  parm("BeamRemnants:halfScaleForKT", 1.0 );
1808  parm("BeamRemnants:halfMassForKT", 1.0 );
1809 
1810  // ATLAS MB tune A2-CTEQ6L1.
1811  if (ppTune == 7) {
1812  if (preferLHAPDF) {
1813  flag("PDF:useLHAPDF", true );
1814  word("PDF:LHAPDFset", "cteq6ll.LHpdf");
1815  } else mode("PDF:pSet", 8 );
1816  parm("MultipartonInteractions:pT0Ref", 2.18 );
1817  parm("MultipartonInteractions:ecmPow", 0.22 );
1818  parm("MultipartonInteractions:a1", 0.06 );
1819  parm("BeamRemnants:reconnectRange", 1.55 );
1820  }
1821 
1822  // ATLAS MB tune A2-MSTW2008LO.
1823  else if (ppTune == 8) {
1824  if (preferLHAPDF) {
1825  flag("PDF:useLHAPDF", true );
1826  word("PDF:LHAPDFset", "MSTW2008lo68cl.LHgrid");
1827  } else mode("PDF:pSet", 5 );
1828  parm("MultipartonInteractions:pT0Ref", 1.90 );
1829  parm("MultipartonInteractions:ecmPow", 0.30 );
1830  parm("MultipartonInteractions:a1", 0.03 );
1831  parm("BeamRemnants:reconnectRange", 2.28 );
1832  }
1833 
1834  // ATLAS UE tune AU2-CTEQ6L1.
1835  if (ppTune == 9) {
1836  if (preferLHAPDF) {
1837  flag("PDF:useLHAPDF", true );
1838  word("PDF:LHAPDFset", "cteq6ll.LHpdf");
1839  } else mode("PDF:pSet", 8 );
1840  parm("MultipartonInteractions:pT0Ref", 2.13 );
1841  parm("MultipartonInteractions:ecmPow", 0.21 );
1842  parm("MultipartonInteractions:a1", 0.00 );
1843  parm("BeamRemnants:reconnectRange", 2.21 );
1844  }
1845 
1846  // ATLAS UE tune AU2-MSTW2008LO.
1847  else if (ppTune == 10) {
1848  if (preferLHAPDF) {
1849  flag("PDF:useLHAPDF", true );
1850  word("PDF:LHAPDFset", "MSTW2008lo68cl.LHgrid");
1851  } else mode("PDF:pSet", 5 );
1852  parm("MultipartonInteractions:pT0Ref", 1.87 );
1853  parm("MultipartonInteractions:ecmPow", 0.28 );
1854  parm("MultipartonInteractions:a1", 0.01 );
1855  parm("BeamRemnants:reconnectRange", 5.32 );
1856  }
1857 
1858  // ATLAS UE tune AU2-CT10.
1859  else if (ppTune == 11) {
1860  flag("PDF:useLHAPDF", true );
1861  word("PDF:LHAPDFset", "CT10.LHgrid");
1862  parm("MultipartonInteractions:pT0Ref", 1.70 );
1863  parm("MultipartonInteractions:ecmPow", 0.16 );
1864  parm("MultipartonInteractions:a1", 0.10 );
1865  parm("BeamRemnants:reconnectRange", 4.67 );
1866  }
1867 
1868  // ATLAS UE tune AU2-MRST2007LO*.
1869  else if (ppTune == 12) {
1870  if (preferLHAPDF) {
1871  flag("PDF:useLHAPDF", true );
1872  word("PDF:LHAPDFset", "MRST2007lomod.LHgrid");
1873  } else mode("PDF:pSet", 3 );
1874  parm("MultipartonInteractions:pT0Ref", 2.39 );
1875  parm("MultipartonInteractions:ecmPow", 0.24 );
1876  parm("MultipartonInteractions:a1", 0.01 );
1877  parm("BeamRemnants:reconnectRange", 1.76 );
1878  }
1879 
1880  // ATLAS UE tune AU2-MRST2007LO**.
1881  else if (ppTune == 13) {
1882  if (preferLHAPDF) {
1883  flag("PDF:useLHAPDF", true );
1884  word("PDF:LHAPDFset", "MRSTMCal.LHgrid");
1885  } else mode("PDF:pSet", 4 );
1886  parm("MultipartonInteractions:pT0Ref", 2.57 );
1887  parm("MultipartonInteractions:ecmPow", 0.23 );
1888  parm("MultipartonInteractions:a1", 0.01 );
1889  parm("BeamRemnants:reconnectRange", 1.47 );
1890  }
1891  }
1892 
1893  // The Monash 2013 tune by Peter Skands, the pp part (January 2014).
1894  else if (ppTune == 14) {
1895  mode("PDF:pSet", 13 ); // NNPDF
1896  parm("SigmaProcess:alphaSvalue", 0.130 ); // same as PDF
1897  flag("SigmaTotal:zeroAXB", true );
1898  flag("SigmaDiffractive:dampen", true );
1899  parm("SigmaDiffractive:maxXB", 65.0 );
1900  parm("SigmaDiffractive:maxAX", 65.0 );
1901  parm("SigmaDiffractive:maxXX", 65.0 );
1902  parm("Diffraction:largeMassSuppress", 4.0 );
1903  flag("TimeShower:dampenBeamRecoil", true );
1904  flag("TimeShower:phiPolAsym", true );
1905  parm("SpaceShower:alphaSvalue", 0.1365); // same as FSR
1906  mode("SpaceShower:alphaSorder", 1 );
1907  flag("SpaceShower:alphaSuseCMW", false );
1908  flag("SpaceShower:samePTasMPI", false );
1909  parm("SpaceShower:pT0Ref", 2.0 );
1910  parm("SpaceShower:ecmRef", 7000.0);
1911  parm("SpaceShower:ecmPow", 0.0 );
1912  flag("SpaceShower:rapidityOrder", true );
1913  flag("SpaceShower:phiPolAsym", true );
1914  flag("SpaceShower:phiIntAsym", true );
1915  parm("MultipartonInteractions:alphaSvalue", 0.130 ); // same as PDF
1916  parm("MultipartonInteractions:pT0Ref", 2.28 );
1917  parm("MultipartonInteractions:ecmRef", 7000. );
1918  parm("MultipartonInteractions:ecmPow", 0.215 );
1919  mode("MultipartonInteractions:bProfile", 3 );
1920  parm("MultipartonInteractions:expPow", 1.85 );
1921  parm("MultipartonInteractions:a1", 0.15 );
1922  parm("BeamRemnants:primordialKTsoft", 0.9 );
1923  parm("BeamRemnants:primordialKThard", 1.8 );
1924  parm("BeamRemnants:halfScaleForKT", 1.5 );
1925  parm("BeamRemnants:halfMassForKT", 1.0 );
1926  parm("BeamRemnants:reconnectRange", 1.80 );
1927  }
1928 
1929 }
1930 
1931 //--------------------------------------------------------------------------
1932 
1933 // Convert string to lowercase for case-insensitive comparisons.
1934 // Also remove initial and trailing blanks, if any.
1935 
1936 string Settings::toLower(const string& name) {
1937 
1938  // Copy string without initial and trailing blanks.
1939  if (name.find_first_not_of(" \n\t\v\b\r\f\a") == string::npos) return "";
1940  int firstChar = name.find_first_not_of(" \n\t\v\b\r\f\a");
1941  int lastChar = name.find_last_not_of(" \n\t\v\b\r\f\a");
1942  string temp = name.substr( firstChar, lastChar + 1 - firstChar);
1943 
1944  // Convert to lowercase letter by letter.
1945  for (int i = 0; i < int(temp.length()); ++i) temp[i] = tolower(temp[i]);
1946  return temp;
1947 
1948 }
1949 
1950 //--------------------------------------------------------------------------
1951 
1952 // Allow several alternative inputs for true/false.
1953 
1954 bool Settings::boolString(string tag) {
1955 
1956  string tagLow = toLower(tag);
1957  return ( tagLow == "true" || tagLow == "1" || tagLow == "on"
1958  || tagLow == "yes" || tagLow == "ok" );
1959 
1960 }
1961 
1962 //--------------------------------------------------------------------------
1963 
1964 // Extract XML value string following XML attribute.
1965 
1966 string Settings::attributeValue(string line, string attribute) {
1967 
1968  if (line.find(attribute) == string::npos) return "";
1969  int iBegAttri = line.find(attribute);
1970  int iBegQuote = line.find("\"", iBegAttri + 1);
1971  int iEndQuote = line.find("\"", iBegQuote + 1);
1972  return line.substr(iBegQuote + 1, iEndQuote - iBegQuote - 1);
1973 
1974 }
1975 
1976 //--------------------------------------------------------------------------
1977 
1978 // Extract XML bool value following XML attribute.
1979 
1980 bool Settings::boolAttributeValue(string line, string attribute) {
1981 
1982  string valString = attributeValue(line, attribute);
1983  if (valString == "") return false;
1984  return boolString(valString);
1985 
1986 }
1987 
1988 //--------------------------------------------------------------------------
1989 
1990 // Extract XML int value following XML attribute.
1991 
1992 int Settings::intAttributeValue(string line, string attribute) {
1993  string valString = attributeValue(line, attribute);
1994  if (valString == "") return 0;
1995  istringstream valStream(valString);
1996  int intVal;
1997  valStream >> intVal;
1998  return intVal;
1999 
2000 }
2001 
2002 //--------------------------------------------------------------------------
2003 
2004 // Extract XML double value following XML attribute.
2005 
2006 double Settings::doubleAttributeValue(string line, string attribute) {
2007  string valString = attributeValue(line, attribute);
2008  if (valString == "") return 0.;
2009  istringstream valStream(valString);
2010  double doubleVal;
2011  valStream >> doubleVal;
2012  return doubleVal;
2013 
2014 }
2015 
2016 //--------------------------------------------------------------------------
2017 
2018 // Extract XML bool vector value following XML attribute.
2019 
2020 vector<bool> Settings::boolVectorAttributeValue(string line,
2021  string attribute) {
2022  string valString = attributeValue(line, attribute);
2023  if (valString == "") return vector<bool>(1, false);
2024  vector<bool> vectorVal;
2025  size_t stringPos(0);
2026  while (stringPos != string::npos) {
2027  stringPos = valString.find(",");
2028  istringstream valStream(valString.substr(0, stringPos));
2029  valString = valString.substr(stringPos + 1);
2030  vectorVal.push_back(boolString(valStream.str()));
2031  }
2032  return vectorVal;
2033 
2034 }
2035 
2036 //--------------------------------------------------------------------------
2037 
2038 // Extract XML int vector value following XML attribute.
2039 
2040 vector<int> Settings::intVectorAttributeValue(string line,
2041  string attribute) {
2042  string valString = attributeValue(line, attribute);
2043  if (valString == "") return vector<int>(1, 0);
2044  int intVal;
2045  vector<int> vectorVal;
2046  size_t stringPos(0);
2047  while (stringPos != string::npos) {
2048  stringPos = valString.find(",");
2049  istringstream valStream(valString.substr(0, stringPos));
2050  valString = valString.substr(stringPos + 1);
2051  valStream >> intVal;
2052  vectorVal.push_back(intVal);
2053  }
2054  return vectorVal;
2055 
2056 }
2057 
2058 //--------------------------------------------------------------------------
2059 
2060 // Extract XML double vector value following XML attribute.
2061 
2062 vector<double> Settings::doubleVectorAttributeValue(string line,
2063  string attribute) {
2064  string valString = attributeValue(line, attribute);
2065  if (valString == "") return vector<double>(1, 0.);
2066  double doubleVal;
2067  vector<double> vectorVal;
2068  size_t stringPos(0);
2069  while (stringPos != string::npos) {
2070  stringPos = valString.find(",");
2071  istringstream valStream(valString.substr(0, stringPos));
2072  valString = valString.substr(stringPos + 1);
2073  valStream >> doubleVal;
2074  vectorVal.push_back(doubleVal);
2075  }
2076  return vectorVal;
2077 
2078 }
2079 
2080 //==========================================================================
2081 
2082 } // end namespace Pythia8