00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef HepRandom_h
00042 #define HepRandom_h 1
00043
00044 #include <vector>
00045
00046 #include "RandomEngine.h"
00047
00048 class HepRandom {
00049
00050 public:
00051
00052 HepRandom();
00053 HepRandom(long seed);
00054
00055
00056
00057 HepRandom(HepRandomEngine & algorithm);
00058 HepRandom(HepRandomEngine * algorithm);
00059
00060
00061
00062
00063 virtual ~HepRandom();
00064
00065
00066 inline HepDouble flat();
00067
00068
00069 inline HepDouble flat (HepRandomEngine* theNewEngine);
00070
00071
00072 inline void flatArray(const HepInt size, HepDouble* vect);
00073
00074 #ifndef ST_NO_TEMPLATE_DEF_ARGS
00075 void flatArray(vector<HepDouble>&);
00076 #else
00077 void flatArray(vector<HepDouble, allocator<HepDouble> >&);
00078 #endif
00079
00080
00081 inline void flatArray(HepRandomEngine* theNewEngine,
00082 const HepInt size, HepDouble* vect);
00083 #ifndef ST_NO_TEMPLATE_DEF_ARGS
00084 inline void flatArray(HepRandomEngine* theNewEngine,
00085 vector<HepDouble>& vec);
00086 #else
00087 inline void flatArray(HepRandomEngine* theNewEngine,
00088 vector<HepDouble, allocator<HepDouble> >& vec);
00089 #endif
00090
00091
00092
00093 virtual HepDouble operator()();
00094
00095
00096
00097
00098
00099
00100 static void setTheSeed(long seed, HepInt lux=3);
00101
00102
00103 static long getTheSeed();
00104
00105
00106 static void setTheSeeds(const long* seeds, HepInt aux=-1);
00107
00108
00109 static const long* getTheSeeds();
00110
00111
00112 static void getTheTableSeeds (long* seeds, HepInt index);
00113
00114
00115 static HepRandom * getTheGenerator() { return theGenerator; }
00116
00117
00118 static void setTheEngine (HepRandomEngine* theNewEngine);
00119
00120
00121 static HepRandomEngine * getTheEngine();
00122
00123
00124 static void saveEngineStatus();
00125
00126
00127 static void restoreEngineStatus();
00128
00129
00130 static void showEngineStatus();
00131
00132
00133
00134
00135
00136
00137 void setFlag( HepBoolean val ){set = val;}
00138
00139 HepBoolean getFlag() {return set;}
00140
00141 void setVal( HepDouble nextVal ){nextGauss = nextVal;}
00142
00143 HepDouble getVal() {return nextGauss;}
00144
00145
00146
00147
00148
00149 void setOldMean( HepDouble val ){oldm = val;}
00150
00151 HepDouble getOldMean() {return oldm;}
00152
00153 HepDouble getMaxMean() {return meanMax;}
00154
00155 void setPStatus(HepDouble sq, HepDouble alxm, HepDouble g) {
00156 status[0] = sq; status[1] = alxm; status[2] = g;
00157 }
00158
00159 HepDouble* getPStatus() {return status;}
00160
00161 private:
00162
00163 inline void setSeed(long seed, HepInt lux);
00164
00165
00166 inline long getSeed() const;
00167
00168
00169 inline void setSeeds(const long* seeds, HepInt aux);
00170
00171
00172 inline const long* getSeeds () const;
00173
00174
00175 inline void getTableSeeds (long* seeds, HepInt index) const;
00176
00177
00178 void setEngine (HepRandomEngine* engine) { theEngine = engine; }
00179
00180
00181 HepRandomEngine * getEngine() const { return theEngine; }
00182
00183
00184 void saveStatus() const;
00185
00186
00187 void restoreStatus();
00188
00189
00190 void showStatus() const;
00191
00192
00193 protected:
00194
00195 HepRandomEngine * theEngine;
00196
00197
00198 HepBoolean deleteEngine;
00199
00200
00201 HepBoolean set;
00202
00203 HepDouble status[3], oldm;
00204 HepDouble nextGauss;
00205
00206
00207 const HepDouble meanMax;
00208
00209
00210 private:
00211
00212 static HepRandom * theGenerator;
00213
00214 };
00215
00216 inline void HepRandom::setSeed(long seed, HepInt lux) {
00217 theEngine->setSeed(seed,lux);
00218 }
00219
00220 inline void HepRandom::setSeeds(const long* seeds, HepInt aux) {
00221 theEngine->setSeeds(seeds,aux);
00222 }
00223
00224 inline long HepRandom::getSeed() const {
00225 return theEngine->getSeed();
00226 }
00227
00228 inline const long* HepRandom::getSeeds() const {
00229 return theEngine->getSeeds();
00230 }
00231
00232 inline void HepRandom::getTableSeeds(long* seeds, HepInt index) const {
00233 theEngine->getTableSeeds(seeds,index);
00234 }
00235
00236 inline void HepRandom::saveStatus() const {
00237 theEngine->saveStatus();
00238 }
00239
00240 inline void HepRandom::restoreStatus() {
00241 theEngine->restoreStatus();
00242 }
00243
00244 inline void HepRandom::showStatus() const {
00245 theEngine->showStatus();
00246 }
00247
00248 inline HepDouble HepRandom::flat() {
00249 return theEngine->flat();
00250 }
00251
00252 inline void HepRandom::flatArray(const HepInt size, HepDouble* vect) {
00253 theEngine->flatArray(size,vect);
00254 }
00255
00256 #ifdef ST_NO_TEMPLATE_DEF_ARGS
00257 inline void HepRandom::flatArray(vector<HepDouble, allocator<HepDouble> >& vec)
00258 #else
00259 inline void HepRandom::flatArray(vector<HepDouble>& vec)
00260 #endif
00261 {
00262 theEngine->flatArray(vec);
00263 }
00264
00265 inline HepDouble HepRandom::flat(HepRandomEngine* theNewEngine)
00266 {
00267 return theNewEngine->flat();
00268 }
00269
00270 inline void HepRandom::flatArray(HepRandomEngine* theNewEngine,
00271 const HepInt size, HepDouble* vect)
00272 {
00273 theNewEngine->flatArray(size,vect);
00274 }
00275
00276 #ifdef ST_NO_TEMPLATE_DEF_ARGS
00277 inline void HepRandom::flatArray(HepRandomEngine* theNewEngine,
00278 vector<HepDouble, allocator<HepDouble> >& vec)
00279 #else
00280 inline void HepRandom::flatArray(HepRandomEngine* theNewEngine,
00281 vector<HepDouble>& vec)
00282 #endif
00283 {
00284 theNewEngine->flatArray(vec);
00285 }
00286
00287 #endif