ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id: RooRandom.cxx 24285 2008-06-16 15:05:15Z wouter $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
//
// BEGIN_HTML
// This class provides a static interface for generating random numbers.
// By default a private copy of TRandom3 is used to generate all random numbers.
// END_HTML
//

#include "RooFit.h"

#include "RooRandom.h"
#include "RooRandom.h"
#include "RooQuasiRandomGenerator.h"

#include "TRandom3.h"

#include <assert.h>

ClassImp(RooRandom)
  ;



//_____________________________________________________________________________
TRandom *RooRandom::randomGenerator() 
{
  // Return a pointer to a singleton random-number generator
  // implementation. Creates the object the first time it is called.
  
  static TRandom *_theGenerator= 0;
  if(0 == _theGenerator) _theGenerator= new TRandom3();
  return _theGenerator;
}


//_____________________________________________________________________________
RooQuasiRandomGenerator *RooRandom::quasiGenerator() 
{
  // Return a pointer to a singleton quasi-random generator
  // implementation. Creates the object the first time it is called.
  
  static RooQuasiRandomGenerator *_theGenerator= 0;
  if(0 == _theGenerator) _theGenerator= new RooQuasiRandomGenerator();
  return _theGenerator;
}


//_____________________________________________________________________________
Double_t RooRandom::uniform(TRandom *generator) 
{
  // Return a number uniformly distributed from (0,1)

  return generator->Rndm();
}


//_____________________________________________________________________________
void RooRandom::uniform(UInt_t dimension, Double_t vector[], TRandom *generator) 
{
  // Fill the vector provided with random numbers uniformly distributed from (0,1)
  
  for(UInt_t index= 0; index < dimension; index++) vector[index]= uniform(generator);
}


//_____________________________________________________________________________
UInt_t RooRandom::integer(UInt_t n, TRandom *generator) 
{
  // Return an integer uniformly distributed from [0,n-1]

  return generator->Integer(n);
}


//_____________________________________________________________________________
Double_t RooRandom::gaussian(TRandom *generator) 
{
  // Return a Gaussian random variable with mean 0 and variance 1.

  return generator->Gaus();
}


//_____________________________________________________________________________
Bool_t RooRandom::quasi(UInt_t dimension, Double_t vector[], RooQuasiRandomGenerator *generator) 
{
  // Return a quasi-random number in the range (0,1) using the
  // Niederreiter base 2 generator described in Bratley, Fox, Niederreiter,
  // ACM Trans. Model. Comp. Sim. 2, 195 (1992).

  return generator->generate(dimension,vector);
}
 RooRandom.cxx:1
 RooRandom.cxx:2
 RooRandom.cxx:3
 RooRandom.cxx:4
 RooRandom.cxx:5
 RooRandom.cxx:6
 RooRandom.cxx:7
 RooRandom.cxx:8
 RooRandom.cxx:9
 RooRandom.cxx:10
 RooRandom.cxx:11
 RooRandom.cxx:12
 RooRandom.cxx:13
 RooRandom.cxx:14
 RooRandom.cxx:15
 RooRandom.cxx:16
 RooRandom.cxx:17
 RooRandom.cxx:18
 RooRandom.cxx:19
 RooRandom.cxx:20
 RooRandom.cxx:21
 RooRandom.cxx:22
 RooRandom.cxx:23
 RooRandom.cxx:24
 RooRandom.cxx:25
 RooRandom.cxx:26
 RooRandom.cxx:27
 RooRandom.cxx:28
 RooRandom.cxx:29
 RooRandom.cxx:30
 RooRandom.cxx:31
 RooRandom.cxx:32
 RooRandom.cxx:33
 RooRandom.cxx:34
 RooRandom.cxx:35
 RooRandom.cxx:36
 RooRandom.cxx:37
 RooRandom.cxx:38
 RooRandom.cxx:39
 RooRandom.cxx:40
 RooRandom.cxx:41
 RooRandom.cxx:42
 RooRandom.cxx:43
 RooRandom.cxx:44
 RooRandom.cxx:45
 RooRandom.cxx:46
 RooRandom.cxx:47
 RooRandom.cxx:48
 RooRandom.cxx:49
 RooRandom.cxx:50
 RooRandom.cxx:51
 RooRandom.cxx:52
 RooRandom.cxx:53
 RooRandom.cxx:54
 RooRandom.cxx:55
 RooRandom.cxx:56
 RooRandom.cxx:57
 RooRandom.cxx:58
 RooRandom.cxx:59
 RooRandom.cxx:60
 RooRandom.cxx:61
 RooRandom.cxx:62
 RooRandom.cxx:63
 RooRandom.cxx:64
 RooRandom.cxx:65
 RooRandom.cxx:66
 RooRandom.cxx:67
 RooRandom.cxx:68
 RooRandom.cxx:69
 RooRandom.cxx:70
 RooRandom.cxx:71
 RooRandom.cxx:72
 RooRandom.cxx:73
 RooRandom.cxx:74
 RooRandom.cxx:75
 RooRandom.cxx:76
 RooRandom.cxx:77
 RooRandom.cxx:78
 RooRandom.cxx:79
 RooRandom.cxx:80
 RooRandom.cxx:81
 RooRandom.cxx:82
 RooRandom.cxx:83
 RooRandom.cxx:84
 RooRandom.cxx:85
 RooRandom.cxx:86
 RooRandom.cxx:87
 RooRandom.cxx:88
 RooRandom.cxx:89
 RooRandom.cxx:90
 RooRandom.cxx:91
 RooRandom.cxx:92
 RooRandom.cxx:93
 RooRandom.cxx:94
 RooRandom.cxx:95
 RooRandom.cxx:96
 RooRandom.cxx:97
 RooRandom.cxx:98
 RooRandom.cxx:99
 RooRandom.cxx:100
 RooRandom.cxx:101
 RooRandom.cxx:102
 RooRandom.cxx:103
 RooRandom.cxx:104
 RooRandom.cxx:105
 RooRandom.cxx:106
 RooRandom.cxx:107
 RooRandom.cxx:108