00001 // $Id: NonRandomEngine.h,v 1.6 2002/04/12 15:02:44 evc Exp $ 00002 // -*- C++ -*- 00003 // 00004 // ----------------------------------------------------------------------- 00005 // HEP Random 00006 // --- NonRandomEngine --- 00007 // class header file 00008 // ----------------------------------------------------------------------- 00009 00010 // This class is present EXCLUSIVELY as a means to test distributions (and 00011 // other programs that depend on random numbers) by feeding them a stream 00012 // of "randoms" that the testing program supplies explicitly. 00013 // 00014 // The testing program calls setNextRandom (double) to setup the next 00015 // value to be produced when flat() is done. 00016 // 00017 // To protect against accidental use of this NON-RANDOM engine as a random 00018 // engine, if setNextRandom () is never called, all attempts to generate 00019 // a random will fail and exit. 00020 00021 // ======================================================================= 00022 // Mark Fischler - Created: 9/30/99 00023 // ======================================================================= 00024 00025 #ifndef NonRandomEngine_h 00026 #define NonRandomEngine_h 1 00027 00028 #include "CLHEP/Random/RandomEngine.h" 00029 00034 class NonRandomEngine : public HepRandomEngine { 00035 00036 public: 00037 00038 NonRandomEngine(); 00039 virtual ~NonRandomEngine(); 00040 // Constructors and destructor 00041 00042 void setNextRandom (double r); 00043 // Preset the next random to be delivered 00044 void setRandomSequence (double *s, int n); 00045 // Establish a sequence of n next randoms; 00046 // replaces setNextRandom n times. 00047 void setRandomInterval (double x); 00048 // Establish that if there is no sequence active each 00049 // random should be bumped by this interval (mod 1) compared 00050 // to the last. x should be between 0 and 1. 00051 00052 double flat(); 00053 // It returns the previously established setNextRandom and bumps that up 00054 // by the non-zero randomInterval supplied. Thus repeated calls to flat() 00055 // generate an evenly spaced sequence (mod 1). 00056 00057 void flatArray (const int size, double* vect); 00058 // Fills the array "vect" of specified size with flat random values. 00059 00060 private: 00061 00062 bool nextHasBeenSet; 00063 bool sequenceHasBeenSet; 00064 bool intervalHasBeenSet; 00065 double nextRandom; 00066 double *sequence; 00067 int nSequence; 00068 double randomInterval; 00069 00070 // The following are necessary to fill virtual methods but should never 00071 // be used: 00072 00073 virtual void setSeed(long seed, int) {}; 00074 virtual void setSeeds(const long * seeds, int) {}; 00075 virtual void saveStatus( const char filename[] = "Config.conf") const {}; 00076 virtual void restoreStatus( const char filename[] = "Config.conf" ) {}; 00077 virtual void showStatus() const {}; 00078 00079 }; 00080 00081 #endif