StRoot  1
JamesRandom.h
1 /***************************************************************************
2  *
3  * \$Id: JamesRandom.h,v 1.1 1999/01/30 03:58:59 fisyak Exp \$
4  *
5  * Author: Gabriele Cosmo - Created: 5th September 1995
6  * modified for SCL bl
7  ***************************************************************************
8  *
9  * Description:
10  * JamesRandom.h,v 1.6 1997/07/12 21:05:56
11  * -----------------------------------------------------------------------
12  * HEP Random
13  * --- HepJamesRandom ---
15  * -----------------------------------------------------------------------
16  * This file is part of Geant4 (simulation toolkit for HEP).
17  *
18  * HepJamesRandom implements the algorithm by Marsaglia-Zaman RANMAR
19  * described in "F.James, Comp. Phys. Comm. 60 (1990) 329" and implemented
20  * in FORTRAN77 as part of the MATHLIB HEP library for pseudo-random
21  * numbers generation.
22  * This is the default random engine invoked by each distribution unless
23  * the user sets a different one.
24  *
25  ***************************************************************************
26  *
27  * \$Log: JamesRandom.h,v \$
28  * Revision 1.1 1999/01/30 03:58:59 fisyak
29  * Root Version of StarClassLibrary
30  *
31  * Revision 1.1 1999/01/23 00:27:33 ullrich
32  * Initial Revision
33  *
34  **************************************************************************/
35 #ifndef HepJamesRandom_h
36 #define HepJamesRandom_h 1
37
38 #include "RandomEngine.h"
39
41
42 public:
43
44  HepJamesRandom(long seed = 19780503);
45  ~HepJamesRandom();
46  // Constructor and destructor.
47
49  // Copy constructor
50
51  HepJamesRandom & operator = (const HepJamesRandom &p);
52  // Overloaded assignment operator, to retrieve the engine status.
53
54  HepDouble flat();
55  // Returns a pseudo random number between 0 and 1
56  // (excluding the end points)
57
58  void flatArray (const HepInt size, HepDouble* vect);
59 #ifndef ST_NO_TEMPLATE_DEF_ARGS
60  void flatArray (vector<HepDouble>&);
61 #else
62  void flatArray (vector<HepDouble, allocator<HepDouble> >&);
63 #endif
64  // Fills the array "vect" of specified size with flat random values.
65
66  void setSeed(long seed, HepInt dum=0);
67  // Sets the state of the algorithm according to seed.
68
69  void setSeeds(const long * seeds, HepInt dum=0);
70  // Sets the state of the algorithm according to the zero terminated
71  // array of seeds. Only the first seed is used.
72
73  void saveStatus() const;
74  // Saves on file JamesRand.conf the current engine status.
75
76  void restoreStatus();
77  // Reads from file JamesRand.conf the last saved engine status
78  // and restores it.
79
80  void showStatus() const;
81  // Dumps the engine status on the screen.
82
83 private:
84
85  // Members defining the current status of the generator.
86  HepDouble u[97];
87  HepDouble c, cd, cm;
88  HepDouble *pi97, *pj97;
89
90 };
91
92 #endif