StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Random.cc
1 /***************************************************************************
2  *
3  * $Id: Random.cc,v 1.1 1999/01/30 03:59:00 fisyak Exp $
4  *
5  * Author: Gabriele Cosmo - Created: 5th September 1995
6  * modified for SCL bl
7  ***************************************************************************
8  *
9  * Description:
10  * Random.cc,v 1.15 1997/08/12 00:38:47
11  * -----------------------------------------------------------------------
12  * HEP Random
13  * --- HepRandom ---
14  * class implementation file
15  * -----------------------------------------------------------------------
16  * This file is part of Geant4 (simulation toolkit for HEP).
17  *
18  ***************************************************************************
19  *
20  * $Log: Random.cc,v $
21  * Revision 1.1 1999/01/30 03:59:00 fisyak
22  * Root Version of StarClassLibrary
23  *
24  * Revision 1.1 1999/01/23 00:29:10 ullrich
25  * Initial Revision
26  *
27  **************************************************************************/
28 #include "JamesRandom.h"
29 #include "Random.h"
30 
31 // -----------------------------
32 // Static members initialisation
33 // -----------------------------
34 
35 HepJamesRandom theMainEngine;
36 HepRandom aGenerator(theMainEngine);
37 HepRandom* HepRandom::theGenerator = &aGenerator;
38 
39 //---------------------------- HepRandom ---------------------------------
40 
41 HepRandom::HepRandom()
42 : theEngine(new HepJamesRandom), deleteEngine(true),
43  set(false), oldm(-1.0), nextGauss(0.0), meanMax(2.0E9) {
44  for (HepInt i=0; i<3; ++i)
45  status[i] = 0.;
46 }
47 
48 HepRandom::HepRandom(long seed)
49 : theEngine(new HepJamesRandom(seed)), deleteEngine(true),
50  set(false), oldm(-1.0), nextGauss(0.0), meanMax(2.0E9) {
51  for (HepInt i=0; i<3; ++i)
52  status[i] = 0.;
53 }
54 
55 HepRandom::HepRandom(HepRandomEngine & algorithm)
56 : theEngine(&algorithm), deleteEngine(false),
57  set(false), oldm(-1.0), nextGauss(0.0), meanMax(2.0E9) {
58  // called always because it is static
59  for (HepInt i=0; i<3; ++i)
60  status[i] = 0.;
61 }
62 
63 HepRandom::HepRandom(HepRandomEngine * algorithm)
64 : theEngine(algorithm), deleteEngine(true),
65  set(false), oldm(-1.0), nextGauss(0.0), meanMax(2.0E9) {
66  for (HepInt i=0; i<3; ++i)
67  status[i] = 0.;
68 }
69 
70 HepRandom::~HepRandom() {
71  if ( deleteEngine ) delete theEngine;
72 }
73 
74 HepDouble HepRandom::operator()() {
75  return flat();
76 }
77 
78 // --------------------------
79 // Static methods definitions
80 // --------------------------
81 
82 void HepRandom::setTheSeed(long seed, HepInt lux)
83 {
84  theGenerator->setSeed(seed,lux);
85 }
86 
87 long HepRandom::getTheSeed()
88 {
89  return theGenerator->getSeed();
90 }
91 
92 void HepRandom::setTheSeeds(const long* seeds, HepInt aux)
93 {
94  theGenerator->setSeeds(seeds,aux);
95 }
96 
97 const long* HepRandom::getTheSeeds ()
98 {
99  return theGenerator->getSeeds();
100 }
101 
102 void HepRandom::getTheTableSeeds (long* seeds, HepInt index)
103 {
104  theGenerator->getTableSeeds(seeds, index);
105 }
106 
107 void HepRandom::setTheEngine (HepRandomEngine* theNewEngine)
108 {
109  theGenerator->setEngine(theNewEngine);
110 }
111 
112 HepRandomEngine * HepRandom::getTheEngine()
113 {
114  return theGenerator->getEngine();
115 }
116 
117 void HepRandom::saveEngineStatus()
118 {
119  theGenerator->saveStatus();
120 }
121 
122 void HepRandom::restoreEngineStatus()
123 {
124  theGenerator->restoreStatus();
125 }
126 
127 void HepRandom::showEngineStatus()
128 {
129  theGenerator->showStatus();
130 }