CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
NonRandomEngine.h
Go to the documentation of this file.
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
34namespace CLHEP {
35
36/**
37 * @author
38 * @ingroup random
39 */
41
42public:
43
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;
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
78private:
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
91 virtual void setSeed(long , int) {};
92 virtual void setSeeds(const long * , int) {};
93 virtual void saveStatus( const char* ) const {};
94 virtual void restoreStatus( const char* ) {};
95 virtual void showStatus() const {};
96
97
98};
99
100} // namespace CLHEP
101
102#endif
void setRandomSequence(double *s, int n)
std::string name() const
void setNextRandom(double r)
virtual std::istream & getState(std::istream &is)
virtual std::istream & get(std::istream &is)
static std::string beginTag()
void setRandomInterval(double x)
std::vector< unsigned long > put() const
static std::string engineName()
void flatArray(const int size, double *vect)