ThePEG  1.8.0
StandardRandom.h
1 // -*- C++ -*-
2 //
3 // StandardRandom.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_StandardRandom_H
10 #define ThePEG_StandardRandom_H
11 // This is the declaration of the StandardRandom class.
12 
13 #include "RandomGenerator.h"
14 #include "ThePEG/Persistency/PersistentOStream.h"
15 #include "ThePEG/Persistency/PersistentIStream.h"
16 
17 namespace ThePEG {
18 
27 
28 public:
29 
35  StandardRandom() : u(97) { if ( theSeed != 0 ) setSeed(theSeed); }
37 
38 public:
39 
44  virtual void setSeed(long seed);
45 
46 protected:
47 
51  virtual void fill();
52 
53 public:
54 
55 
62  void persistentOutput(PersistentOStream & os) const;
63 
69  void persistentInput(PersistentIStream & is, int version);
71 
75  static void Init();
76 
77 protected:
78 
85  virtual IBPtr clone() const;
86 
91  virtual IBPtr fullclone() const;
93 
94 private:
95 
99  vector<double> u;
100 
104  double c;
105 
109  double cd;
110 
114  double cm;
115 
119  int i97;
120 
124  int j97;
125 
126 private:
127 
132 
137 
138 };
139 
144 template <>
147  typedef RandomGenerator NthBase;
148 };
149 
152 template <>
153 struct ClassTraits<StandardRandom>: public ClassTraitsBase<StandardRandom> {
155  static string className() { return "ThePEG::StandardRandom"; }
156 };
157 
160 }
161 
162 #endif /* ThePEG_StandardRandom_H */
virtual IBPtr clone() const
Make a simple clone of this object.
virtual void setSeed(long seed)
Reset the underlying random algorithm with the given seed.
PersistentIStream is used to read persistent objects from a stream where they were previously written...
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
static ClassDescription< StandardRandom > initStandardRandom
Describe a concrete class with persistent data.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
virtual void fill()
Fill the cache with random numbers.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
RandomGenerator is an interface to the CLHEP::RandomEngine classes.
StandardRandom & operator=(const StandardRandom &)
Private and non-existent assignment operator.
static void Init()
Standard Init function used to initialize the interface.
int j97
Index for the internal state.
vector< double > u
The internal state vector.
double c
Parameter for the internal state.
int i97
Index for the internal state.
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
StandardRandom inherits from the RandomGenerator class and is an interface to the CLHEP::JamesRandom ...
double cd
Parameter for the internal state.
StandardRandom()
Default constructor.
static string className()
Return the name of class T.
Definition: ClassTraits.h:66
double cm
Parameter for the internal state.
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
long theSeed
The seed to initialize the random generator with.
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156