Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
JamesRandom.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// -----------------------------------------------------------------------
4// HEP Random
5// --- HepJamesRandom ---
6// class header file
7// -----------------------------------------------------------------------
8// This file is part of Geant4 (simulation toolkit for HEP).
9//
10// HepJamesRandom implements the algorithm by Marsaglia-Zaman RANMAR
11// described in "F.James, Comp. Phys. Comm. 60 (1990) 329" and implemented
12// in FORTRAN77 as part of the MATHLIB HEP library for pseudo-random
13// numbers generation.
14// This is the default random engine invoked by each distribution unless
15// the user sets a different one.
16
17// =======================================================================
18// Gabriele Cosmo - Created: 5th September 1995
19// - Minor corrections: 31st October 1996
20// - Added methods for engine status: 19th November 1996
21// - setSeed(), setSeeds() now have default dummy argument
22// set to zero: 11th July 1997
23// J.Marraffino - Added stream operators and related constructor.
24// Added automatic seed selection from seed table and
25// engine counter: 16th Feb 1998
26// Ken Smith - Added conversion operators: 6th Aug 1998
27// V. Innocente - changed pointers to indices 3 may 2000
28// Mark Fischler - Methods for distrib. instance save/restore 12/8/04
29// Mark Fischler methods for anonymous save/restore 12/27/04
30// =======================================================================
31
32#ifndef HepJamesRandom_h
33#define HepJamesRandom_h 1
34
36
37namespace CLHEP {
38
39/**
40 * @author
41 * @ingroup random
42 */
44
45public:
46
47 HepJamesRandom(std::istream& is);
49 HepJamesRandom(long seed);
50 HepJamesRandom(int rowIndex, int colIndex);
51 virtual ~HepJamesRandom();
52 // Constructor and destructor.
53
54 double flat();
55 // Returns a pseudo random number between 0 and 1
56 // (excluding the end points)
57
58 void flatArray (const int size, double* vect);
59 // Fills the array "vect" of specified size with flat random values.
60
61 void setSeed(long seed, int dum=0);
62 // Sets the state of the algorithm according to seed.
63
64 void setSeeds(const long * seeds, int dum=0);
65 // Sets the state of the algorithm according to the zero terminated
66 // array of seeds. Only the first seed is used.
67
68 void saveStatus( const char filename[] = "JamesRand.conf" ) const;
69 // Saves on file JamesRand.conf the current engine status.
70
71 void restoreStatus( const char filename[] = "JamesRand.conf" );
72 // Reads from file JamesRand.conf the last saved engine status
73 // and restores it.
74
75 void showStatus() const;
76 // Dumps the engine status on the screen.
77
78 operator double();
79 // Returns same as flat()
80 operator float();
81 // less precise flat, faster if possible
82 operator unsigned int();
83 // 32-bit flat, but slower than double or float.
84
85 virtual std::ostream & put (std::ostream & os) const;
86 virtual std::istream & get (std::istream & is);
87 static std::string beginTag ( );
88 virtual std::istream & getState ( std::istream & is );
89
90 std::string name() const;
91 static std::string engineName() {return "HepJamesRandom";}
92
93 std::vector<unsigned long> put () const;
94 bool get (const std::vector<unsigned long> & v);
95 bool getState (const std::vector<unsigned long> & v);
96
97 static const unsigned int VECTOR_STATE_SIZE = 202;
98
99private:
100
101 // Members defining the current status of the generator.
102 double u[97];
103 double c, cd, cm;
104 int i97, j97;
105};
106
107} // namespace CLHEP
108
109#endif
void flatArray(const int size, double *vect)
Definition: JamesRandom.cc:264
static std::string beginTag()
Definition: JamesRandom.cc:333
static std::string engineName()
Definition: JamesRandom.h:91
void setSeeds(const long *seeds, int dum=0)
Definition: JamesRandom.cc:233
virtual std::istream & getState(std::istream &is)
Definition: JamesRandom.cc:337
std::string name() const
Definition: JamesRandom.cc:64
std::vector< unsigned long > put() const
Definition: JamesRandom.cc:297
void setSeed(long seed, int dum=0)
Definition: JamesRandom.cc:181
virtual std::istream & get(std::istream &is)
Definition: JamesRandom.cc:316
void saveStatus(const char filename[]="JamesRand.conf") const
Definition: JamesRandom.cc:114
void restoreStatus(const char filename[]="JamesRand.conf")
Definition: JamesRandom.cc:127
static const unsigned int VECTOR_STATE_SIZE
Definition: JamesRandom.h:97
void showStatus() const
Definition: JamesRandom.cc:165
Definition: DoubConv.h:17