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

Random/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
virtual ~RandGamma()
Definition: RandGamma.cc:28
std::string name() const
Definition: RandGamma.cc:25
static std::string distributionName()
HepRandomEngine & engine()
Definition: RandGamma.cc:26
void fireArray(const int size, double *vect)
Definition: RandGamma.cc:60
RandGamma(HepRandomEngine &anEngine, double k=1.0, double lambda=1.0)
double operator()()
static void shootArray(const int size, double *vect, double k=1.0, double lambda=1.0)
Definition: RandGamma.cc:45
static double shoot()
std::ostream & put(std::ostream &os) const
Definition: RandGamma.cc:223