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

Random/CLHEP/Random/RandGamma.h
Go to the documentation of this file.
1 // $Id: RandGamma.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandGamma ---
7 // class header file
8 // -----------------------------------------------------------------------
9 
10 // Class defining methods for shooting gamma distributed random values,
11 // given a k (default=1) and specifying also a lambda (default=1).
12 // Default values are used for operator()().
13 
14 // Valid input values are k > 0 and lambda > 0. When invalid values are
15 // presented, the code silently returns -1.0.
16 
17 // =======================================================================
18 // John Marraffino - Created: 12th May 1998 Based on the C-Rand package
19 // by Ernst Stadlober and Franz Niederl of the Technical
20 // University of Graz, Austria.
21 // Gabriele Cosmo - Removed useless methods and data: 5th Jan 1999
22 // M Fischler - put and get to/from streams 12/10/04
23 // =======================================================================
24 
25 #ifndef RandGamma_h
26 #define RandGamma_h 1
27 
28 #include "CLHEP/Random/defs.h"
29 #include "CLHEP/Random/Random.h"
30 #include "CLHEP/Utility/memory.h"
31 
32 namespace CLHEP {
33 
38 class RandGamma : public HepRandom {
39 
40 public:
41 
42  inline RandGamma ( HepRandomEngine& anEngine, double k=1.0,
43  double lambda=1.0 );
44  inline RandGamma ( HepRandomEngine* anEngine, double k=1.0,
45  double lambda=1.0 );
46  // These constructors should be used to instantiate a RandGamma
47  // distribution object defining a local engine for it.
48  // The static generator will be skipped using the non-static methods
49  // defined below.
50  // If the engine is passed by pointer the corresponding engine object
51  // will be deleted by the RandGamma destructor.
52  // If the engine is passed by reference the corresponding engine object
53  // will not be deleted by the RandGamma destructor.
54 
55  virtual ~RandGamma();
56  // Destructor
57 
58  // Static methods to shoot random values using the static generator
59 
60  static inline double shoot();
61 
62  static double shoot( double k, double lambda );
63 
64  static void shootArray ( const int size, double* vect,
65  double k=1.0, double lambda=1.0 );
66 
67  // Static methods to shoot random values using a given engine
68  // by-passing the static generator.
69 
70  static inline double shoot( HepRandomEngine* anEngine );
71 
72  static double shoot( HepRandomEngine* anEngine,
73  double k, double lambda );
74 
75  static void shootArray ( HepRandomEngine* anEngine, const int size,
76  double* vect, double k=1.0,
77  double lambda=1.0 );
78 
79  // Methods using the localEngine to shoot random values, by-passing
80  // the static generator.
81 
82  inline double fire();
83 
84  double fire( double k, double lambda );
85 
86  void fireArray ( const int size, double* vect);
87  void fireArray ( const int size, double* vect,
88  double k, double lambda );
89  inline double operator()();
90  inline double operator()( double k, double lambda );
91 
92  // Save and restore to/from streams
93 
94  std::ostream & put ( std::ostream & os ) const;
95  std::istream & get ( std::istream & is );
96 
97  std::string name() const;
98  HepRandomEngine & engine();
99 
100  static std::string distributionName() {return "RandGamma";}
101  // Provides the name of this distribution class
102 
103 
104 private:
105 
106  static double genGamma( HepRandomEngine *anEngine, double k,
107  double lambda );
108 
109  shared_ptr<HepRandomEngine> localEngine;
110  double defaultK;
111  double defaultLambda;
112 
113 };
114 
115 } // namespace CLHEP
116 
117 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
118 // backwards compatibility will be enabled ONLY in CLHEP 1.9
119 using namespace CLHEP;
120 #endif
121 
122 #include "CLHEP/Random/RandGamma.icc"
123 
124 #endif
CLHEP::shared_ptr
Definition: Matrix/CLHEP/Utility/memory.h:66
CLHEP::HepRandomEngine
Definition: Matrix/CLHEP/Random/RandomEngine.h:55
CLHEP::RandGamma::RandGamma
RandGamma(HepRandomEngine &anEngine, double k=1.0, double lambda=1.0)
CLHEP::RandGamma::fire
double fire()
CLHEP::RandGamma::put
std::ostream & put(std::ostream &os) const
Definition: RandGamma.cc:223
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::RandGamma::shootArray
static void shootArray(const int size, double *vect, double k=1.0, double lambda=1.0)
Definition: RandGamma.cc:45
CLHEP::RandGamma::~RandGamma
virtual ~RandGamma()
Definition: RandGamma.cc:28
CLHEP::RandGamma::name
std::string name() const
Definition: RandGamma.cc:25
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::RandGamma::engine
HepRandomEngine & engine()
Definition: RandGamma.cc:26
CLHEP
Definition: ClhepVersion.h:13
CLHEP::RandGamma::operator()
double operator()()
CLHEP::RandGamma::fireArray
void fireArray(const int size, double *vect)
Definition: RandGamma.cc:60
CLHEP::RandGamma::get
std::istream & get(std::istream &is)
Definition: RandGamma.cc:243
k
long k
Definition: JamesRandomSeeding.txt:29
CLHEP::RandGamma::shoot
static double shoot()
CLHEP::RandGamma::distributionName
static std::string distributionName()
Definition: Random/CLHEP/Random/RandGamma.h:100