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

Random/CLHEP/Random/RandExponential.h
Go to the documentation of this file.
1 // $Id: RandExponential.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandExponential ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // Class defining methods for shooting exponential distributed random
12 // values, given a mean (default mean = 1).
13 // Default mean is used for operator()().
14 
15 // =======================================================================
16 // Gabriele Cosmo - Created: 5th September 1995
17 // - Added methods to shoot arrays: 28th July 1997
18 // J.Marraffino - Added default mean as attribute and
19 // operator() with mean: 16th Feb 1998
20 // M Fischler - put and get to/from streams 12/10/04
21 // =======================================================================
22 
23 #ifndef RandExponential_h
24 #define RandExponential_h 1
25 
26 #include "CLHEP/Random/defs.h"
27 #include "CLHEP/Random/Random.h"
28 #include "CLHEP/Utility/memory.h"
29 
30 namespace CLHEP {
31 
36 class RandExponential : public HepRandom {
37 
38 public:
39 
40  inline RandExponential ( HepRandomEngine& anEngine, double mean=1.0 );
41  inline RandExponential ( HepRandomEngine* anEngine, double mean=1.0 );
42  // These constructors should be used to instantiate a RandExponential
43  // distribution object defining a local engine for it.
44  // The static generator will be skipped using the non-static methods
45  // defined below.
46  // If the engine is passed by pointer the corresponding engine object
47  // will be deleted by the RandExponential destructor.
48  // If the engine is passed by reference the corresponding engine object
49  // will not be deleted by the RandExponential destructor.
50 
51  virtual ~RandExponential();
52  // Destructor
53 
54  // Static methods to shoot random values using the static generator
55 
56  static double shoot();
57 
58  static double shoot( double mean );
59 
60  static void shootArray ( const int size, double* vect,
61  double mean=1.0 );
62 
63  // Static methods to shoot random values using a given engine
64  // by-passing the static generator.
65 
66  static inline double shoot( HepRandomEngine* anEngine );
67 
68  static inline double shoot( HepRandomEngine* anEngine, double mean );
69 
70  static void shootArray ( HepRandomEngine* anEngine, const int size,
71  double* vect, double mean=1.0 );
72 
73  // Methods using the localEngine to shoot random values, by-passing
74  // the static generator.
75 
76  inline double fire();
77 
78  inline double fire( double mean );
79 
80  void fireArray ( const int size, double* vect );
81  void fireArray ( const int size, double* vect, double mean );
82 
83  double operator()();
84  double operator()( double mean );
85 
86  // Save and restore to/from streams
87 
88  std::ostream & put ( std::ostream & os ) const;
89  std::istream & get ( std::istream & is );
90 
91  std::string name() const;
93 
94  static std::string distributionName() {return "RandExponential";}
95  // Provides the name of this distribution class
96 
97 private:
98 
99  shared_ptr<HepRandomEngine> localEngine;
100  double defaultMean;
101 
102 };
103 
104 } // namespace CLHEP
105 
106 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
107 // backwards compatibility will be enabled ONLY in CLHEP 1.9
108 using namespace CLHEP;
109 #endif
110 
111 #include "CLHEP/Random/RandExponential.icc"
112 
113 #endif
double operator()(double mean)
static double shoot(double mean)
double fire(double mean)
void fireArray(const int size, double *vect, double mean)
static double shoot(HepRandomEngine *anEngine)
RandExponential(HepRandomEngine &anEngine, double mean=1.0)
static void shootArray(HepRandomEngine *anEngine, const int size, double *vect, double mean=1.0)
HepRandomEngine & engine()
std::istream & get(std::istream &is)
RandExponential(HepRandomEngine *anEngine, double mean=1.0)
static double shoot()
std::string name() const
std::ostream & put(std::ostream &os) const
void fireArray(const int size, double *vect)
static double shoot(HepRandomEngine *anEngine, double mean)
static void shootArray(const int size, double *vect, double mean=1.0)