File indexing completed on 2025-01-18 10:06:28
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 #ifndef M_PI
0051 #define M_PI 3.1415926535897932385
0052 #endif
0053
0054
0055 #ifndef SUBRUNDEFAULT
0056 #define SUBRUNDEFAULT -999
0057 #endif
0058
0059
0060
0061 #ifdef GCCFPDEBUG
0062 #ifndef __ENABLE_FP_DEBUG__
0063 #define __ENABLE_FP_DEBUG__
0064 #include <fenv.h>
0065 static void __attribute__((constructor)) raisefpe() {
0066 feenableexcept (FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID);
0067 }
0068 #endif
0069 #endif
0070
0071
0072
0073
0074
0075
0076 namespace Pythia8 {
0077
0078
0079 using std::swap;
0080 using std::max;
0081 using std::min;
0082 using std::abs;
0083 using std::sort;
0084 using std::function;
0085 using std::isnan;
0086 using std::isinf;
0087 using std::isfinite;
0088 using std::numeric_limits;
0089
0090
0091 using std::pair;
0092 using std::make_pair;
0093 using std::string;
0094 using std::to_string;
0095 using std::vector;
0096 using std::array;
0097 using std::map;
0098 using std::multimap;
0099 using std::unordered_map;
0100 using std::deque;
0101 using std::priority_queue;
0102 using std::set;
0103 using std::multiset;
0104 using std::list;
0105 using std::tuple;
0106 using std::function;
0107 using std::fill;
0108 using std::end;
0109 using std::begin;
0110
0111
0112 using std::cin;
0113 using std::cout;
0114 using std::cerr;
0115 using std::streambuf;
0116 using std::istream;
0117 using std::ostream;
0118 using std::fstream;
0119 using std::ifstream;
0120 using std::ofstream;
0121 using std::stringstream;
0122 using std::istringstream;
0123 using std::ostringstream;
0124 using std::ios;
0125
0126
0127 using std::endl;
0128 using std::fixed;
0129 using std::scientific;
0130 using std::left;
0131 using std::right;
0132 using std::setw;
0133 using std::setprecision;
0134
0135
0136 using std::shared_ptr;
0137 using std::weak_ptr;
0138 using std::unique_ptr;
0139 using std::dynamic_pointer_cast;
0140 using std::make_shared;
0141
0142
0143 using std::queue;
0144 using std::mutex;
0145 using std::thread;
0146 using std::atomic;
0147 using std::lock_guard;
0148
0149 }
0150
0151 namespace Pythia8 {
0152
0153
0154 constexpr double HBARC = 0.19732698;
0155 constexpr double GEV2FMINV = 1. / HBARC;
0156 constexpr double GEVINV2FM = HBARC;
0157 constexpr double FM2GEVINV = 1./HBARC;
0158 constexpr double FMINV2GEV = HBARC;
0159
0160
0161 constexpr double HBARCSQ = 0.38937937;
0162 constexpr double GEVSQ2MBINV = 1. / HBARCSQ;
0163 constexpr double GEVSQINV2MB = HBARCSQ;
0164 constexpr double MB2GEVSQINV = 1. / HBARCSQ;
0165 constexpr double MBINV2GEVSQ = HBARCSQ;
0166
0167
0168 constexpr double FM2MM = 1e-12;
0169 constexpr double MM2FM = 1e12;
0170
0171
0172 constexpr double MB2PB = 1e9;
0173 constexpr double PB2MB = 1e-9;
0174 constexpr double MB2FB = 1e12;
0175 constexpr double FB2MB = 1e-12;
0176
0177
0178 constexpr double FMSQ2MB = 10.;
0179 constexpr double MB2FMSQ = 0.1;
0180
0181
0182 constexpr double pow2(const double& x) {return x*x;}
0183 constexpr double pow3(const double& x) {return x*x*x;}
0184 constexpr double pow4(const double& x) {return x*x*x*x;}
0185 constexpr double pow5(const double& x) {return x*x*x*x*x;}
0186 constexpr double pow6(const double& x) {return x*x*x*x*x*x;}
0187 constexpr double pow7(const double& x) {return x*x*x*x*x*x*x;}
0188 constexpr double pow8(const double& x) {return x*x*x*x*x*x*x*x;}
0189
0190
0191 inline double sqrtpos(const double& x) {return sqrt( max( 0., x));}
0192
0193
0194 inline double sqrtnan(const double& x) {
0195 return x > 0 ? sqrt(x) : numeric_limits<double>::quiet_NaN(); }
0196
0197
0198 inline double clamp(const double& x, const double& xmin, const double& xmax) {
0199 return (x < xmin) ? xmin : (x > xmax) ? xmax : x; }
0200
0201
0202
0203 string toLower(const string& name, bool trim = true);
0204
0205
0206 inline void toLowerRep(string& name, bool trim = true) {
0207 name = toLower( name, trim);}
0208
0209
0210 inline string toString(bool val) {return val ? "on" : "off";}
0211
0212
0213 inline string toString(int val) {return to_string(val);}
0214
0215
0216 string toString(double val);
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
0260
0261 #ifndef __METHOD_NAME__
0262
0263 #ifndef PYTHIA_FUNCTION
0264 #if ( defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \
0265 || (defined(__ICC) && (__ICC >= 600)) )
0266 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__
0267 #elif defined(__DMC__) && (__DMC__ >= 0x810)
0268 # define PYTHIA_FUNCTION __PRETTY_FUNCTION__
0269 #elif defined(__FUNCSIG__)
0270 # define PYTHIA_FUNCTION __FUNCSIG__
0271 #elif ( (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) \
0272 || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) )
0273 # define PYTHIA_FUNCTION __FUNCTION__
0274 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
0275 # define PYTHIA_FUNCTION __FUNC__
0276 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
0277 # define PYTHIA_FUNCTION __func__
0278 #else
0279 # define PYTHIA_FUNCTION "unknown"
0280 #endif
0281 #endif
0282
0283 inline std::string methodName(const std::string& prettyFunction, bool
0284 withNamespace=false) {
0285
0286
0287 size_t end = prettyFunction.rfind(')');
0288 int bracketCount = 1;
0289 while (bracketCount > 0) {
0290 --end;
0291 if (prettyFunction[end] == ')') ++bracketCount;
0292 else if (prettyFunction[end] == '(') --bracketCount;
0293 }
0294
0295
0296 size_t begin = prettyFunction.rfind(' ', end) + 1;
0297 if (!withNamespace)
0298 begin = prettyFunction.find("::", begin) + 2;
0299
0300
0301 return prettyFunction.substr(begin, end - begin);
0302 }
0303
0304 #define __METHOD_NAME__ methodName(PYTHIA_FUNCTION)
0305 #endif
0306
0307
0308
0309 }
0310
0311
0312 namespace std {
0313 template <class T1, class T2> struct hash<pair<T1, T2> > {
0314 public:
0315 size_t operator()(const pair<T1, T2>& p) const {
0316 return hash<T1>{}(p.first) ^ hash<T2>{}(p.second);
0317 }
0318 };
0319
0320
0321
0322 }
0323
0324 #endif