CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandGamma.h

Go to the documentation of this file.
00001 // $Id: RandGamma.h,v 1.3.4.1 2005/03/18 22:26:48 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                          --- RandGamma ---
00007 //                          class header file
00008 // -----------------------------------------------------------------------
00009 
00010 // Class defining methods for shooting gamma distributed random values,
00011 // given a k (default=1) and specifying also a lambda (default=1).
00012 // Default values are used for operator()().
00013 
00014 // Valid input values are k > 0 and lambda > 0.  When invalid values are
00015 // presented, the code silently returns -1.0.
00016 
00017 // =======================================================================
00018 // John Marraffino - Created: 12th May 1998  Based on the C-Rand package
00019 //                   by Ernst Stadlober and Franz Niederl of the Technical
00020 //                   University of Graz, Austria.
00021 // Gabriele Cosmo  - Removed useless methods and data: 5th Jan 1999
00022 // M Fischler      - put and get to/from streams 12/10/04
00023 // =======================================================================
00024 
00025 #ifndef RandGamma_h
00026 #define RandGamma_h 1
00027 
00028 #include "CLHEP/Random/defs.h"
00029 #include "CLHEP/Random/Random.h"
00030 
00031 namespace CLHEP {
00032 
00037 class RandGamma : public HepRandom {
00038 
00039 public:
00040 
00041   inline RandGamma ( HepRandomEngine& anEngine, double k=1.0,
00042                                                 double lambda=1.0 );
00043   inline RandGamma ( HepRandomEngine* anEngine, double k=1.0, 
00044                                                 double lambda=1.0 );
00045   // These constructors should be used to instantiate a RandGamma
00046   // distribution object defining a local engine for it.
00047   // The static generator will be skipped using the non-static methods
00048   // defined below.
00049   // If the engine is passed by pointer the corresponding engine object
00050   // will be deleted by the RandGamma destructor.
00051   // If the engine is passed by reference the corresponding engine object
00052   // will not be deleted by the RandGamma destructor.
00053 
00054   virtual ~RandGamma();
00055   // Destructor
00056 
00057   // Static methods to shoot random values using the static generator
00058 
00059   static inline double shoot();
00060 
00061   static double shoot( double k, double lambda );
00062 
00063   static void shootArray ( const int size, double* vect,
00064                             double k=1.0, double lambda=1.0 );
00065 
00066   //  Static methods to shoot random values using a given engine
00067   //  by-passing the static generator.
00068 
00069   static inline double shoot( HepRandomEngine* anEngine );
00070 
00071   static double shoot( HepRandomEngine* anEngine, 
00072                                   double k, double lambda );
00073 
00074   static void shootArray ( HepRandomEngine* anEngine, const int size,
00075                             double* vect, double k=1.0,
00076                             double lambda=1.0 );
00077 
00078   //  Methods using the localEngine to shoot random values, by-passing
00079   //  the static generator.
00080 
00081   inline double fire();
00082 
00083   double fire( double k, double lambda );
00084   
00085   void fireArray ( const int size, double* vect);
00086   void fireArray ( const int size, double* vect,
00087                    double k, double lambda );
00088   inline double operator()();
00089   inline double operator()( double k, double lambda );
00090 
00091   // Save and restore to/from streams
00092   
00093   std::ostream & put ( std::ostream & os ) const;
00094   std::istream & get ( std::istream & is );
00095 
00096   std::string name() const;
00097   HepRandomEngine & engine();
00098 
00099   static std::string distributionName() {return "RandGamma";}  
00100   // Provides the name of this distribution class
00101   
00102 
00103 private:
00104 
00105   // Private copy constructor. Defining it here disallows use.
00106   RandGamma(const RandGamma& d);
00107 
00108   static double genGamma( HepRandomEngine *anEngine, double k,
00109                                                         double lambda );
00110 
00111   HepRandomEngine* localEngine;
00112   bool deleteEngine;
00113   double defaultK;
00114   double defaultLambda;
00115 
00116 };
00117 
00118 }  // namespace CLHEP
00119 
00120 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00121 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00122 using namespace CLHEP;
00123 #endif
00124 
00125 #include "CLHEP/Random/RandGamma.icc"
00126 
00127 #endif

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7