Geant4 Cross Reference |
1 // -*- C++ -*- 1 2 // 3 // ------------------------------------------- 4 // HEP Random 5 // --- HepJamesRandom - 6 // class header file 7 // ------------------------------------------- 8 // This file is part of Geant4 (simulation too 9 // 10 // HepJamesRandom implements the algorithm by 11 // described in "F.James, Comp. Phys. Comm. 60 12 // in FORTRAN77 as part of the MATHLIB HEP lib 13 // numbers generation. 14 // This is the default random engine invoked b 15 // the user sets a different one. 16 17 // =========================================== 18 // Gabriele Cosmo - Created: 5th September 199 19 // - Minor corrections: 31st Oc 20 // - Added methods for engine s 21 // - setSeed(), setSeeds() now 22 // set to zero: 11th July 199 23 // J.Marraffino - Added stream operators and 24 // Added automatic seed selec 25 // engine counter: 16th Feb 1 26 // Ken Smith - Added conversion operators 27 // V. Innocente - changed pointers to indice 28 // Mark Fischler - Methods for distrib. insta 29 // Mark Fischler methods for anonymous sav 30 // =========================================== 31 32 #ifndef HepJamesRandom_h 33 #define HepJamesRandom_h 1 34 35 #include "CLHEP/Random/RandomEngine.h" 36 37 namespace CLHEP { 38 39 /** 40 * @author 41 * @ingroup random 42 */ 43 class HepJamesRandom: public HepRandomEngine { 44 45 public: 46 47 HepJamesRandom(std::istream& is); 48 HepJamesRandom(); 49 HepJamesRandom(long seed); 50 HepJamesRandom(int rowIndex, int colIndex); 51 virtual ~HepJamesRandom(); 52 // Constructor and destructor. 53 54 double flat(); 55 // Returns a pseudo random number between 0 56 // (excluding the end points) 57 58 void flatArray (const int size, double* vect 59 // Fills the array "vect" of specified size 60 61 void setSeed(long seed, int dum=0); 62 // Sets the state of the algorithm according 63 64 void setSeeds(const long * seeds, int dum=0) 65 // Sets the state of the algorithm according 66 // array of seeds. Only the first seed is us 67 68 void saveStatus( const char filename[] = "Ja 69 // Saves on file JamesRand.conf the current 70 71 void restoreStatus( const char filename[] = 72 // Reads from file JamesRand.conf the last s 73 // and restores it. 74 75 void showStatus() const; 76 // Dumps the engine status on the screen. 77 78 operator double(); 79 // Returns same as flat() 80 operator float(); 81 // less precise flat, faster if possible 82 operator unsigned int(); 83 // 32-bit flat, but slower than double or fl 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 "Hep 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 // Members defining the current status of th 102 double u[97]; 103 double c, cd, cm; 104 int i97, j97; 105 }; 106 107 } // namespace CLHEP 108 109 #endif 110