Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
RanecuEngine.h
이 파일의 문서화 페이지로 가기
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RanecuEngine ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // RANECU Random Engine - algorithm originally written in FORTRAN77
12 // as part of the MATHLIB HEP library.
13 // The initialisation is carried out using a Multiplicative Congruential
14 // generator using formula constants of L'Ecuyer as described in "F.James,
15 // Comp. Phys. Comm. 60 (1990) 329-344".
16 // Seeds are taken from a seed table given an index, the getSeed() method
17 // returns the current index in the seed table, the getSeeds() method
18 // returns a pointer to the couple of seeds stored in the local table of
19 // seeds at the current index.
20 
21 // =======================================================================
22 // Gabriele Cosmo - Created: 2nd February 1996
23 // - Minor corrections: 31st October 1996
24 // - Added methods for engine status: 19th November 1996
25 // - setSeed() now has default dummy argument
26 // set to zero: 11th July 1997
27 // - Added default index to setSeeds(): 16th Oct 1997
28 // J.Marraffino - Added stream operators and related constructor.
29 // Added automatic seed selection from seed table and
30 // engine counter: 16th Feb 1998
31 // Ken Smith - Added conversion operators: 6th Aug 1998
32 // Mark Fischler Methods for distrib. instance save/restore 12/8/04
33 // Mark Fischler methods for anonymous save/restore 12/27/04
34 // =======================================================================
35 
36 #ifndef RanecuEngine_h
37 #define RanecuEngine_h 1
38 
40 
41 namespace CLHEP {
42 
47 class RanecuEngine : public HepRandomEngine {
48 
49 public:
50 
51  RanecuEngine(std::istream& is);
52  RanecuEngine();
53  RanecuEngine(int index);
54  virtual ~RanecuEngine();
55  // Constructors and destructor.
56 
57  double flat();
58  // Returns a pseudo random number between 0 and 1
59  // (excluding the end points)
60 
61  void flatArray (const int size, double* vect);
62  // Fills an array "vect" of specified size with flat random values.
63 
64  void setIndex (long index);
65  // Sets the state of the algorithm according to "index", the position
66  // in the local table of seeds.
67 
68  void setSeed (long index, int dum=0);
69  // Resets the state of the algorithm according to "index", the position
70  // in the static table of seeds stored in HepRandom.
71 
72  void setSeeds (const long* seeds, int index=-1);
73  // Sets the state of the algorithm according to the array of seeds
74  // "seeds" containing two seed values to be stored in the local table at
75  // "index" position.
76 
77  void saveStatus( const char filename[] = "Ranecu.conf" ) const;
78  // Saves on file Ranecu.conf the current engine status.
79 
80  void restoreStatus( const char filename[] = "Ranecu.conf" );
81  // Reads from file Ranecu.conf the last saved engine status
82  // and restores it.
83 
84  void showStatus() const;
85  // Dumps the engine status on the screen.
86 
87  operator double();
88  // Returns same as flat()
89  operator float();
90  // less precise flat, faster if possible
91  operator unsigned int();
92  // 32-bit int flat, faster in this case
93 
94  virtual std::ostream & put (std::ostream & os) const;
95  virtual std::istream & get (std::istream & is);
96  static std::string beginTag ( );
97  virtual std::istream & getState ( std::istream & is );
98 
99  std::string name() const;
100  static std::string engineName() {return "RanecuEngine";}
101 
102  std::vector<unsigned long> put () const;
103  bool get (const std::vector<unsigned long> & v);
104  bool getState (const std::vector<unsigned long> & v);
105 
106 protected:
107 
108  // Suggested L'ecuyer coefficients for portable 32 bits generators.
109 
110  static const int ecuyer_a = 40014;
111  static const int ecuyer_b = 53668;
112  static const int ecuyer_c = 12211;
113  static const int ecuyer_d = 40692;
114  static const int ecuyer_e = 52774;
115  static const int ecuyer_f = 3791;
116  static const int shift1 = 2147483563;
117  static const int shift2 = 2147483399;
118 
119  static const unsigned int VECTOR_STATE_SIZE = 4;
120 
121 private:
122 
123  // private method used to mitigate the effects of using a lookup table
124  void further_randomize (int seq, int col, int index, int modulus);
125 
126  // Members defining the current state of the generator.
127 
128  static const int maxSeq = 215;
129  long table[215][2];
130  int seq;
131 
132 };
133 
134 } // namespace CLHEP
135 
136 #endif
static const int ecuyer_c
Definition: RanecuEngine.h:112
void restoreStatus(const char filename[]="Ranecu.conf")
static std::string engineName()
Definition: RanecuEngine.h:100
void showStatus() const
void setSeeds(const long *seeds, int index=-1)
void setSeed(long index, int dum=0)
static const int ecuyer_a
Definition: RanecuEngine.h:110
static const int maxSeq
Definition: RanecuEngine.h:128
virtual std::istream & getState(std::istream &is)
void setIndex(long index)
Int_t col[ntarg]
Definition: Style.C:29
static const int shift2
Definition: RanecuEngine.h:117
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
std::string name() const
Definition: RanecuEngine.cc:60
void flatArray(const int size, double *vect)
static const unsigned int VECTOR_STATE_SIZE
Definition: RanecuEngine.h:119
long table[215][2]
Definition: RanecuEngine.h:129
void further_randomize(int seq, int col, int index, int modulus)
Definition: RanecuEngine.cc:62
static const int ecuyer_b
Definition: RanecuEngine.h:111
std::vector< unsigned long > put() const
void saveStatus(const char filename[]="Ranecu.conf") const
static const int ecuyer_d
Definition: RanecuEngine.h:113
static const int shift1
Definition: RanecuEngine.h:116
static const int ecuyer_f
Definition: RanecuEngine.h:115
static std::string beginTag()
static const int ecuyer_e
Definition: RanecuEngine.h:114