CLHEP/Random/RandGamma.h

00001 // $Id: RandGamma.h,v 1.8 2002/04/12 15:02:44 evc 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 // =======================================================================
00023 
00024 #ifndef RandGamma_h
00025 #define RandGamma_h 1
00026 
00027 #include "CLHEP/Random/Random.h"
00028 
00033 class RandGamma : public HepRandom {
00034 
00035 public:
00036 
00037   inline RandGamma ( HepRandomEngine& anEngine, double k=1.0,
00038                                                 double lambda=1.0 );
00039   inline RandGamma ( HepRandomEngine* anEngine, double k=1.0, 
00040                                                 double lambda=1.0 );
00041   // These constructors should be used to instantiate a RandGamma
00042   // distribution object defining a local engine for it.
00043   // The static generator will be skipped using the non-static methods
00044   // defined below.
00045   // If the engine is passed by pointer the corresponding engine object
00046   // will be deleted by the RandGamma destructor.
00047   // If the engine is passed by reference the corresponding engine object
00048   // will not be deleted by the RandGamma destructor.
00049 
00050   virtual ~RandGamma();
00051   // Destructor
00052 
00053   // Static methods to shoot random values using the static generator
00054 
00055   static inline double shoot();
00056 
00057   static double shoot( double k, double lambda );
00058 
00059   static void shootArray ( const int size, double* vect,
00060                             double k=1.0, double lambda=1.0 );
00061 
00062   //  Static methods to shoot random values using a given engine
00063   //  by-passing the static generator.
00064 
00065   static inline double shoot( HepRandomEngine* anEngine );
00066 
00067   static double shoot( HepRandomEngine* anEngine, 
00068                                   double k, double lambda );
00069 
00070   static void shootArray ( HepRandomEngine* anEngine, const int size,
00071                             double* vect, double k=1.0,
00072                             double lambda=1.0 );
00073 
00074   //  Methods using the localEngine to shoot random values, by-passing
00075   //  the static generator.
00076 
00077   inline double fire();
00078 
00079   double fire( double k, double lambda );
00080   
00081   void fireArray ( const int size, double* vect);
00082   void fireArray ( const int size, double* vect,
00083                    double k, double lambda );
00084   inline double operator()();
00085   inline double operator()( double k, double lambda );
00086 
00087 private:
00088 
00089   // Private copy constructor. Defining it here disallows use.
00090   RandGamma(const RandGamma& d);
00091 
00092   static double genGamma( HepRandomEngine *anEngine, double k,
00093                                                         double lambda );
00094 
00095   HepRandomEngine* localEngine;
00096   bool deleteEngine;
00097   const double defaultK;
00098   const double defaultLambda;
00099 
00100 };
00101 
00102 #include "CLHEP/Random/RandGamma.icc"
00103 
00104 #endif

Class Library for High Energy Physics (version 1.8)