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
MadgraphPar Class Reference

#include <GeneratorInput.h>

Public Member Functions

void extractRunParam (string line)
 
double getParam (const string &paramIn)
 
int getParamAsInt (const string &paramIn)
 
bool haveParam (const string &paramIn)
 
 MadgraphPar (Pythia8::Info *infoPtrIn=NULL)
 
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 157 of file GeneratorInput.h.

Constructor & Destructor Documentation

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

Definition at line 162 of file GeneratorInput.h.

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

Member Function Documentation

void MadgraphPar::extractRunParam ( string  line)

Definition at line 959 of file GeneratorInput.cc.

References customizeTrackingMonitorSeedNumber::idx, params, python.rootplot.root2matplotlib::replace(), trim(), and warnParamOverwrite().

Referenced by parse().

959  {
960 
961  // Extract information to the right of the final '!' character
962  size_t idz = line.find("#");
963  if ( !(idz == string::npos) ) return;
964  size_t idx = line.find("=");
965  size_t idy = line.find("!");
966  if (idy == string::npos) idy = line.size();
967  if (idx == string::npos) return;
968  string paramName = trim( line.substr( idx + 1, idy - idx - 1) );
969  string paramVal = trim( line.substr( 0, idx) );
970  replace( paramVal.begin(), paramVal.end(), 'd', 'e');
971 
972  // Simple tokeniser
973  istringstream iss(paramVal);
974  double val;
975  if (paramName.find(",") != string::npos) {
976  string paramNameNow;
977  istringstream issName( paramName);
978  while ( getline(issName, paramNameNow, ',') ) {
979  iss >> val;
980  warnParamOverwrite( paramNameNow, val);
981  params[paramNameNow] = val;
982  }
983 
984  // Default case: assume integer and double on the left
985  } else {
986  iss >> val;
987  warnParamOverwrite( paramName, val);
988  params[paramName] = val;
989  }
990 }
void warnParamOverwrite(const string &paramIn, double val)
map< string, double > params
static string trim(string s)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
double MadgraphPar::getParam ( const string &  paramIn)
inline

Definition at line 176 of file GeneratorInput.h.

References haveParam(), and params.

Referenced by JetMatchingMadgraph::initAfterBeams(), and warnParamOverwrite().

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

Definition at line 178 of file GeneratorInput.h.

References haveParam(), and params.

Referenced by JetMatchingMadgraph::initAfterBeams().

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

Definition at line 171 of file GeneratorInput.h.

References params.

Referenced by getParam(), getParamAsInt(), JetMatchingMadgraph::initAfterBeams(), and warnParamOverwrite().

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

Definition at line 945 of file GeneratorInput.cc.

References extractRunParam(), and geometryCSVtoXML::line.

Referenced by JetMatchingMadgraph::initAfterBeams().

945  {
946 
947  // Loop over incoming lines
948  stringstream paramStream(paramStr);
949  string line;
950  while ( getline(paramStream, line) ) extractRunParam(line);
951  return true;
952 
953 }
void extractRunParam(string line)
void MadgraphPar::printParams ( )

Definition at line 996 of file GeneratorInput.cc.

References gather_cfg::cout, and params.

Referenced by JetMatchingMadgraph::initAfterBeams().

996  {
997 
998  // Loop over all stored parameters and print
999  cout << endl
1000  << " *-------- Madgraph parameters --------*" << endl;
1001  for (map<string,double>::iterator it = params.begin();
1002  it != params.end(); ++it)
1003  cout << " | " << left << setw(15) << it->first
1004  << " | " << right << setw(15) << it->second
1005  << " |" << endl;
1006  cout << " *---------------------------------------*" << endl;
1007 }
map< string, double > params
tuple cout
Definition: gather_cfg.py:121
string MadgraphPar::trim ( string  s)
staticprivate

Definition at line 1027 of file GeneratorInput.cc.

References i, and alignCSCRings::s.

Referenced by extractRunParam().

1027  {
1028 
1029  // Remove whitespace in incoming string
1030  size_t i;
1031  if ( (i = s.find_last_not_of(" \t\r\n")) != string::npos)
1032  s = s.substr(0, i + 1);
1033  if ( (i = s.find_first_not_of(" \t\r\n")) != string::npos)
1034  s = s.substr(i);
1035  return s;
1036 }
int i
Definition: DBlmapReader.cc:9
void MadgraphPar::warnParamOverwrite ( const string &  paramIn,
double  val 
)
private

Definition at line 1013 of file GeneratorInput.cc.

References funct::abs(), getParam(), haveParam(), infoPtr, and ZEROTHRESHOLD.

Referenced by extractRunParam().

1013  {
1014 
1015  // Check if present and if new value is different
1016  if (haveParam(paramIn) &&
1017  abs(getParam(paramIn) - val) > ZEROTHRESHOLD) {
1018  if (infoPtr) infoPtr->errorMsg("Warning in LHAupAlpgen::"
1019  "warnParamOverwrite: overwriting existing parameter", paramIn);
1020  }
1021 }
bool haveParam(const string &paramIn)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double getParam(const string &paramIn)
static const double ZEROTHRESHOLD
Pythia8::Info * infoPtr

Member Data Documentation

Pythia8::Info* MadgraphPar::infoPtr
private

Definition at line 196 of file GeneratorInput.h.

Referenced by warnParamOverwrite().

map<string,double> MadgraphPar::params
private

Definition at line 193 of file GeneratorInput.h.

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

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

Definition at line 199 of file GeneratorInput.h.

Referenced by warnParamOverwrite().