Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RandExponential.h
Go to the documentation of this file.
1 // $Id:$
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/Random.h"
27 #include "CLHEP/Utility/memory.h"
28 
29 namespace CLHEP {
30 
35 class RandExponential : public HepRandom {
36 
37 public:
38 
39  inline RandExponential ( HepRandomEngine& anEngine, double mean=1.0 );
40  inline RandExponential ( HepRandomEngine* anEngine, double mean=1.0 );
41  // These constructors should be used to instantiate a RandExponential
42  // distribution object defining a local engine for it.
43  // The static generator will be skipped using the non-static methods
44  // defined below.
45  // If the engine is passed by pointer the corresponding engine object
46  // will be deleted by the RandExponential destructor.
47  // If the engine is passed by reference the corresponding engine object
48  // will not be deleted by the RandExponential destructor.
49 
50  virtual ~RandExponential();
51  // Destructor
52 
53  // Static methods to shoot random values using the static generator
54 
55  static double shoot();
56 
57  static double shoot( double mean );
58 
59  static void shootArray ( const int size, double* vect,
60  double mean=1.0 );
61 
62  // Static methods to shoot random values using a given engine
63  // by-passing the static generator.
64 
65  static inline double shoot( HepRandomEngine* anEngine );
66 
67  static inline double shoot( HepRandomEngine* anEngine, double mean );
68 
69  static void shootArray ( HepRandomEngine* anEngine, const int size,
70  double* vect, double mean=1.0 );
71 
72  // Methods using the localEngine to shoot random values, by-passing
73  // the static generator.
74 
75  inline double fire();
76 
77  inline double fire( double mean );
78 
79  void fireArray ( const int size, double* vect );
80  void fireArray ( const int size, double* vect, double mean );
81 
82  double operator()();
83  double operator()( double mean );
84 
85  // Save and restore to/from streams
86 
87  std::ostream & put ( std::ostream & os ) const;
88  std::istream & get ( std::istream & is );
89 
90  std::string name() const;
92 
93  static std::string distributionName() {return "RandExponential";}
94  // Provides the name of this distribution class
95 
96 private:
97 
98  std::shared_ptr<HepRandomEngine> localEngine;
99  double defaultMean;
100 
101 };
102 
103 } // namespace CLHEP
104 
105 #include "CLHEP/Random/RandExponential.icc"
106 
107 #endif
HepRandomEngine & engine()
RandExponential(HepRandomEngine &anEngine, double mean=1.0)
static std::string distributionName()
std::string name() const
static void shootArray(const int size, double *vect, double mean=1.0)
void fireArray(const int size, double *vect)
std::ostream & put(std::ostream &os) const