File indexing completed on 2025-09-18 09:25:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef Pythia8_PythiaStdlib_H
0011 #define Pythia8_PythiaStdlib_H
0012
0013
0014 #include <cstddef>
0015 #include <cmath>
0016 #include <cstdlib>
0017 #include <algorithm>
0018 #include <memory>
0019 #include <functional>
0020 #include <limits>
0021 #include <utility>
0022
0023
0024 #include <string>
0025 #include <vector>
0026 #include <array>
0027 #include <map>
0028 #include <unordered_map>
0029 #include <deque>
0030 #include <queue>
0031 #include <set>
0032 #include <list>
0033 #include <functional>
0034
0035
0036 #include <dlfcn.h>
0037
0038
0039 #include <iostream>
0040 #include <iomanip>
0041 #include <fstream>
0042 #include <sstream>
0043
0044
0045 #include <mutex>
0046 #include <atomic>
0047 #include <thread>
0048
0049
0050 #include "Pythia8/PythiaFpe.h"
0051
0052
0053 #ifndef M_PI
0054 #define M_PI 3.1415926535897932385
0055 #endif
0056
0057
0058 #ifndef SUBRUNDEFAULT
0059 #define SUBRUNDEFAULT -999
0060 #endif
0061
0062
0063
0064
0065
0066
0067 namespace Pythia8 {
0068
0069
0070 using std::swap;
0071 using std::max;
0072 using std::min;
0073 using std::abs;
0074 using std::sort;
0075 using std::function;
0076 using std::isnan;
0077 using std::isinf;
0078 using std::isfinite;
0079 using std::numeric_limits;
0080
0081
0082 using std::pair;
0083 using std::make_pair;
0084 using std::string;
0085 using std::to_string;
0086 using std::vector;
0087 using std::array;
0088 using std::map;
0089 using std::multimap;
0090 using std::unordered_map;
0091 using std::deque;
0092 using std::priority_queue;
0093 using std::set;
0094 using std::multiset;
0095 using std::list;
0096 using std::tuple;
0097 using std::function;
0098 using std::fill;
0099 using std::end;
0100 using std::begin;
0101
0102
0103 using std::cin;
0104 using std::cout;
0105 using std::cerr;
0106 using std::streambuf;
0107 using std::istream;
0108 using std::ostream;
0109 using std::fstream;
0110 using std::ifstream;
0111 using std::ofstream;
0112 using std::stringstream;
0113 using std::istringstream;
0114 using std::ostringstream;
0115 using std::ios;
0116
0117
0118 using std::endl;
0119 using std::fixed;
0120 using std::scientific;
0121 using std::left;
0122 using std::right;
0123 using std::setw;
0124 using std::setprecision;
0125
0126
0127 using std::shared_ptr;
0128 using std::weak_ptr;
0129 using std::unique_ptr;
0130 using std::dynamic_pointer_cast;
0131 using std::make_shared;
0132
0133
0134 using std::queue;
0135 using std::mutex;
0136 using std::thread;
0137 using std::atomic;
0138 using std::lock_guard;
0139
0140 }
0141
0142 namespace Pythia8 {
0143
0144
0145 constexpr double HBARC = 0.19732698;
0146 constexpr double GEV2FMINV = 1. / HBARC;
0147 constexpr double GEVINV2FM = HBARC;
0148 constexpr double FM2GEVINV = 1./HBARC;
0149 constexpr double FMINV2GEV = HBARC;
0150
0151
0152 constexpr double HBARCSQ = 0.38937937;
0153 constexpr double GEVSQ2MBINV = 1. / HBARCSQ;
0154 constexpr double GEVSQINV2MB = HBARCSQ;
0155 constexpr double MB2GEVSQINV = 1. / HBARCSQ;
0156 constexpr double MBINV2GEVSQ = HBARCSQ;
0157
0158
0159 constexpr double FM2MM = 1e-12;
0160 constexpr double MM2FM = 1e12;
0161
0162
0163 constexpr double MB2PB = 1e9;
0164 constexpr double PB2MB = 1e-9;
0165 constexpr double MB2FB = 1e12;
0166 constexpr double FB2MB = 1e-12;
0167
0168
0169 constexpr double FMSQ2MB = 10.;
0170 constexpr double MB2FMSQ = 0.1;
0171
0172
0173 constexpr double pow2(const double& x) {return x*x;}
0174 constexpr double pow3(const double& x) {return x*x*x;}
0175 constexpr double pow4(const double& x) {return x*x*x*x;}
0176 constexpr double pow5(const double& x) {return x*x*x*x*x;}
0177 constexpr double pow6(const double& x) {return x*x*x*x*x*x;}
0178 constexpr double pow7(const double& x) {return x*x*x*x*x*x*x;}
0179 constexpr double pow8(const double& x) {return x*x*x*x*x*x*x*x;}
0180
0181
0182 inline double sqrtpos(const double& x) {return sqrt( max( 0., x));}
0183
0184
0185 inline double sqrtnan(const double& x) {
0186 return x > 0 ? sqrt(x) : numeric_limits<double>::quiet_NaN(); }
0187
0188
0189 inline double clamp(const double& x, const double& xmin, const double& xmax) {
0190 return (x < xmin) ? xmin : (x > xmax) ? xmax : x; }
0191
0192
0193
0194 string toLower(const string& name, bool trim = true);
0195
0196
0197 inline void toLowerRep(string& name, bool trim = true) {
0198 name = toLower( name, trim);}
0199
0200
0201 string trimString(const string& name);
0202
0203
0204 inline void trimStringRep(string& name) {
0205 name = trimString( name);}
0206
0207
0208 inline string toString(bool val) {return val ? "on" : "off";}
0209
0210
0211 inline string toString(int val) {return to_string(val);}
0212
0213
0214 string toString(double val);
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259 #ifndef __METHOD_NAME__
0260
0261 #ifndef PYTHIA_FUNCTION
0262 #if ( defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \
0263 || (defined(__ICC) && (__ICC >= 600)) )
0264 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__
0265 #elif defined(__DMC__) && (__DMC__ >= 0x810)
0266 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__
0267 #elif defined(__FUNCSIG__)
0268 # define PYTHIA_FUNCTION __FUNCSIG__
0269 #elif ( (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) \
0270 || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) )
0271 # define PYTHIA_FUNCTION __FUNCTION__
0272 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
0273 # define PYTHIA_FUNCTION __FUNC__
0274 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
0275 # define PYTHIA_FUNCTION __func__
0276 #else
0277 # define PYTHIA_FUNCTION "unknown"
0278 #endif
0279 #endif
0280
0281 inline std::string methodName(const std::string& prettyFunction, bool
0282 withNamespace=false) {
0283
0284
0285 size_t end = prettyFunction.rfind(')');
0286 int bracketCount = 1;
0287 while (bracketCount > 0) {
0288 --end;
0289 if (prettyFunction[end] == ')') ++bracketCount;
0290 else if (prettyFunction[end] == '(') --bracketCount;
0291 }
0292
0293
0294 size_t begin = prettyFunction.rfind(' ', end) + 1;
0295 if (!withNamespace)
0296 begin = prettyFunction.find("::", begin) + 2;
0297
0298
0299 return prettyFunction.substr(begin, end - begin);
0300 }
0301
0302 #define __METHOD_NAME__ methodName(PYTHIA_FUNCTION)
0303 #endif
0304
0305
0306
0307 }
0308
0309
0310 namespace std {
0311 template <class T1, class T2> struct hash<pair<T1, T2> > {
0312 public:
0313 size_t operator()(const pair<T1, T2>& p) const {
0314 return hash<T1>{}(p.first) ^ hash<T2>{}(p.second);
0315 }
0316 };
0317
0318
0319
0320 }
0321
0322 #endif