10 #ifndef Pythia8_PythiaStdlib_H 11 #define Pythia8_PythiaStdlib_H 29 #include <unordered_map> 51 #include "Pythia8/PythiaFpe.h" 55 #define M_PI 3.1415926535897932385 60 #define SUBRUNDEFAULT -999 80 using std::numeric_limits;
92 using std::unordered_map;
94 using std::priority_queue;
108 using std::streambuf;
114 using std::stringstream;
115 using std::istringstream;
116 using std::ostringstream;
122 using std::scientific;
126 using std::setprecision;
129 using std::shared_ptr;
131 using std::unique_ptr;
132 using std::dynamic_pointer_cast;
133 using std::make_shared;
140 using std::lock_guard;
147 constexpr
double HBARC = 0.19732698;
148 constexpr
double GEV2FMINV = 1. /
HBARC;
149 constexpr
double GEVINV2FM =
HBARC;
150 constexpr
double FM2GEVINV = 1./
HBARC;
151 constexpr
double FMINV2GEV =
HBARC;
155 constexpr
double GEVSQ2MBINV = 1. /
HBARCSQ;
156 constexpr
double GEVSQINV2MB =
HBARCSQ;
157 constexpr
double MB2GEVSQINV = 1. /
HBARCSQ;
158 constexpr
double MBINV2GEVSQ =
HBARCSQ;
162 constexpr
double MM2FM = 1e12;
166 constexpr
double PB2MB = 1e-9;
167 constexpr
double MB2FB = 1e12;
168 constexpr
double FB2MB = 1e-12;
172 constexpr
double MB2FMSQ = 0.1;
175 constexpr
double pow2(
const double& x) {
return x*x;}
176 constexpr
double pow3(
const double& x) {
return x*x*x;}
177 constexpr
double pow4(
const double& x) {
return x*x*x*x;}
178 constexpr
double pow5(
const double& x) {
return x*x*x*x*x;}
179 constexpr
double pow6(
const double& x) {
return x*x*x*x*x*x;}
180 constexpr
double pow7(
const double& x) {
return x*x*x*x*x*x*x;}
181 constexpr
double pow8(
const double& x) {
return x*x*x*x*x*x*x*x;}
184 inline double sqrtpos(
const double& x) {
return sqrt( max( 0., x));}
188 return x > 0 ? sqrt(x) : numeric_limits<double>::quiet_NaN(); }
191 inline double clamp(
const double& x,
const double& xmin,
const double& xmax) {
192 return (x < xmin) ? xmin : (x > xmax) ? xmax : x; }
196 string toLower(
const string& name,
bool trim =
true);
210 inline string toString(
bool val) {
return val ?
"on" :
"off";}
213 inline string toString(
int val) {
return to_string(val);}
219 vector<string>
splitString(
string val,
string delim);
276 #ifndef __METHOD_NAME__ 278 #ifndef PYTHIA_FUNCTION 279 #if ( defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \ 280 || (defined(__ICC) && (__ICC >= 600)) ) 281 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__ 282 #elif defined(__DMC__) && (__DMC__ >= 0x810) 283 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__ 284 #elif defined(__FUNCSIG__) 285 # define PYTHIA_FUNCTION __FUNCSIG__ 286 #elif ( (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) \ 287 || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) ) 288 # define PYTHIA_FUNCTION __FUNCTION__ 289 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 290 # define PYTHIA_FUNCTION __FUNC__ 291 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) 292 # define PYTHIA_FUNCTION __func__ 294 # define PYTHIA_FUNCTION "unknown" 298 inline std::string
methodName(
const std::string& prettyFunction,
bool 299 withNamespace=
false) {
302 size_t end = prettyFunction.rfind(
')');
303 int bracketCount = 1;
304 while (bracketCount > 0) {
306 if (prettyFunction[end] ==
')') ++bracketCount;
307 else if (prettyFunction[end] ==
'(') --bracketCount;
311 size_t begin = prettyFunction.rfind(
' ', end) + 1;
313 begin = prettyFunction.find(
"::", begin) + 2;
316 return prettyFunction.substr(begin, end - begin);
319 #define __METHOD_NAME__ methodName(PYTHIA_FUNCTION) 328 template <
class T1,
class T2>
struct hash<pair<T1, T2> > {
330 size_t operator()(
const pair<T1, T2>& p)
const {
331 return hash<T1>{}(p.first) ^ hash<T2>{}(p.second);
constexpr double pow2(const double &x)
Powers of small integers - for balance speed/code clarity.
Definition: PythiaStdlib.h:175
vector< double > doubleVectorAttributeValue(string line, string attribute)
Extract XML double vector value following XML attribute.
Definition: PythiaStdlib.cc:205
vector< string > splitString(string val, string delim)
Split a string by a delimiter.
Definition: PythiaStdlib.cc:72
double doubleAttributeValue(string line, string attribute)
Extract XML double value following XML attribute.
Definition: PythiaStdlib.cc:141
vector< bool > boolVectorAttributeValue(string line, string attribute)
Extract XML bool vector value following XML attribute.
Definition: PythiaStdlib.cc:155
int intAttributeValue(string line, string attribute)
Extract XML int value following XML attribute.
Definition: PythiaStdlib.cc:127
void completeTag(istream &stream, string &line)
Complete an XML tag.
Definition: PythiaStdlib.cc:257
end namespace Pythia8
Definition: PythiaStdlib.h:327
void toLowerRep(string &name, bool trim=true)
Variant of above, with in-place replacement.
Definition: PythiaStdlib.h:199
string toLower(const string &name, bool trim=true)
Definition: PythiaStdlib.cc:20
constexpr double MB2PB
Define conversion between mb and pb or fb, in both directions.
Definition: PythiaStdlib.h:165
bool boolString(string tag)
Useful functions for string handling.
Definition: PythiaStdlib.cc:89
string attributeValue(string line, string attribute)
Extract XML value string following XML attribute.
Definition: PythiaStdlib.cc:101
constexpr double FM2MM
Define conversion between fm and mm, in both directions.
Definition: PythiaStdlib.h:161
constexpr double HBARC
Define conversion hbar * c = 0.2 GeV * fm = 1 and related.
Definition: PythiaStdlib.h:147
void trimStringRep(string &name)
Variant of above, with in-place replacement.
Definition: PythiaStdlib.h:206
string toString(bool val)
Convert a boolean to a string.
Definition: PythiaStdlib.h:210
std::string methodName(const std::string &prettyFunction, bool withNamespace=false)
end PYTHIA_FUNCTION
Definition: PythiaStdlib.h:298
vector< string > stringVectorAttributeValue(string line, string attribute)
Extract XML string vector value following XML attribute.
Definition: PythiaStdlib.cc:231
double sqrtnan(const double &x)
Explicitly return NaN if negative square root argument, without FPE.
Definition: PythiaStdlib.h:187
string trimString(const string &name)
Remove any initial and trailing blanks or escape characters.
Definition: PythiaStdlib.cc:37
bool boolAttributeValue(string line, string attribute)
Extract XML bool value following XML attribute.
Definition: PythiaStdlib.cc:115
constexpr double FMSQ2MB
Define conversion between fm^2 and mb, in both directions.
Definition: PythiaStdlib.h:171
double clamp(const double &x, const double &xmin, const double &xmax)
Restrinct value to lie in specified range.
Definition: PythiaStdlib.h:191
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
constexpr double HBARCSQ
Define conversion (hbar * c)^2 = 0.4 GeV^2 * mb = 1 and related.
Definition: PythiaStdlib.h:154
vector< int > intVectorAttributeValue(string line, string attribute)
Extract XML int vector value following XML attribute.
Definition: PythiaStdlib.cc:179
double sqrtpos(const double &x)
Avoid problem with negative square root argument (from roundoff).
Definition: PythiaStdlib.h:184