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

Random/Random/RandEngine.h
Go to the documentation of this file.
1 // $Id: RandEngine.h,v 1.6 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandEngine ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // Simple random engine using rand() and srand() functions from C standard
12 // library to implement the flat() basic distribution and for setting
13 // seeds.
14 // Copy constructor and operator= are private for objects of this class.
15 
16 // =======================================================================
17 // Gabriele Cosmo - Created: 5th September 1995
18 // - Minor corrections: 31st October 1996
19 // - Added methods for engine status: 19th November 1996
20 // - setSeed(), setSeeds() now have default dummy argument
21 // set to zero: 11th July 1997
22 // - Private copy constructor and operator=: 26th Feb 1998
23 // J.Marraffino - Added stream operators and related constructor.
24 // Added automatic seed selection from seed table and
25 // engine counter: 15th Feb 1998
26 // Ken Smith - Added conversion operators: 6th Aug 1998
27 // replace mx by mantissa_bit_32
28 // M Fischler - Inserted warnings about the fact that the quality of rand()
29 // is quite poor.
30 // Mark Fischler Methods for distrib. instance save/restore 12/8/04
31 // Mark Fischler methods for anonymous save/restore 12/27/04
32 // =======================================================================
33 
34 #ifndef RandEngine_h
35 #define RandEngine_h 1
36 
37 #include "CLHEP/Random/defs.h"
38 #include "CLHEP/Random/RandomEngine.h"
39 
40 namespace CLHEP {
41 
46 class RandEngine : public HepRandomEngine {
47 
48 public:
49 
50  RandEngine(std::istream& is);
51  RandEngine();
52  RandEngine(long seed);
53  RandEngine(int rowIndex, int colIndex);
54  virtual ~RandEngine();
55  // Constructors and destructor
56 
57  double flat();
58  // It returns a pseudo random number between 0 and 1,
59  // according to the standard stdlib random function rand()
60  // but excluding the end points.
61  //
62  // WARNING: rand() is quite a weak generator on most systems, <
63  // will not pass several randomness tests, and does not give a <
64  // reproducible sequence of numbers. <
65 
66  void flatArray (const int size, double* vect);
67  // Fills the array "vect" of specified size with flat random values.
68 
69  void setSeed(long seed, int dum=0);
70  // Sets the state of the algorithm according to seed.
71 
72  void setSeeds(const long * seeds, int dum=0);
73  // Sets the state of the algorithm according to the zero terminated
74  // array of seeds. Only the first seed is used.
75 
76  void saveStatus( const char filename[] = "Rand.conf" ) const;
77  // Saves on file Rand.conf the current engine status.
78  // WARNING: This is non-functional, as rand() on various systems will <
79  // not give reproducible streams. <
80 
81  void restoreStatus( const char filename[] = "Rand.conf" );
82  // Reads from file Rand.conf the last saved engine status
83  // and restores it.
84  // WARNING: This is non-functional, as rand() on various systems will <
85  // not give reproducible streams. <
86 
87  void showStatus() const;
88  // Dumps the engine status on the screen.
89 
90  operator unsigned int(); // 32-bit flat value, quickest of all.
91 
92  virtual std::ostream & put (std::ostream & os) const;
93  virtual std::istream & get (std::istream & is);
94  static std::string beginTag ( );
95  virtual std::istream & getState ( std::istream & is );
96 
97  std::string name() const;
98  static std::string engineName() {return "RandEngine";}
99 
100  std::vector<unsigned long> put () const;
101  bool get (const std::vector<unsigned long> & v);
102  bool getState (const std::vector<unsigned long> & v);
103 
104  static const unsigned int VECTOR_STATE_SIZE = 3;
105 
106 private:
107 
108  RandEngine(const RandEngine &p);
109  RandEngine & operator = (const RandEngine &p);
110  // Private copy constructor and assignment operator.
111 
112 private:
113 
114  long seq;
115  static int numEngines;
116  static int maxIndex;
117 
118 };
119 
120 } // namespace CLHEP
121 
122 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
123 // backwards compatibility will be enabled ONLY in CLHEP 1.9
124 using namespace CLHEP;
125 #endif
126 
127 #endif
CLHEP::RandEngine::restoreStatus
void restoreStatus(const char filename[]="Rand.conf")
Definition: RandEngine.cc:168
CLHEP::RandEngine::~RandEngine
virtual ~RandEngine()
Definition: RandEngine.cc:124
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::RandEngine::beginTag
static std::string beginTag()
Definition: RandEngine.cc:413
CLHEP::RandEngine::saveStatus
void saveStatus(const char filename[]="Rand.conf") const
Definition: RandEngine.cc:139
CLHEP::RandEngine::setSeeds
void setSeeds(const long *seeds, int dum=0)
Definition: RandEngine.cc:133
CLHEP::RandEngine
Definition: Matrix/CLHEP/Random/RandEngine.h:46
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
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::RandEngine::name
std::string name() const
Definition: RandEngine.cc:73
CLHEP::RandEngine::RandEngine
RandEngine()
Definition: RandEngine.cc:100
CLHEP::RandEngine::put
std::vector< unsigned long > put() const
Definition: RandEngine.cc:383
CLHEP::RandEngine::get
virtual std::istream & get(std::istream &is)
Definition: RandEngine.cc:391
CLHEP::RandEngine::engineName
static std::string engineName()
Definition: Random/Random/RandEngine.h:98
CLHEP::RandEngine::flatArray
void flatArray(const int size, double *vect)
Definition: RandEngine.cc:360
CLHEP::RandEngine::setSeed
void setSeed(long seed, int dum=0)
Definition: RandEngine.cc:126
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::RandEngine::getState
virtual std::istream & getState(std::istream &is)
Definition: RandEngine.cc:417
CLHEP::RandEngine::VECTOR_STATE_SIZE
static const unsigned int VECTOR_STATE_SIZE
Definition: Matrix/CLHEP/Random/RandEngine.h:104
CLHEP::RandEngine::showStatus
void showStatus() const
Definition: RandEngine.cc:213
CLHEP::RandEngine::flat
double flat()
Definition: RandEngine.cc:352