Geant4 Cross Reference |
1 // -*- C++ -*- 1 2 // 3 // ------------------------------------------- 4 // HEP Random 5 // --- RanshiEngine --- 6 // class header file 7 // ------------------------------------------- 8 // 9 // 10 // The algorithm for this random engine was ta 11 // Phys. Comm. 87 (1995) 291-306". 12 // 13 // The algorithm can be imagined as a physical 14 // 512 "black balls" each with their own uniqu 15 // acterized by disrete angles, where the spin 16 // A "red ball" collides based upon the angle 17 // of its spin, and the spin of the colliding 18 // random number. The spin of the colliding ba 19 // left circular shift of the black ball's spi 20 // spin. The black ball's old spin becomes the 21 // 22 // To avoid the traps presented, two measures 23 // ball will oscillate between hitting the low 24 // turn and the upper half on another; second, 25 // incremented by a counter of the number of r 26 // 27 // The result is scaled to a double precision 28 // is added another random double further scal 29 // right in order to ensure that the remaining 30 // left empty due to the mere 32 bits represen 31 32 // =========================================== 33 // Ken Smith - Created: 9th June 1998 34 // - Removed pow() from flat me 35 // - Added conversion operators 36 // Mark Fischler Methods put, get for insta 37 // Mark Fischler methods for anonymous save 38 // =========================================== 39 40 #ifndef HepRanshiEngine_h 41 #define HepRanshiEngine_h 42 43 #include "CLHEP/Random/RandomEngine.h" 44 45 namespace CLHEP { 46 47 /** 48 * @author 49 * @ingroup random 50 */ 51 class RanshiEngine: public HepRandomEngine { 52 53 public: 54 55 RanshiEngine(); 56 RanshiEngine(std::istream &is); 57 RanshiEngine(long seed); 58 RanshiEngine(int rowIndex, int colIndex); 59 virtual ~RanshiEngine(); 60 // Constructors and destructor 61 62 double flat(); 63 // Returns a pseudo random number between 64 65 void flatArray(const int size, double* vec 66 // Fills the array "vect" of specified siz 67 68 void setSeed(long seed, int); 69 // Sets the state of the algorithm accordi 70 71 void setSeeds(const long* seeds, int); 72 // Sets the state of the algorithm accordi 73 // array of seeds. 74 75 void saveStatus(const char filename[] = "R 76 // Saves on named file the current engine 77 78 void restoreStatus(const char filename[] = 79 // Reads from named file the last saved en 80 // and restores it. 81 82 void showStatus() const; 83 // Dumps the engine status on the screen 84 85 operator double(); // Returns same a 86 operator float(); // flat value, wi 87 operator unsigned int(); // 32-bit flat va 88 89 virtual std::ostream & put (std::ostream & 90 virtual std::istream & get (std::istream & 91 static std::string beginTag ( ); 92 virtual std::istream & getState ( std::ist 93 94 std::string name() const; 95 static std::string engineName() {return "R 96 97 std::vector<unsigned long> put () const; 98 bool get (const std::vector<unsigned long> 99 bool getState (const std::vector<unsigned 100 101 private: 102 enum {numBuff = 512}; 103 104 unsigned int halfBuff, numFlats; 105 unsigned int buffer[numBuff]; 106 unsigned int redSpin; 107 108 static const unsigned int VECTOR_STATE_SIZ 109 110 }; // RanshiEngine 111 112 } // namespace CLHEP 113 114 #endif // HepRanshiEngine_h 115