CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Matrix/CLHEP/Random/RanecuEngine.h
Go to the documentation of this file.
1 // $Id: RanecuEngine.h,v 1.6 2010/07/20 18:06:02 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RanecuEngine ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // RANECU Random Engine - algorithm originally written in FORTRAN77
12 // as part of the MATHLIB HEP library.
13 // The initialisation is carried out using a Multiplicative Congruential
14 // generator using formula constants of L'Ecuyer as described in "F.James,
15 // Comp. Phys. Comm. 60 (1990) 329-344".
16 // Seeds are taken from a seed table given an index, the getSeed() method
17 // returns the current index in the seed table, the getSeeds() method
18 // returns a pointer to the couple of seeds stored in the local table of
19 // seeds at the current index.
20 
21 // =======================================================================
22 // Gabriele Cosmo - Created: 2nd February 1996
23 // - Minor corrections: 31st October 1996
24 // - Added methods for engine status: 19th November 1996
25 // - setSeed() now has default dummy argument
26 // set to zero: 11th July 1997
27 // - Added default index to setSeeds(): 16th Oct 1997
28 // J.Marraffino - Added stream operators and related constructor.
29 // Added automatic seed selection from seed table and
30 // engine counter: 16th Feb 1998
31 // Ken Smith - Added conversion operators: 6th Aug 1998
32 // Mark Fischler Methods for distrib. instance save/restore 12/8/04
33 // Mark Fischler methods for anonymous save/restore 12/27/04
34 // =======================================================================
35 
36 #ifndef RanecuEngine_h
37 #define RanecuEngine_h 1
38 
39 #include "CLHEP/Random/defs.h"
40 #include "CLHEP/Random/RandomEngine.h"
41 
42 namespace CLHEP {
43 
48 class RanecuEngine : public HepRandomEngine {
49 
50 public:
51 
52  RanecuEngine(std::istream& is);
53  RanecuEngine();
54  RanecuEngine(int index);
55  virtual ~RanecuEngine();
56  // Constructors and destructor.
57 
58  double flat();
59  // Returns a pseudo random number between 0 and 1
60  // (excluding the end points)
61 
62  void flatArray (const int size, double* vect);
63  // Fills an array "vect" of specified size with flat random values.
64 
65  void setIndex (long index);
66  // Sets the state of the algorithm according to "index", the position
67  // in the local table of seeds.
68 
69  void setSeed (long index, int dum=0);
70  // Resets the state of the algorithm according to "index", the position
71  // in the static table of seeds stored in HepRandom.
72 
73  void setSeeds (const long* seeds, int index=-1);
74  // Sets the state of the algorithm according to the array of seeds
75  // "seeds" containing two seed values to be stored in the local table at
76  // "index" position.
77 
78  void saveStatus( const char filename[] = "Ranecu.conf" ) const;
79  // Saves on file Ranecu.conf the current engine status.
80 
81  void restoreStatus( const char filename[] = "Ranecu.conf" );
82  // Reads from file Ranecu.conf the last saved engine status
83  // and restores it.
84 
85  void showStatus() const;
86  // Dumps the engine status on the screen.
87 
88  operator unsigned int();
89  // 32-bit int flat, faster in this case
90 
91  virtual std::ostream & put (std::ostream & os) const;
92  virtual std::istream & get (std::istream & is);
93  static std::string beginTag ( );
94  virtual std::istream & getState ( std::istream & is );
95 
96  std::string name() const;
97  static std::string engineName() {return "RanecuEngine";}
98 
99  std::vector<unsigned long> put () const;
100  bool get (const std::vector<unsigned long> & v);
101  bool getState (const std::vector<unsigned long> & v);
102 
103 protected:
104 
105  // Suggested L'ecuyer coefficients for portable 32 bits generators.
106 
107  static const int ecuyer_a = 40014;
108  static const int ecuyer_b = 53668;
109  static const int ecuyer_c = 12211;
110  static const int ecuyer_d = 40692;
111  static const int ecuyer_e = 52774;
112  static const int ecuyer_f = 3791;
113  static const int shift1 = 2147483563;
114  static const int shift2 = 2147483399;
115 
116  static const unsigned int VECTOR_STATE_SIZE = 4;
117 
118 private:
119 
120  // private method used to mitigate the effects of using a lookup table
121  void further_randomize (int seq, int col, int index, int modulus);
122 
123  // Members defining the current state of the generator.
124 
125  static const int maxSeq = 215;
126  long table[215][2];
127  int seq;
128  static int numEngines;
129 
130 };
131 
132 } // namespace CLHEP
133 
134 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
135 // backwards compatibility will be enabled ONLY in CLHEP 1.9
136 using namespace CLHEP;
137 #endif
138 
139 #endif
CLHEP::RanecuEngine::setSeed
void setSeed(long index, int dum=0)
Definition: RanecuEngine.cc:106
CLHEP::HepRandomEngine
Definition: Matrix/CLHEP/Random/RandomEngine.h:55
CLHEP::RanecuEngine::flat
double flat()
Definition: RanecuEngine.cc:214
CLHEP::RanecuEngine::ecuyer_a
static const int ecuyer_a
Definition: Matrix/CLHEP/Random/RanecuEngine.h:107
CLHEP::RanecuEngine
Definition: Matrix/CLHEP/Random/RanecuEngine.h:48
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP::RanecuEngine::shift2
static const int shift2
Definition: Matrix/CLHEP/Random/RanecuEngine.h:114
CLHEP::RanecuEngine::~RanecuEngine
virtual ~RanecuEngine()
Definition: RanecuEngine.cc:104
CLHEP::RanecuEngine::ecuyer_d
static const int ecuyer_d
Definition: Matrix/CLHEP/Random/RanecuEngine.h:110
CLHEP::RanecuEngine::engineName
static std::string engineName()
Definition: Matrix/CLHEP/Random/RanecuEngine.h:97
CLHEP::RanecuEngine::flatArray
void flatArray(const int size, double *vect)
Definition: RanecuEngine.cc:237
CLHEP::RanecuEngine::setIndex
void setIndex(long index)
Definition: RanecuEngine.cc:128
size
user code seldom needs to call this function directly ZMerrno whether or not they are still recorded ZMerrno size() Return the(integer) number of ZMthrow 'n exceptions currently recorded. 5) ZMerrno.clear() Set an internal counter to zero. This counter is available(see next function) to user code to track ZMthrow 'n exceptions that have occurred during any arbitrary time interval. 6) ZMerrno.countSinceCleared() Return the(integer) number of ZMthrow 'n exceptions that have been recorded via ZMerrno.write()
CLHEP::RanecuEngine::RanecuEngine
RanecuEngine()
Definition: RanecuEngine.cc:65
CLHEP
Definition: ClhepVersion.h:13
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
CLHEP::RanecuEngine::ecuyer_c
static const int ecuyer_c
Definition: Matrix/CLHEP/Random/RanecuEngine.h:109
CLHEP::RanecuEngine::saveStatus
void saveStatus(const char filename[]="Ranecu.conf") const
Definition: RanecuEngine.cc:135
CLHEP::RanecuEngine::restoreStatus
void restoreStatus(const char filename[]="Ranecu.conf")
Definition: RanecuEngine.cc:166
CLHEP::RanecuEngine::showStatus
void showStatus() const
Definition: RanecuEngine.cc:203
CLHEP::RanecuEngine::ecuyer_f
static const int ecuyer_f
Definition: Matrix/CLHEP/Random/RanecuEngine.h:112
CLHEP::RanecuEngine::ecuyer_e
static const int ecuyer_e
Definition: Matrix/CLHEP/Random/RanecuEngine.h:111
seeds
Technical Maintenance Note for CLHEP Random Consequences of seeding JamesRandom with positive seed values greater than In the source code JamesRandom The usual way of seeding a generator is via the default which makes use of the table of seeds(with some trickery to ensure that the values won 't repeat after the table rows are exhausted). The trickery preserves the fact that sees are never negative(because the table values are never negative
CLHEP::RanecuEngine::shift1
static const int shift1
Definition: Matrix/CLHEP/Random/RanecuEngine.h:113
CLHEP::RanecuEngine::getState
virtual std::istream & getState(std::istream &is)
Definition: RanecuEngine.cc:338
CLHEP::RanecuEngine::setSeeds
void setSeeds(const long *seeds, int index=-1)
Definition: RanecuEngine.cc:116
CLHEP::RanecuEngine::beginTag
static std::string beginTag()
Definition: RanecuEngine.cc:334
CLHEP::RanecuEngine::name
std::string name() const
Definition: RanecuEngine.cc:54
CLHEP::RanecuEngine::VECTOR_STATE_SIZE
static const unsigned int VECTOR_STATE_SIZE
Definition: Matrix/CLHEP/Random/RanecuEngine.h:116
CLHEP::RanecuEngine::ecuyer_b
static const int ecuyer_b
Definition: Matrix/CLHEP/Random/RanecuEngine.h:108
CLHEP::RanecuEngine::put
std::vector< unsigned long > put() const
Definition: RanecuEngine.cc:306
CLHEP::RanecuEngine::get
virtual std::istream & get(std::istream &is)
Definition: RanecuEngine.cc:315