00001 /*************************************************************************** 00002 * 00003 * $Id: RanluxEngine.h,v 1.1 1999/01/30 03:59:01 fisyak Exp $ 00004 * 00005 * Author: Adeyemi Adesanya - Created: 6th November 1995 00006 * modfied for SCL bl 00007 *************************************************************************** 00008 * 00009 * Description: 00010 * RanluxEngine.h,v 1.3 1997/07/22 01:17:06 00011 * ----------------------------------------------------------------------- 00012 * HEP Random 00013 * --- RanluxEngine --- 00014 * class header file 00015 * ----------------------------------------------------------------------- 00016 * This file is part of Geant4 (simulation toolkit for HEP). 00017 * 00018 * The algorithm for this random engine has been taken from the original 00019 * implementation in FORTRAN by Fred James as part of the MATHLIB HEP 00020 * library. 00021 * The initialisation is carried out using a Multiplicative Congruential 00022 * generator using formula constants of L'Ecuyer as described in "F.James, 00023 * Comp. Phys. Comm. 60 (1990) 329-344". 00024 * 00025 *************************************************************************** 00026 * 00027 * $Log: RanluxEngine.h,v $ 00028 * Revision 1.1 1999/01/30 03:59:01 fisyak 00029 * Root Version of StarClassLibrary 00030 * 00031 * Revision 1.1 1999/01/23 00:27:44 ullrich 00032 * Initial Revision 00033 * 00034 **************************************************************************/ 00035 #ifndef RanluxEngine_h 00036 #define RanluxEngine_h 1 00037 00038 #include "RandomEngine.h" 00039 00040 class RanluxEngine : public HepRandomEngine { 00041 00042 public: 00043 00044 RanluxEngine(long seed = 19780503, HepInt lux = 3); 00045 ~RanluxEngine(); 00046 // Constructor and destructor 00047 00048 RanluxEngine(const RanluxEngine &p); 00049 // Copy constructor 00050 00051 RanluxEngine & operator = (const RanluxEngine &p); 00052 // Overloaded assignment operator, to retrieve the engine status. 00053 00054 // Luxury level is set in the same way as the original FORTRAN routine. 00055 // level 0 (p=24): equivalent to the original RCARRY of Marsaglia 00056 // and Zaman, very long period, but fails many tests. 00057 // level 1 (p=48): considerable improvement in quality over level 0, 00058 // now passes the gap test, but still fails spectral test. 00059 // level 2 (p=97): passes all known tests, but theoretically still 00060 // defective. 00061 // level 3 (p=223): DEFAULT VALUE. Any theoretically possible 00062 // correlations have very small chance of being observed. 00063 // level 4 (p=389): highest possible luxury, all 24 bits chaotic. 00064 00065 HepDouble flat(); 00066 // It returns a pseudo random number between 0 and 1, 00067 // excluding the end points. 00068 00069 void flatArray (const HepInt size, HepDouble* vect); 00070 #ifndef ST_NO_TEMPLATE_DEF_ARGS 00071 void flatArray (vector<HepDouble>&); 00072 #else 00073 void flatArray (vector<HepDouble, allocator<HepDouble> >&); 00074 #endif 00075 // Fills the array "vect" of specified size with flat random values. 00076 00077 void setSeed(long seed, HepInt lux=3); 00078 // Sets the state of the algorithm according to seed. 00079 00080 void setSeeds(const long * seeds, HepInt lux=3); 00081 // Sets the state of the algorithm according to the zero terminated 00082 // array of seeds. Only the first seed is used. 00083 00084 void saveStatus() const; 00085 // Saves on file Ranlux.conf the current engine status. 00086 00087 void restoreStatus(); 00088 // Reads from file Ranlux.conf the last saved engine status 00089 // and restores it. 00090 00091 void showStatus() const; 00092 // Dumps the engine status on the screen. 00093 00094 HepInt getLuxury() const { return luxury; } 00095 // Gets the luxury level. 00096 00097 private: 00098 00099 HepInt nskip, luxury; 00100 HepFloat float_seed_table[24]; 00101 HepInt i_lag,j_lag; 00102 HepFloat carry; 00103 HepInt count24; 00104 const HepInt int_modulus; 00105 const HepFloat mantissa_bit_24; 00106 const HepFloat mantissa_bit_12; 00107 00108 }; 00109 00110 #endif
1.5.9