CLHEP VERSION 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.5 2010/06/16 17:24:53 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 #include "CLHEP/Utility/memory.h"
00031 
00032 namespace CLHEP {
00033 
00038 class RandGamma : public HepRandom {
00039 
00040 public:
00041 
00042   inline RandGamma ( HepRandomEngine& anEngine, double k=1.0,
00043                                                 double lambda=1.0 );
00044   inline RandGamma ( HepRandomEngine* anEngine, double k=1.0, 
00045                                                 double lambda=1.0 );
00046   // These constructors should be used to instantiate a RandGamma
00047   // distribution object defining a local engine for it.
00048   // The static generator will be skipped using the non-static methods
00049   // defined below.
00050   // If the engine is passed by pointer the corresponding engine object
00051   // will be deleted by the RandGamma destructor.
00052   // If the engine is passed by reference the corresponding engine object
00053   // will not be deleted by the RandGamma destructor.
00054 
00055   virtual ~RandGamma();
00056   // Destructor
00057 
00058   // Static methods to shoot random values using the static generator
00059 
00060   static inline double shoot();
00061 
00062   static double shoot( double k, double lambda );
00063 
00064   static void shootArray ( const int size, double* vect,
00065                             double k=1.0, double lambda=1.0 );
00066 
00067   //  Static methods to shoot random values using a given engine
00068   //  by-passing the static generator.
00069 
00070   static inline double shoot( HepRandomEngine* anEngine );
00071 
00072   static double shoot( HepRandomEngine* anEngine, 
00073                                   double k, double lambda );
00074 
00075   static void shootArray ( HepRandomEngine* anEngine, const int size,
00076                             double* vect, double k=1.0,
00077                             double lambda=1.0 );
00078 
00079   //  Methods using the localEngine to shoot random values, by-passing
00080   //  the static generator.
00081 
00082   inline double fire();
00083 
00084   double fire( double k, double lambda );
00085   
00086   void fireArray ( const int size, double* vect);
00087   void fireArray ( const int size, double* vect,
00088                    double k, double lambda );
00089   inline double operator()();
00090   inline double operator()( double k, double lambda );
00091 
00092   // Save and restore to/from streams
00093   
00094   std::ostream & put ( std::ostream & os ) const;
00095   std::istream & get ( std::istream & is );
00096 
00097   std::string name() const;
00098   HepRandomEngine & engine();
00099 
00100   static std::string distributionName() {return "RandGamma";}  
00101   // Provides the name of this distribution class
00102   
00103 
00104 private:
00105 
00106   static double genGamma( HepRandomEngine *anEngine, double k,
00107                                                         double lambda );
00108 
00109   shared_ptr<HepRandomEngine> localEngine;
00110   double defaultK;
00111   double defaultLambda;
00112 
00113 };
00114 
00115 }  // namespace CLHEP
00116 
00117 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00118 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00119 using namespace CLHEP;
00120 #endif
00121 
00122 #include "CLHEP/Random/RandGamma.icc"
00123 
00124 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7