Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
JamesRandom.h
이 파일의 문서화 페이지로 가기
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- HepJamesRandom ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // HepJamesRandom implements the algorithm by Marsaglia-Zaman RANMAR
12 // described in "F.James, Comp. Phys. Comm. 60 (1990) 329" and implemented
13 // in FORTRAN77 as part of the MATHLIB HEP library for pseudo-random
14 // numbers generation.
15 // This is the default random engine invoked by each distribution unless
16 // the user sets a different one.
17 
18 // =======================================================================
19 // Gabriele Cosmo - Created: 5th September 1995
20 // - Minor corrections: 31st October 1996
21 // - Added methods for engine status: 19th November 1996
22 // - setSeed(), setSeeds() now have default dummy argument
23 // set to zero: 11th July 1997
24 // J.Marraffino - Added stream operators and related constructor.
25 // Added automatic seed selection from seed table and
26 // engine counter: 16th Feb 1998
27 // Ken Smith - Added conversion operators: 6th Aug 1998
28 // V. Innocente - changed pointers to indices 3 may 2000
29 // Mark Fischler - Methods for distrib. instance save/restore 12/8/04
30 // Mark Fischler methods for anonymous save/restore 12/27/04
31 // =======================================================================
32 
33 #ifndef HepJamesRandom_h
34 #define HepJamesRandom_h 1
35 
37 
38 namespace CLHEP {
39 
45 
46 public:
47 
48  HepJamesRandom(std::istream& is);
50  HepJamesRandom(long seed);
51  HepJamesRandom(int rowIndex, int colIndex);
52  virtual ~HepJamesRandom();
53  // Constructor and destructor.
54 
55  double flat();
56  // Returns a pseudo random number between 0 and 1
57  // (excluding the end points)
58 
59  void flatArray (const int size, double* vect);
60  // Fills the array "vect" of specified size with flat random values.
61 
62  void setSeed(long seed, int dum=0);
63  // Sets the state of the algorithm according to seed.
64 
65  void setSeeds(const long * seeds, int dum=0);
66  // Sets the state of the algorithm according to the zero terminated
67  // array of seeds. Only the first seed is used.
68 
69  void saveStatus( const char filename[] = "JamesRand.conf" ) const;
70  // Saves on file JamesRand.conf the current engine status.
71 
72  void restoreStatus( const char filename[] = "JamesRand.conf" );
73  // Reads from file JamesRand.conf the last saved engine status
74  // and restores it.
75 
76  void showStatus() const;
77  // Dumps the engine status on the screen.
78 
79  operator double();
80  // Returns same as flat()
81  operator float();
82  // less precise flat, faster if possible
83  operator unsigned int();
84  // 32-bit flat, but slower than double or float.
85 
86  virtual std::ostream & put (std::ostream & os) const;
87  virtual std::istream & get (std::istream & is);
88  static std::string beginTag ( );
89  virtual std::istream & getState ( std::istream & is );
90 
91  std::string name() const;
92  static std::string engineName() {return "HepJamesRandom";}
93 
94  std::vector<unsigned long> put () const;
95  bool get (const std::vector<unsigned long> & v);
96  bool getState (const std::vector<unsigned long> & v);
97 
98  static const unsigned int VECTOR_STATE_SIZE = 202;
99 
100 private:
101 
102  // Members defining the current status of the generator.
103  double u[97];
104  double c, cd, cm;
105  int i97, j97;
106 };
107 
108 } // namespace CLHEP
109 
110 #endif
void setSeed(long seed, int dum=0)
Definition: JamesRandom.cc:178
void saveStatus(const char filename[]="JamesRand.conf") const
Definition: JamesRandom.cc:111
static std::string beginTag()
Definition: JamesRandom.cc:330
void flatArray(const int size, double *vect)
Definition: JamesRandom.cc:261
std::vector< unsigned long > put() const
Definition: JamesRandom.cc:294
static const unsigned int VECTOR_STATE_SIZE
Definition: JamesRandom.h:98
std::string name() const
Definition: JamesRandom.cc:61
long seed
Definition: chem4.cc:68
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void setSeeds(const long *seeds, int dum=0)
Definition: JamesRandom.cc:230
virtual std::istream & getState(std::istream &is)
Definition: JamesRandom.cc:334
void showStatus() const
Definition: JamesRandom.cc:162
static std::string engineName()
Definition: JamesRandom.h:92
void restoreStatus(const char filename[]="JamesRand.conf")
Definition: JamesRandom.cc:124