StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RanluxEngine.h
1 /***************************************************************************
2  *
3  * $Id: RanluxEngine.h,v 1.1 1999/01/30 03:59:01 fisyak Exp $
4  *
5  * Author: Adeyemi Adesanya - Created: 6th November 1995
6  * modfied for SCL bl
7  ***************************************************************************
8  *
9  * Description:
10  * RanluxEngine.h,v 1.3 1997/07/22 01:17:06
11  * -----------------------------------------------------------------------
12  * HEP Random
13  * --- RanluxEngine ---
14  * class header file
15  * -----------------------------------------------------------------------
16  * This file is part of Geant4 (simulation toolkit for HEP).
17  *
18  * The algorithm for this random engine has been taken from the original
19  * implementation in FORTRAN by Fred James as part of the MATHLIB HEP
20  * library.
21  * The initialisation is carried out using a Multiplicative Congruential
22  * generator using formula constants of L'Ecuyer as described in "F.James,
23  * Comp. Phys. Comm. 60 (1990) 329-344".
24  *
25  ***************************************************************************
26  *
27  * $Log: RanluxEngine.h,v $
28  * Revision 1.1 1999/01/30 03:59:01 fisyak
29  * Root Version of StarClassLibrary
30  *
31  * Revision 1.1 1999/01/23 00:27:44 ullrich
32  * Initial Revision
33  *
34  **************************************************************************/
35 #ifndef RanluxEngine_h
36 #define RanluxEngine_h 1
37 
38 #include "RandomEngine.h"
39 
40 class RanluxEngine : public HepRandomEngine {
41 
42 public:
43 
44  RanluxEngine(long seed = 19780503, HepInt lux = 3);
45  ~RanluxEngine();
46  // Constructor and destructor
47 
48  RanluxEngine(const RanluxEngine &p);
49  // Copy constructor
50 
51  RanluxEngine & operator = (const RanluxEngine &p);
52  // Overloaded assignment operator, to retrieve the engine status.
53 
54 // Luxury level is set in the same way as the original FORTRAN routine.
55 // level 0 (p=24): equivalent to the original RCARRY of Marsaglia
56 // and Zaman, very long period, but fails many tests.
57 // level 1 (p=48): considerable improvement in quality over level 0,
58 // now passes the gap test, but still fails spectral test.
59 // level 2 (p=97): passes all known tests, but theoretically still
60 // defective.
61 // level 3 (p=223): DEFAULT VALUE. Any theoretically possible
62 // correlations have very small chance of being observed.
63 // level 4 (p=389): highest possible luxury, all 24 bits chaotic.
64 
65  HepDouble flat();
66  // It returns a pseudo random number between 0 and 1,
67  // excluding the end points.
68 
69  void flatArray (const HepInt size, HepDouble* vect);
70 #ifndef ST_NO_TEMPLATE_DEF_ARGS
71  void flatArray (vector<HepDouble>&);
72 #else
73  void flatArray (vector<HepDouble, allocator<HepDouble> >&);
74 #endif
75  // Fills the array "vect" of specified size with flat random values.
76 
77  void setSeed(long seed, HepInt lux=3);
78  // Sets the state of the algorithm according to seed.
79 
80  void setSeeds(const long * seeds, HepInt lux=3);
81  // Sets the state of the algorithm according to the zero terminated
82  // array of seeds. Only the first seed is used.
83 
84  void saveStatus() const;
85  // Saves on file Ranlux.conf the current engine status.
86 
87  void restoreStatus();
88  // Reads from file Ranlux.conf the last saved engine status
89  // and restores it.
90 
91  void showStatus() const;
92  // Dumps the engine status on the screen.
93 
94  HepInt getLuxury() const { return luxury; }
95  // Gets the luxury level.
96 
97 private:
98 
99  HepInt nskip, luxury;
100  HepFloat float_seed_table[24];
101  HepInt i_lag,j_lag;
102  HepFloat carry;
103  HepInt count24;
104  const HepInt int_modulus;
105  const HepFloat mantissa_bit_24;
106  const HepFloat mantissa_bit_12;
107 
108 };
109 
110 #endif