CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
AlpgenPar Class Reference

#include <GeneratorInput.h>

Public Member Functions

 AlpgenPar (Pythia8::Info *infoPtrIn=NULL)
 
void extractRunParam (string line)
 
double getParam (const string &paramIn)
 
int getParamAsInt (const string &paramIn)
 
bool haveParam (const string &paramIn)
 
bool parse (const string paramStr)
 
void printParams ()
 

Private Member Functions

void warnParamOverwrite (const string &paramIn, double val)
 

Static Private Member Functions

static string trim (string s)
 

Private Attributes

Pythia8::Info * infoPtr
 
map< string, double > params
 

Static Private Attributes

static const double ZEROTHRESHOLD = 1e-10
 

Detailed Description

Definition at line 33 of file GeneratorInput.h.

Constructor & Destructor Documentation

AlpgenPar::AlpgenPar ( Pythia8::Info *  infoPtrIn = NULL)
inline

Definition at line 38 of file GeneratorInput.h.

38 : infoPtr(infoPtrIn) {}
Pythia8::Info * infoPtr

Member Function Documentation

void AlpgenPar::extractRunParam ( string  line)

Definition at line 62 of file GeneratorInput.cc.

References customizeTrackingMonitorSeedNumber::idx, and nevent.

62  {
63 
64  // Extract information to the right of the final '!' character
65  size_t idx = line.rfind("!");
66  if (idx == string::npos) return;
67  string paramName = trim(line.substr(idx + 1));
68  string paramVal = trim(line.substr(0, idx));
69  istringstream iss(paramVal);
70 
71  // Special case: 'hard process code' - single integer input
72  double val;
73  if (paramName == "hard process code") {
74  iss >> val;
75  warnParamOverwrite("hpc", val);
76  params["hpc"] = val;
77 
78  // Special case: 'Crosssection +- error (pb)' - two double values
79  } else if (paramName.find("Crosssection") == 0) {
80  double xerrup;
81  iss >> val >> xerrup;
82  warnParamOverwrite("xsecup", val);
83  warnParamOverwrite("xerrup", val);
84  params["xsecup"] = val;
85  params["xerrup"] = xerrup;
86 
87  // Special case: 'unwtd events, lum (pb-1)' - integer and double values
88  } else if (paramName.find("unwtd events") == 0) {
89  int nevent;
90  iss >> nevent >> val;
91  warnParamOverwrite("nevent", val);
92  warnParamOverwrite("lum", val);
93  params["nevent"] = nevent;
94  params["lum"] = val;
95 
96  // Special case: 'mc,mb,...' - split on ',' for name and ' ' for values
97  } else if (paramName.find(",") != string::npos) {
98 
99  // Simple tokeniser
100  string paramNameNow;
101  istringstream issName(paramName);
102  while (getline(issName, paramNameNow, ',')) {
103  iss >> val;
104  warnParamOverwrite(paramNameNow, val);
105  params[paramNameNow] = val;
106  }
107 
108  // Default case: assume integer and double on the left
109  } else {
110  int paramIdx;
111  iss >> paramIdx >> val;
112  warnParamOverwrite(paramName, val);
113  params[paramName] = val;
114  }
115 }
int nevent
Definition: AMPTWrapper.h:74
map< string, double > params
void warnParamOverwrite(const string &paramIn, double val)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static string trim(string s)
double AlpgenPar::getParam ( const string &  paramIn)
inline

Definition at line 52 of file GeneratorInput.h.

References haveParam(), and params.

Referenced by AlpgenHooks::initAfterBeams(), and LHAupAlpgen::setInit().

52  {
53  return (haveParam(paramIn)) ? params[paramIn] : 0.; }
map< string, double > params
bool haveParam(const string &paramIn)
int AlpgenPar::getParamAsInt ( const string &  paramIn)
inline

Definition at line 54 of file GeneratorInput.h.

References haveParam(), and params.

Referenced by AlpgenHooks::initAfterBeams(), and LHAupAlpgen::setInit().

54  {
55  return (haveParam(paramIn)) ? int(params[paramIn]) : 0.; }
map< string, double > params
bool haveParam(const string &paramIn)
bool AlpgenPar::haveParam ( const string &  paramIn)
inline

Definition at line 47 of file GeneratorInput.h.

References params.

Referenced by getParam(), getParamAsInt(), AlpgenHooks::initAfterBeams(), and LHAupAlpgen::setInit().

47  {
48  return (params.find(paramIn) == params.end()) ? false : true; }
map< string, double > params
bool AlpgenPar::parse ( const string  paramStr)

Definition at line 24 of file GeneratorInput.cc.

References createPayload::block, and geometryCSVtoXML::line.

Referenced by AlpgenHooks::initAfterBeams(), and LHAupAlpgen::LHAupAlpgen().

24  {
25 
26  // Read par file in blocks:
27  // 0 - process information
28  // 1 - run parameters
29  // 2 - cross sections
30  int block = 0;
31 
32  // Loop over incoming lines
33  stringstream paramStream(paramStr);
34  string line;
35  while (getline(paramStream, line)) {
36 
37  // Change to 'run parameters' block
38  if (line.find("run parameters") != string::npos) {
39  block = 1;
40 
41  // End of 'run parameters' block
42  } else if (line.find("end parameters") != string::npos) {
43  block = 2;
44 
45  // Do not extract anything from block 0 so far
46  } else if (block == 0) {
47 
48  // Block 1 or 2: extract parameters
49  } else {
50  extractRunParam(line);
51 
52  }
53  } // while (getline(paramStream, line))
54 
55  return true;
56 }
void extractRunParam(string line)
void AlpgenPar::printParams ( )

Definition at line 121 of file GeneratorInput.cc.

References gather_cfg::cout.

Referenced by AlpgenHooks::initAfterBeams().

121  {
122 
123  // Loop over all stored parameters and print
124  cout << fixed << setprecision(3) << endl
125  << " *------- Alpgen parameters -------*" << endl;
126  for (map < string, double >::iterator it = params.begin();
127  it != params.end(); ++it)
128  cout << " | " << left << setw(13) << it->first
129  << " | " << right << setw(13) << it->second
130  << " |" << endl;
131  cout << " *-----------------------------------*" << endl;
132 }
map< string, double > params
tuple cout
Definition: gather_cfg.py:121
string AlpgenPar::trim ( string  s)
staticprivate

Definition at line 152 of file GeneratorInput.cc.

References i, and alignCSCRings::s.

152  {
153 
154  // Remove whitespace in incoming string
155  size_t i;
156  if ((i = s.find_last_not_of(" \t\r\n")) != string::npos)
157  s = s.substr(0, i + 1);
158  if ((i = s.find_first_not_of(" \t\r\n")) != string::npos)
159  s = s.substr(i);
160  return s;
161 }
int i
Definition: DBlmapReader.cc:9
void AlpgenPar::warnParamOverwrite ( const string &  paramIn,
double  val 
)
private

Definition at line 138 of file GeneratorInput.cc.

References funct::abs().

138  {
139 
140  // Check if present and if new value is different
141  if (haveParam(paramIn) &&
142  abs(getParam(paramIn) - val) > ZEROTHRESHOLD) {
143  if (infoPtr) infoPtr->errorMsg("Warning in LHAupAlpgen::"
144  "warnParamOverwrite: overwriting existing parameter", paramIn);
145  }
146 }
Pythia8::Info * infoPtr
double getParam(const string &paramIn)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const double ZEROTHRESHOLD
bool haveParam(const string &paramIn)

Member Data Documentation

Pythia8::Info* AlpgenPar::infoPtr
private

Definition at line 72 of file GeneratorInput.h.

map<string,double> AlpgenPar::params
private

Definition at line 69 of file GeneratorInput.h.

Referenced by getParam(), getParamAsInt(), and haveParam().

const double AlpgenPar::ZEROTHRESHOLD = 1e-10
staticprivate

Definition at line 75 of file GeneratorInput.h.