Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NonRandomEngine.h
Go to the documentation of this file.
1 // $Id:$
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 
31 #include <vector>
32 
33 namespace CLHEP {
34 
40 
41 public:
42 
44  virtual ~NonRandomEngine();
45  // Constructors and destructor
46 
47  void setNextRandom (double r);
48  // Preset the next random to be delivered
49  void setRandomSequence (double *s, int n);
50  // Establish a sequence of n next randoms;
51  // replaces setNextRandom n times.
52  void setRandomInterval (double x);
53  // Establish that if there is no sequence active each
54  // random should be bumped by this interval (mod 1) compared
55  // to the last. x should be between 0 and 1.
56 
57  double flat();
58  // It returns the previously established setNextRandom and bumps that up
59  // by the non-zero randomInterval supplied. Thus repeated calls to flat()
60  // generate an evenly spaced sequence (mod 1).
61 
62  void flatArray (const int size, double* vect);
63  // Fills the array "vect" of specified size with flat random values.
64 
65  virtual std::ostream & put (std::ostream & os) const;
66  virtual std::istream & get (std::istream & is);
67  static std::string beginTag ( );
68  virtual std::istream & getState ( std::istream & is );
69 
70  std::string name() const;
71  static std::string engineName() {return "NonRandomEngine";}
72 
73  std::vector<unsigned long> put () const;
74  bool get (const std::vector<unsigned long> & v);
75  bool getState (const std::vector<unsigned long> & v);
76 
77 private:
78 
79  bool nextHasBeenSet;
80  bool sequenceHasBeenSet;
81  bool intervalHasBeenSet;
82  double nextRandom;
83  std::vector<double> sequence;
84  unsigned int nInSeq;
85  double randomInterval;
86 
87  // The following are necessary to fill virtual methods but should never
88  // be used:
89 
90  virtual void setSeed(long , int) {};
91  virtual void setSeeds(const long * , int) {};
92  virtual void saveStatus( const char * ) const {};
93  virtual void restoreStatus( const char * ) {};
94  virtual void showStatus() const {};
95 
96 
97 };
98 
99 } // namespace CLHEP
100 
101 #endif
std::string name() const
void setNextRandom(double r)
tuple x
Definition: test.py:50
virtual std::istream & getState(std::istream &is)
void flatArray(const int size, double *vect)
const XML_Char * s
Definition: expat.h:262
static std::string beginTag()
void setRandomInterval(double x)
void setRandomSequence(double *s, int n)
const G4int n
tuple v
Definition: test.py:18
static std::string engineName()
std::vector< unsigned long > put() const