CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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
32namespace CLHEP {
33
34/**
35 * @author
36 * @ingroup random
37 */
38class RandGamma : public HepRandom {
39
40public:
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;
99
100 static std::string distributionName() {return "RandGamma";}
101 // Provides the name of this distribution class
102
103
104private:
105
106 static double genGamma( HepRandomEngine *anEngine, double k,
107 double lambda );
108
109 std::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
119using namespace CLHEP;
120#endif
121
122#include "CLHEP/Random/RandGamma.icc"
123
124#endif
RandGamma(HepRandomEngine &anEngine, double k=1.0, double lambda=1.0)
static double shoot(HepRandomEngine *anEngine)
double operator()(double k, double lambda)
std::string name() const
Definition: RandGamma.cc:29
RandGamma(HepRandomEngine *anEngine, double k=1.0, double lambda=1.0)
double operator()()
HepRandomEngine & engine()
Definition: RandGamma.cc:30
static void shootArray(const int size, double *vect, double k=1.0, double lambda=1.0)
Definition: RandGamma.cc:49
static std::string distributionName()
Definition: RandGamma.h:100
std::ostream & put(std::ostream &os) const
Definition: RandGamma.cc:227
virtual ~RandGamma()
Definition: RandGamma.cc:32
static double shoot()
void fireArray(const int size, double *vect)
Definition: RandGamma.cc:64
std::istream & get(std::istream &is)
Definition: RandGamma.cc:247