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