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 #ifndef DualRand_h
00037 #define DualRand_h
00038
00039 #include "CLHEP/Random/RandomEngine.h"
00040
00045 class DualRand: public HepRandomEngine {
00046
00047 public:
00048
00049 DualRand();
00050 DualRand(long seed);
00051 DualRand(HepStd::istream & is);
00052 DualRand(int rowIndex, int colIndex);
00053 virtual ~DualRand();
00054
00055 DualRand(const DualRand & p);
00056 DualRand & operator=(const DualRand & p);
00057
00058 double flat();
00059
00060
00061
00062 void flatArray(const int size, double * vect);
00063
00064
00065 void setSeed(long seed, int);
00066
00067
00068 void setSeeds(const long * seeds, int);
00069
00070
00071
00072 void saveStatus( const char filename[] = "DualRand.conf") const;
00073
00074
00075 void restoreStatus( const char filename[] = "DualRand.conf" );
00076
00077
00078 void showStatus() const;
00079
00080
00081 operator float();
00082 operator unsigned int();
00083
00084 friend HepStd::ostream & operator<< (HepStd::ostream & os, const DualRand & e);
00085 friend HepStd::istream & operator>> (HepStd::istream & is, DualRand & e);
00086
00087 private:
00088
00089 static int numEngines;
00090
00091 static double twoToMinus_32;
00092 static double twoToMinus_53;
00093 static double nearlyTwoToMinus_54;
00094 void powersOfTwo();
00095
00096
00097
00098 class Tausworthe {
00099 public:
00100 Tausworthe();
00101 Tausworthe(unsigned int seed);
00102 operator unsigned int();
00103 void put(HepStd::ostream & os) const;
00104 void get(HepStd::istream & is);
00105 private:
00106 int wordIndex;
00107 unsigned int words[4];
00108 };
00109
00110 class IntegerCong {
00111 public:
00112 IntegerCong();
00113 IntegerCong(unsigned int seed, int streamNumber);
00114 operator unsigned int();
00115 void put(HepStd::ostream & os) const;
00116 void get(HepStd::istream & is);
00117 private:
00118 unsigned int state, multiplier, addend;
00119 };
00120
00121 Tausworthe tausworthe;
00122 IntegerCong integerCong;
00123
00124 };
00125
00126 #endif // DualRand_h