Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
NonRandomEngine.h
이 파일의 문서화 페이지로 가기
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 
82  double nextRandom;
83  std::vector<double> sequence;
84  unsigned int nInSeq;
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
Float_t x
Definition: compare.C:6
static std::string beginTag()
virtual void saveStatus(const char *) const
void setNextRandom(double r)
std::vector< double > sequence
static std::string engineName()
virtual void setSeed(long, int)
const XML_Char * s
Definition: expat.h:262
virtual void restoreStatus(const char *)
void flatArray(const int size, double *vect)
virtual void showStatus() const
void setRandomSequence(double *s, int n)
void setRandomInterval(double x)
std::string name() const
Char_t n[5]
virtual std::istream & getState(std::istream &is)
virtual void setSeeds(const long *, int)
std::vector< unsigned long > put() const