Geant4 Cross Reference |
>> 1 // $Id:$ 1 // -*- C++ -*- 2 // -*- C++ -*- 2 // 3 // 3 // ------------------------------------------- 4 // ----------------------------------------------------------------------- 4 // HEP Random 5 // HEP Random 5 // --- NonRandomEngine 6 // --- NonRandomEngine --- 6 // class header file 7 // class header file 7 // ------------------------------------------- 8 // ----------------------------------------------------------------------- 8 9 9 // This class is present EXCLUSIVELY as a mean 10 // This class is present EXCLUSIVELY as a means to test distributions (and 10 // other programs that depend on random number 11 // other programs that depend on random numbers) by feeding them a stream 11 // of "randoms" that the testing program suppl 12 // of "randoms" that the testing program supplies explicitly. 12 // 13 // 13 // The testing program calls setNextRandom (do 14 // The testing program calls setNextRandom (double) to setup the next 14 // value to be produced when flat() is done. 15 // value to be produced when flat() is done. 15 // 16 // 16 // To protect against accidental use of this N 17 // To protect against accidental use of this NON-RANDOM engine as a random 17 // engine, if setNextRandom () is never called 18 // engine, if setNextRandom () is never called, all attempts to generate 18 // a random will fail and exit. 19 // a random will fail and exit. 19 20 20 // =========================================== 21 // ======================================================================= 21 // Mark Fischler - Created: 9/30/99 22 // Mark Fischler - Created: 9/30/99 22 // Mark Fischler methods for distrib. insta 23 // Mark Fischler methods for distrib. instance save/restore 12/8/04 23 // Mark Fischler methods for anonymous save 24 // Mark Fischler methods for anonymous save/restore 12/27/04 24 // =========================================== 25 // ======================================================================= 25 26 26 #ifndef NonRandomEngine_h 27 #ifndef NonRandomEngine_h 27 #define NonRandomEngine_h 1 28 #define NonRandomEngine_h 1 28 29 29 #include "CLHEP/Random/RandomEngine.h" 30 #include "CLHEP/Random/RandomEngine.h" 30 #include <vector> 31 #include <vector> 31 32 32 namespace CLHEP { 33 namespace CLHEP { 33 34 34 /** 35 /** 35 * @author 36 * @author 36 * @ingroup random 37 * @ingroup random 37 */ 38 */ 38 class NonRandomEngine : public HepRandomEngine 39 class NonRandomEngine : public HepRandomEngine { 39 40 40 public: 41 public: 41 42 42 NonRandomEngine(); 43 NonRandomEngine(); 43 virtual ~NonRandomEngine(); 44 virtual ~NonRandomEngine(); 44 // Constructors and destructor 45 // Constructors and destructor 45 46 46 void setNextRandom (double r); 47 void setNextRandom (double r); 47 // Preset the next random to be delivered 48 // Preset the next random to be delivered 48 void setRandomSequence (double *s, int n); 49 void setRandomSequence (double *s, int n); 49 // Establish a sequence of n next randoms; 50 // Establish a sequence of n next randoms; 50 // replaces setNextRandom n times. 51 // replaces setNextRandom n times. 51 void setRandomInterval (double x); 52 void setRandomInterval (double x); 52 // Establish that if there is no sequence ac 53 // Establish that if there is no sequence active each 53 // random should be bumped by this interval 54 // random should be bumped by this interval (mod 1) compared 54 // to the last. x should be between 0 and 1 55 // to the last. x should be between 0 and 1. 55 56 56 double flat(); 57 double flat(); 57 // It returns the previously established set 58 // It returns the previously established setNextRandom and bumps that up 58 // by the non-zero randomInterval supplied. 59 // by the non-zero randomInterval supplied. Thus repeated calls to flat() 59 // generate an evenly spaced sequence (mod 1 60 // generate an evenly spaced sequence (mod 1). 60 61 61 void flatArray (const int size, double* vect 62 void flatArray (const int size, double* vect); 62 // Fills the array "vect" of specified size 63 // Fills the array "vect" of specified size with flat random values. 63 64 64 virtual std::ostream & put (std::ostream & o 65 virtual std::ostream & put (std::ostream & os) const; 65 virtual std::istream & get (std::istream & i 66 virtual std::istream & get (std::istream & is); 66 static std::string beginTag ( ); 67 static std::string beginTag ( ); 67 virtual std::istream & getState ( std::istre 68 virtual std::istream & getState ( std::istream & is ); 68 69 69 std::string name() const; 70 std::string name() const; 70 static std::string engineName() {return "Non 71 static std::string engineName() {return "NonRandomEngine";} 71 72 72 std::vector<unsigned long> put () const; 73 std::vector<unsigned long> put () const; 73 bool get (const std::vector<unsigned long> & 74 bool get (const std::vector<unsigned long> & v); 74 bool getState (const std::vector<unsigned lo 75 bool getState (const std::vector<unsigned long> & v); 75 76 76 private: 77 private: 77 78 78 bool nextHasBeenSet; 79 bool nextHasBeenSet; 79 bool sequenceHasBeenSet; 80 bool sequenceHasBeenSet; 80 bool intervalHasBeenSet; 81 bool intervalHasBeenSet; 81 double nextRandom; 82 double nextRandom; 82 std::vector<double> sequence; 83 std::vector<double> sequence; 83 unsigned int nInSeq; 84 unsigned int nInSeq; 84 double randomInterval; 85 double randomInterval; 85 86 86 // The following are necessary to fill virtu 87 // The following are necessary to fill virtual methods but should never 87 // be used: 88 // be used: 88 89 89 virtual void setSeed(long , int) {}; 90 virtual void setSeed(long , int) {}; 90 virtual void setSeeds(const long * , int) {} 91 virtual void setSeeds(const long * , int) {}; 91 virtual void saveStatus( const char * ) cons 92 virtual void saveStatus( const char * ) const {}; 92 virtual void restoreStatus( const char * ) { 93 virtual void restoreStatus( const char * ) {}; 93 virtual void showStatus() const {}; 94 virtual void showStatus() const {}; 94 95 95 96 96 }; 97 }; 97 98 98 } // namespace CLHEP 99 } // namespace CLHEP 99 100 100 #endif 101 #endif 101 102