17 #include "CLHEP/Random/RandFlat.h"    18 #include "CLHEP/Random/RanluxEngine.h"    19 #include "CLHEP/Random/Ranlux64Engine.h"    25 #define PI       3.14159265358979323846264338328          36 using namespace CLHEP;
    45     fScale = 1./(double(RAND_MAX) + 1.);
    48   inline void RndmArray(
int n, 
double * 
x) {
    49     for ( 
double * itr = x; itr != x+
n; ++itr)
    50       *itr= fScale*
double(std::rand());
    52   inline double Uniform() {
    53     return fScale*double(std::rand());
    56   std::string 
Type()
 const { 
return "std::rand"; }
    57   unsigned int EngineSize()
 const { 
return 0; }
    59   void SetSeed(
int seed) { std::srand(seed); }
    70 template <
class Engine>
    73    RandomCLHEP(Engine & 
e) :
    78   inline void RndmArray(
int n, 
double * 
x) {
    81   inline double Uniform() {
    85    std::string 
Type()
 const { 
return std::string(
"CLHEP ") + Engine::engineName(); }
    86    unsigned int EngineSize()
 const { 
return 0; }
    88   void SetSeed(
int seed) { fRand.setSeed(seed); }
   101   std::cout << 
"\nRandom :\t " << r.Type() << 
" \t size of state = " << r.EngineSize() << std::endl;
   106   std::cout << 
"\nRandom :\t " << r.
ClassName() << std::endl;
   110   std::cout << 
"\nRandom :\t " << r.
ClassName() << std::endl;
   114   std::cout << 
"\nRandom :\t " << r.
ClassName() << std::endl;
   118   std::cout << 
"\nRandom :\t " << r.
ClassName() << std::endl;
   137     for (
int i = 0; i < 
n; i+=1000 ) {
   138       r.RndmArray(1000,ax);
   139       r.RndmArray(1000,ay);
   140       for (
int j = 0; j < 1000; ++j)
   141        if ( ( ax[j]*ax[j] + ay[j]*ay[j] ) <= 1.0 ) n1++;
   145     for (
int i = 0; i < 
n; ++i) {
   148       if ( ( x*x + y*y ) <= 1.0 ) n1++;
   154   std::cout << 
"\tTime = " << w.
RealTime()*1.0E9/
NEVT << 
"  "   156             << 
" (ns/call)" << std::endl;
   157   double piEstimate = 4.0 * double(n1)/double(n);
   158   double delta = piEstimate-
PI;
   160   std::cout << 
"\t\tDeltaPI = " << delta/sigma << 
" (sigma) " << std::endl;
   165   std::cout << 
"***************************************************\n";
   166   std::cout << 
" TEST RANDOM    NEVT = " << 
NEVT << std::endl;
   167   std::cout << 
"***************************************************\n\n";
   225   RanluxEngine             e1(1,3);
   226   RanluxEngine             e2(1,4);
   227   Ranlux64Engine           e3(1,0);
   228   Ranlux64Engine           e4(1,1);
   229   Ranlux64Engine           e5(1,2);
   231   RandomCLHEP<RanluxEngine>  crlx3(e1);
   232   RandomCLHEP<RanluxEngine>  crlx4(e2);
   234   RandomCLHEP<Ranlux64Engine>  crlx64a(e3);
   235   RandomCLHEP<Ranlux64Engine>  crlx64b(e4);
   236   RandomCLHEP<Ranlux64Engine>  crlx64c(e5);
   249   std::vector<double> v1(n);
   250   std::vector<double> v2(n);
   260   for (
int i = 0; i < 
n; ++i) {
   265      std::cout << 
"ERROR: Test failing comparing TRandom3 with GSL MT" << std::endl;
   269   std::ofstream 
file(
"testRandom.out");
   270   std::ostream & out = file;
   272   int prec = std::cout.precision(9);
   274      for (
int l = 0; 
l < 8; ++
l) {
   275         out << std::setw(12) << v1[j+
l] << 
",";
   283   std::cout.precision(prec);
 Random number generator class based on M. 
 
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
 
void generate(R &r, bool array=true)
 
void Start(Bool_t reset=kTRUE)
Start the stopwatch. 
 
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
 
void RndmArray(int n, double *array)
Generate an array of random numbers between ]0,1] 0 is excluded and 1 is included Function to preserv...
 
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
 
virtual const char * ClassName() const
Returns name of class to which the object belongs. 
 
void Stop()
Stop the stopwatch. 
 
The Ranlux Random number generator class. 
 
This is the base class for the ROOT Random number generators. 
 
unsigned int r3[N_CITIES]
 
void printName(const R &r)
 
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
 
unsigned int r1[N_CITIES]
 
Type
enumeration specifying the integration types. 
 
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1]. 
 
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
 
unsigned int r2[N_CITIES]
 
Documentation for the Random class.