CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

NonRandomEngine.h

Go to the documentation of this file.
00001 // $Id: NonRandomEngine.h,v 1.3.4.1 2005/03/18 22:26:48 garren 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 // Mark Fischler    methods for distrib. instance save/restore 12/8/04    
00024 // Mark Fischler    methods for anonymous save/restore 12/27/04    
00025 // =======================================================================
00026 
00027 #ifndef NonRandomEngine_h
00028 #define NonRandomEngine_h 1
00029 
00030 #include "CLHEP/Random/defs.h"
00031 #include "CLHEP/Random/RandomEngine.h"
00032 #include <vector>
00033 
00034 namespace CLHEP {
00035 
00040 class NonRandomEngine : public HepRandomEngine {
00041 
00042 public:
00043 
00044   NonRandomEngine();
00045   virtual ~NonRandomEngine();
00046   // Constructors and destructor
00047 
00048   void setNextRandom     (double r);
00049         // Preset the next random to be delivered
00050   void setRandomSequence (double *s, int n);
00051         // Establish a sequence of n next randoms; 
00052         // replaces setNextRandom n times.
00053   void setRandomInterval (double x);
00054         // Establish that if there is no sequence active each 
00055         // random should be bumped by this interval (mod 1) compared 
00056         // to the last.  x should be between 0 and 1.
00057 
00058   double flat();
00059   // It returns the previously established setNextRandom and bumps that up
00060   // by the non-zero randomInterval supplied.  Thus repeated calls to flat()
00061   // generate an evenly spaced sequence (mod 1).
00062 
00063   void flatArray (const int size, double* vect);
00064   // Fills the array "vect" of specified size with flat random values.
00065 
00066   virtual std::ostream & put (std::ostream & os) const;
00067   virtual std::istream & get (std::istream & is);
00068   static  std::string beginTag ( );
00069   virtual std::istream & getState ( std::istream & is );
00070 
00071   std::string name() const;
00072   static std::string engineName() {return "NonRandomEngine";}
00073 
00074   std::vector<unsigned long> put () const;
00075   bool get (const std::vector<unsigned long> & v);
00076   bool getState (const std::vector<unsigned long> & v);
00077   
00078 private:
00079 
00080   bool nextHasBeenSet;
00081   bool sequenceHasBeenSet;
00082   bool intervalHasBeenSet;
00083   double  nextRandom;
00084   std::vector<double> sequence;
00085   unsigned int nInSeq;
00086   double  randomInterval;
00087 
00088   // The following are necessary to fill virtual methods but should never 
00089   // be used:
00090 
00091   virtual void setSeed(long seed, int) {};
00092   virtual void setSeeds(const long * seeds, int) {};
00093   virtual void saveStatus( const char filename[] = "Config.conf") const {};
00094   virtual void restoreStatus( const char filename[] = "Config.conf" ) {};
00095   virtual void showStatus() const {};
00096 
00097  
00098 };
00099 
00100 }  // namespace CLHEP
00101 
00102 #endif

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7