Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
RandGamma.h
Go to the documentation of this file.
1// $Id:$
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/Random.h"
30
31namespace CLHEP {
32
33/**
34 * @author
35 * @ingroup random
36 */
37class RandGamma : public HepRandom {
38
39public:
40
41 inline RandGamma ( HepRandomEngine& anEngine, double k=1.0,
42 double lambda=1.0 );
43 inline RandGamma ( HepRandomEngine* anEngine, double k=1.0,
44 double lambda=1.0 );
45 // These constructors should be used to instantiate a RandGamma
46 // distribution object defining a local engine for it.
47 // The static generator will be skipped using the non-static methods
48 // defined below.
49 // If the engine is passed by pointer the corresponding engine object
50 // will be deleted by the RandGamma destructor.
51 // If the engine is passed by reference the corresponding engine object
52 // will not be deleted by the RandGamma destructor.
53
54 virtual ~RandGamma();
55 // Destructor
56
57 // Static methods to shoot random values using the static generator
58
59 static inline double shoot();
60
61 static double shoot( double k, double lambda );
62
63 static void shootArray ( const int size, double* vect,
64 double k=1.0, double lambda=1.0 );
65
66 // Static methods to shoot random values using a given engine
67 // by-passing the static generator.
68
69 static inline double shoot( HepRandomEngine* anEngine );
70
71 static double shoot( HepRandomEngine* anEngine,
72 double k, double lambda );
73
74 static void shootArray ( HepRandomEngine* anEngine, const int size,
75 double* vect, double k=1.0,
76 double lambda=1.0 );
77
78 // Methods using the localEngine to shoot random values, by-passing
79 // the static generator.
80
81 inline double fire();
82
83 double fire( double k, double lambda );
84
85 void fireArray ( const int size, double* vect);
86 void fireArray ( const int size, double* vect,
87 double k, double lambda );
88 inline double operator()();
89 inline double operator()( double k, double lambda );
90
91 // Save and restore to/from streams
92
93 std::ostream & put ( std::ostream & os ) const;
94 std::istream & get ( std::istream & is );
95
96 std::string name() const;
98
99 static std::string distributionName() {return "RandGamma";}
100 // Provides the name of this distribution class
101
102
103private:
104
105 static double genGamma( HepRandomEngine *anEngine, double k,
106 double lambda );
107
108 shared_ptr<HepRandomEngine> localEngine;
109 double defaultK;
110 double defaultLambda;
111
112};
113
114} // namespace CLHEP
115
116#include "CLHEP/Random/RandGamma.icc"
117
118#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:24
RandGamma(HepRandomEngine *anEngine, double k=1.0, double lambda=1.0)
double operator()()
HepRandomEngine & engine()
Definition: RandGamma.cc:25
static void shootArray(const int size, double *vect, double k=1.0, double lambda=1.0)
Definition: RandGamma.cc:44
static std::string distributionName()
Definition: RandGamma.h:99
std::ostream & put(std::ostream &os) const
Definition: RandGamma.cc:222
virtual ~RandGamma()
Definition: RandGamma.cc:27
static double shoot()
void fireArray(const int size, double *vect)
Definition: RandGamma.cc:59
std::istream & get(std::istream &is)
Definition: RandGamma.cc:235
Definition: DoubConv.h:17