ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
math
mathcore
inc
Math
TRandomEngine.h
Go to the documentation of this file.
1
// @(#)root/mathcore:$Id$
2
// Author: L. Moneta Tue Aug 4 2015
3
4
/**********************************************************************
5
* *
6
* Copyright (c) 2015 LCG ROOT Math Team, CERN/PH-SFT *
7
* *
8
* *
9
**********************************************************************/
10
11
// random engines based on ROOT
12
13
#ifndef ROOT_Math_TRandomEngine
14
#define ROOT_Math_TRandomEngine
15
16
17
18
namespace
ROOT {
19
20
namespace
Math {
21
22
class
RandomBaseEngine
{
23
public
:
24
virtual
double
Rndm
() = 0;
25
virtual
~RandomBaseEngine
() {}
26
};
27
28
29
class
TRandomEngine
:
public
RandomBaseEngine
{
30
public
:
31
virtual
~TRandomEngine
() {}
32
};
33
34
class
LCGEngine
:
public
TRandomEngine
{
35
36
37
public
:
38
39
typedef
TRandomEngine
BaseType
;
40
41
LCGEngine
() :
fSeed
(65539) { }
42
43
virtual
~LCGEngine
() {}
44
45
void
SetSeed
(
unsigned
int
seed) {
fSeed
= seed; }
46
47
virtual
double
Rndm
() {
48
//double Rndm() {
49
return
Rndm_impl
();
50
}
51
double
Rndm_impl
() {
52
const
double
kCONS = 4.6566128730774E-10;
// (1/pow(2,31)
53
unsigned
int
rndm
=
IntRndm
();
// generate integer number
54
if
(rndm != 0)
return
kCONS*
rndm
;
55
return
Rndm_impl
();
56
}
57
inline
double
operator()
() {
return
Rndm_impl
(); }
58
59
unsigned
int
IntRndm
() {
60
fSeed
= (1103515245 *
fSeed
+ 12345) & 0x7fffffffUL;
61
return
fSeed
;
62
}
63
64
private
:
65
unsigned
int
fSeed
;
66
};
67
68
69
}
// end namespace Math
70
71
}
// end namespace ROOT
72
73
74
#endif
/* ROOT_Math_TRandomEngine */
ROOT::Math::LCGEngine::IntRndm
unsigned int IntRndm()
Definition:
TRandomEngine.h:59
ROOT::Math::LCGEngine
Definition:
TRandomEngine.h:34
ROOT::Math::LCGEngine::fSeed
unsigned int fSeed
Definition:
TRandomEngine.h:65
ROOT::Math::LCGEngine::~LCGEngine
virtual ~LCGEngine()
Definition:
TRandomEngine.h:43
ROOT::Math::LCGEngine::Rndm
virtual double Rndm()
Definition:
TRandomEngine.h:47
ROOT::Math::LCGEngine::SetSeed
void SetSeed(unsigned int seed)
Definition:
TRandomEngine.h:45
ROOT::Math::TRandomEngine::~TRandomEngine
virtual ~TRandomEngine()
Definition:
TRandomEngine.h:31
ROOT::Math::RandomBaseEngine
Definition:
TRandomEngine.h:22
ROOT::Math::LCGEngine::BaseType
TRandomEngine BaseType
Definition:
TRandomEngine.h:39
ROOT::Math::TRandomEngine
Definition:
TRandomEngine.h:29
ROOT::Math::LCGEngine::operator()
double operator()()
Definition:
TRandomEngine.h:57
ROOT::Math::RandomBaseEngine::~RandomBaseEngine
virtual ~RandomBaseEngine()
Definition:
TRandomEngine.h:25
ROOT::Math::LCGEngine::Rndm_impl
double Rndm_impl()
Definition:
TRandomEngine.h:51
rndm
TRandom3 rndm
Definition:
fit2dHist.C:44
ROOT::Math::LCGEngine::LCGEngine
LCGEngine()
Definition:
TRandomEngine.h:41
ROOT::Math::RandomBaseEngine::Rndm
virtual double Rndm()=0