10 #ifndef Pythia8_PythiaStdlib_H 11 #define Pythia8_PythiaStdlib_H 28 #include <unordered_map> 50 #include "Pythia8/PythiaFpe.h" 54 #define M_PI 3.1415926535897932385 59 #define SUBRUNDEFAULT -999 79 using std::numeric_limits;
90 using std::unordered_map;
92 using std::priority_queue;
106 using std::streambuf;
112 using std::stringstream;
113 using std::istringstream;
114 using std::ostringstream;
120 using std::scientific;
124 using std::setprecision;
127 using std::shared_ptr;
129 using std::unique_ptr;
130 using std::dynamic_pointer_cast;
131 using std::make_shared;
138 using std::lock_guard;
145 constexpr
double HBARC = 0.19732698;
146 constexpr
double GEV2FMINV = 1. /
HBARC;
147 constexpr
double GEVINV2FM =
HBARC;
148 constexpr
double FM2GEVINV = 1./
HBARC;
149 constexpr
double FMINV2GEV =
HBARC;
153 constexpr
double GEVSQ2MBINV = 1. /
HBARCSQ;
154 constexpr
double GEVSQINV2MB =
HBARCSQ;
155 constexpr
double MB2GEVSQINV = 1. /
HBARCSQ;
156 constexpr
double MBINV2GEVSQ =
HBARCSQ;
160 constexpr
double MM2FM = 1e12;
164 constexpr
double PB2MB = 1e-9;
165 constexpr
double MB2FB = 1e12;
166 constexpr
double FB2MB = 1e-12;
170 constexpr
double MB2FMSQ = 0.1;
173 constexpr
double pow2(
const double& x) {
return x*x;}
174 constexpr
double pow3(
const double& x) {
return x*x*x;}
175 constexpr
double pow4(
const double& x) {
return x*x*x*x;}
176 constexpr
double pow5(
const double& x) {
return x*x*x*x*x;}
177 constexpr
double pow6(
const double& x) {
return x*x*x*x*x*x;}
178 constexpr
double pow7(
const double& x) {
return x*x*x*x*x*x*x;}
179 constexpr
double pow8(
const double& x) {
return x*x*x*x*x*x*x*x;}
182 inline double sqrtpos(
const double& x) {
return sqrt( max( 0., x));}
186 return x > 0 ? sqrt(x) : numeric_limits<double>::quiet_NaN(); }
189 inline double clamp(
const double& x,
const double& xmin,
const double& xmax) {
190 return (x < xmin) ? xmin : (x > xmax) ? xmax : x; }
194 string toLower(
const string& name,
bool trim =
true);
208 inline string toString(
bool val) {
return val ?
"on" :
"off";}
211 inline string toString(
int val) {
return to_string(val);}
259 #ifndef __METHOD_NAME__ 261 #ifndef PYTHIA_FUNCTION 262 #if ( defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \ 263 || (defined(__ICC) && (__ICC >= 600)) ) 264 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__ 265 #elif defined(__DMC__) && (__DMC__ >= 0x810) 266 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__ 267 #elif defined(__FUNCSIG__) 268 # define PYTHIA_FUNCTION __FUNCSIG__ 269 #elif ( (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) \ 270 || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) ) 271 # define PYTHIA_FUNCTION __FUNCTION__ 272 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 273 # define PYTHIA_FUNCTION __FUNC__ 274 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) 275 # define PYTHIA_FUNCTION __func__ 277 # define PYTHIA_FUNCTION "unknown" 281 inline std::string
methodName(
const std::string& prettyFunction,
bool 282 withNamespace=
false) {
285 size_t end = prettyFunction.rfind(
')');
286 int bracketCount = 1;
287 while (bracketCount > 0) {
289 if (prettyFunction[end] ==
')') ++bracketCount;
290 else if (prettyFunction[end] ==
'(') --bracketCount;
294 size_t begin = prettyFunction.rfind(
' ', end) + 1;
296 begin = prettyFunction.find(
"::", begin) + 2;
299 return prettyFunction.substr(begin, end - begin);
302 #define __METHOD_NAME__ methodName(PYTHIA_FUNCTION) 311 template <
class T1,
class T2>
struct hash<pair<T1, T2> > {
313 size_t operator()(
const pair<T1, T2>& p)
const {
314 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:173
end namespace Pythia8
Definition: PythiaStdlib.h:310
void toLowerRep(string &name, bool trim=true)
Variant of above, with in-place replacement.
Definition: PythiaStdlib.h:197
string toLower(const string &name, bool trim=true)
Definition: PythiaStdlib.cc:17
constexpr double MB2PB
Define conversion between mb and pb or fb, in both directions.
Definition: PythiaStdlib.h:163
constexpr double FM2MM
Define conversion between fm and mm, in both directions.
Definition: PythiaStdlib.h:159
constexpr double HBARC
Define conversion hbar * c = 0.2 GeV * fm = 1 and related.
Definition: PythiaStdlib.h:145
void trimStringRep(string &name)
Variant of above, with in-place replacement.
Definition: PythiaStdlib.h:204
string toString(bool val)
Convert a boolean to a string.
Definition: PythiaStdlib.h:208
std::string methodName(const std::string &prettyFunction, bool withNamespace=false)
end PYTHIA_FUNCTION
Definition: PythiaStdlib.h:281
double sqrtnan(const double &x)
Explicitly return NaN if negative square root argument, without FPE.
Definition: PythiaStdlib.h:185
string trimString(const string &name)
Remove any initial and trailing blanks or escape characters.
Definition: PythiaStdlib.cc:34
constexpr double FMSQ2MB
Define conversion between fm^2 and mb, in both directions.
Definition: PythiaStdlib.h:169
double clamp(const double &x, const double &xmin, const double &xmax)
Restrinct value to lie in specified range.
Definition: PythiaStdlib.h:189
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:152
double sqrtpos(const double &x)
Avoid problem with negative square root argument (from roundoff).
Definition: PythiaStdlib.h:182