Geant4 Cross Reference |
1 // -*- C++ -*- 1 2 // 3 // ------------------------------------------- 4 // HEP Random 5 // --- Ranlux64Engine - 6 // class header file 7 // ------------------------------------------- 8 // The algorithm for this random engine has be 9 // a double-precision ranlux implementation by 10 // November 1997. 11 // 12 // Like the previous ranlux generator, this on 13 // determining how many pseudo-random numbers 14 // twelve values used. Three levels are given, 15 // himself advocates only the highest two leve 16 // level 0 (p=109): Throw away 17 // level 1 (p=202): (default) Throw away 18 // level 2 (p=397): Throw away 19 // 20 // The initialization is carried out using a M 21 // generator using formula constants of L'Ecuy 22 // Comp. Phys. Comm. 60 (1990) 329-344". 23 // =========================================== 24 // Ken Smith - Created Initial draft: 14t 25 // - Added conversion operators 26 // Mark Fischler 27 // 9/9/98 - Added update() routine to allow 28 // - Replaced algorithm with jone exactly 29 // 48-bits generated 30 // skip n-12 instead of n numbers 31 // - Corrected protection agains overflow 32 // 12/8/04 - Methods for instance save/ 33 // 12/27/04 - methods for anonymous save 34 // 35 // =========================================== 36 37 #ifndef Ranlux64Engine_h 38 #define Ranlux64Engine_h 39 40 #include "CLHEP/Random/RandomEngine.h" 41 42 namespace CLHEP { 43 44 /** 45 * @author 46 * @ingroup random 47 */ 48 class Ranlux64Engine : public HepRandomEngine 49 50 public: 51 52 Ranlux64Engine( std::istream& is ); 53 Ranlux64Engine(); 54 Ranlux64Engine( long seed, int lxr = 1 ); 55 Ranlux64Engine( int rowIndex, int colIndex, 56 virtual ~Ranlux64Engine(); 57 // Constructors and destructor 58 59 double flat(); 60 // It returns a pseudo random number between 61 // excluding the end points. 62 63 void flatArray (const int size, double* vect 64 // Fills the array "vect" of specified size 65 66 void setSeed(long seed, int lxr=1); 67 // Sets the state of the algorithm according 68 69 void setSeeds(const long * seeds, int lxr=1) 70 // Sets the state of the algorithm according 71 // array of seeds. Only the first seed is u 72 73 void saveStatus( const char filename[] = "Ra 74 // Saves in named file the current engine st 75 76 void restoreStatus( const char filename[] = 77 // Reads from named file the last saved engi 78 79 void showStatus() const; 80 // Dumps the engine status on the screen. 81 82 int getLuxury() const { return luxury; } 83 // Gets the luxury level. 84 85 virtual std::ostream & put (std::ostream & o 86 virtual std::istream & get (std::istream & i 87 static std::string beginTag ( ); 88 virtual std::istream & getState ( std::istre 89 90 std::string name() const; 91 static std::string engineName() {return "Ran 92 93 std::vector<unsigned long> put () const; 94 bool get (const std::vector<unsigned long> & 95 bool getState (const std::vector<unsigned lo 96 97 static const unsigned int VECTOR_STATE_SIZE 98 99 private: 100 101 void update(); 102 void advance(int dozens); 103 104 int pDiscard; // separate sequence by p- 105 int pDozens; // pDiscard / 12; 106 int endIters; // pDiscard % 12; 107 int luxury; 108 109 int index; 110 double randoms[12]; // randoms [i] is the x[ 111 double carry; 112 113 }; // Ranlux64Engine 114 115 } // namespace CLHEP 116 117 #endif // Ranlux64Engine_h 118