/usr/include/ThePEG/Repository/UseRandom.h is in libthepeg-dev 1.8.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | // -*- C++ -*-
//
// UseRandom.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_UseRandom_H
#define ThePEG_UseRandom_H
// This is the declaration of the UseRandom class.
#include "ThePEG/Repository/RandomGenerator.h"
namespace ThePEG {
/**
* This UseRandom class keeps a static stack of RandomGenerator
* objects which can be used anywhere by any class. When an
* EventGenerator is initialized or run it adds a RandomGenerator
* object to the stack which can be used by any other object being
* initialized or run through the static functions of the UseRandom
* class. If someone needs to use an alternative RandomGenerator
* object a new UseRandom object can be constructed with a pointer to
* the desired RandomGenerator object as argument and that object will
* the be used by the static UseRandom functions until the UseRandom
* object is destructed.
*
* @see RandomGenerator
* @see EventGenerator
*
*/
class UseRandom {
public:
/**
* Default constructor does nothing.
*/
UseRandom() : randomPushed(false) {}
/**
* Copy-constructor does nothing.
*/
UseRandom(const UseRandom &) : randomPushed(false) {}
/**
* Construct a new object specifying a new RandomGenerator, \a r, to
* be used during this objects lifetime
*/
UseRandom(const RanGenPtr & r) : randomPushed(false) {
if ( r ) {
theRandomStack.push_back(r);
randomPushed = true;
}
}
/**
* The destructor removing the RandomGenerator specified in the
* constructor from the stack.
*/
~UseRandom() { if ( randomPushed ) theRandomStack.pop_back(); }
public:
/**
* Return a reference to the currently chosen RandomGenerator object.
*/
static RandomGenerator & current() { return *theRandomStack.back(); }
/**
* Return a pointer to the currently chosen RandomGenerator object.
*/
// static RandomEngine * currentEngine() {
// return &(current().randomGenerator());
// }
/**
* Return a simple flat random number (from the current
* RandomGenerator object) in the range ]0,1[.
*/
static double rnd() { return current().rnd(); }
/**
* Return \a n simple flat random number (from the current
* RandomGenerator object) in the range ]0,1[.
*/
static RandomGenerator::RndVector rndvec(int n) {
return current().rndvec(n);
}
/**
* Return a simple flat random number (from the current
* RandomGenerator object) in the range ]0,\a xu[.
*/
template <typename Unit>
static Unit rnd(Unit xu) { return current().rnd(xu); }
/**
* Return a simple flat random number (from the current
* RandomGenerator object) in the range ]\a xl,\a xu[.
*/
template <typename Unit>
static Unit rnd(Unit xl, Unit xu) {
return current().rnd(xl, xu);
}
/**
* Return a true with probability \a p (default 0.5).
*/
static bool rndbool(double p = 0.5) {
return current().rndbool(p);
}
/**
* Return a true with probability \a p1/(\a p1+\a p2).
*/
static bool rndbool(double p1, double p2) {
return current().rndbool(p1, p2);
}
/**
* Return -1, 0, or 1 with relative probabilities \a p1, \a p2, \a
* p3.
*/
static int rndsign(double p1, double p2, double p3) {
return current().rndsign(p1, p2, p3);
}
/**
* Return an integer \f$i\f$ with probability p\f$i\f$/(\a p0+\a
* p1).
*/
static int rnd2(double p0, double p1) {
return current().rnd2(p0, p1);
}
/**
* Return an integer \f$i\f$ with probability p\f$i\f$/(\a p0+\a
* p1+\a p2).
*/
static int rnd3(double p0, double p1, double p2) {
return current().rnd3(p0, p1, p2);
}
/**
* Return an integer/ \f$i\f$ with probability p\f$i\f$(\a p0+\a
* p1+\a p2+\a p3).
*/
static int rnd4(double p0, double p1, double p2, double p3) {
return current().rnd4(p0, p1, p2, p3);
}
/**
* Return a simple flat random integrer number in the range [0,\a xu[.
*/
static long irnd(long xu = 2) { return long(rnd() * xu); }
/**
* Return a simple flat random integrer number in the range [\a xl,\a xu[.
*/
static long irnd(long xl, long xu) { return xl + irnd(xu-xl); }
/**
* Return a number between zero and infinity, distributed according
* to \f$e^-x\f$.
*/
static double rndExp() { return current().rndExp(); }
/**
* Return a number between zero and infinity, distributed according
* to \f$e^-{x/\mu}\f$ where \f$\mu\f$ is the \a mean value.
*/
template <typename Unit>
static Unit rndExp(Unit mean) { return current().rndExp(mean); }
/**
* Return a number distributed according to a Gaussian distribution
* with zero mean and unit variance.
*/
static double rndGauss() { return current().rndGauss(); }
/**
* Return a number distributed according to a Gaussian distribution
* with a given standard deviation, \a sigma, and a given \a mean.
*/
template <typename Unit>
static Unit rndGauss(Unit sigma, Unit mean = Unit()) {
return current().rndGauss(sigma, mean);
}
/**
* Return a positive number distributed according to a
* non-relativistic Breit-Wigner with a given width, \a gamma, and a
* given \a mean.
*/
template <typename Unit>
static Unit rndBW(Unit mean, Unit gamma) {
return current().rndBW(mean, gamma);
}
/**
* Return a positive number distributed according to a
* non-relativistic Breit-Wigner with a given width, \a gamma, and a
* given \a mean. The distribution is cut-off so that the number is
* between \a mean - \a cut and \a mean + \a cut
*/
template <typename Unit>
static Unit rndBW(Unit mean, Unit gamma, Unit cut) {
return current().rndBW(mean, gamma, cut);
}
/**
* Return a positive number distributed according to a relativistic
* Breit-Wigner with a given width, \a gamma, and a given \a mean.
*/
template <typename Unit>
static Unit rndRelBW(Unit mean, Unit gamma) {
return current().rndRelBW(mean, gamma);
}
/**
* Return a positive number distributed according to a relativistic
* Breit-Wigner with a given width, \a gamma, and a given \a
* mean. The distribution is cut-off so that the number is between
* \a mean - \a cut and \a mean + \a cut
*/
template <typename Unit>
static Unit rndRelBW(Unit mean, Unit gamma, Unit cut) {
return current().rndRelBW(mean, gamma, cut);
}
/**
* Return a non-negative number generated according to a Poissonian
* distribution with a given \a mean.
*/
static long rndPoisson(double mean) {
return current().rndPoisson(mean);
}
private:
/**
* The stack of RandomGenerators requested.
*/
static vector<RanGenPtr> theRandomStack;
/**
* True if this object is responsible for pushing a RandomGenerator
* onto the stack.
*/
bool randomPushed;
private:
/**
* Private and non-existent assignment operator.
*/
UseRandom & operator=(const UseRandom &);
};
}
#endif /* ThePEG_UseRandom_H */
|