CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // $Id: RandPoissonT.h,v 1.5 2010/06/16 17:24:53 garren Exp $ 00002 // -*- C++ -*- 00003 // 00004 // ----------------------------------------------------------------------- 00005 // HEP Random 00006 // --- RandPoissonT --- 00007 // class header file 00008 // ----------------------------------------------------------------------- 00009 00010 // Class defining methods for shooting numbers according to the Poisson 00011 // distribution, given a mean. RandPoissonT is derived from RandPoisson 00012 // and shares the identical user interface. RandPoissonT is always 00013 // perfectly accurate for any value of mu. 00014 00015 // For mu > 100 the algorithm used is taken from the base class RandPoisson 00016 // (Algorithm from "W.H.Press et al., Numerical Recipes in C, Second Edition".) 00017 // 00018 // For mu < 100, algorithm used is a table lookup based on [mu/K] for some 00019 // smallish K, followed by an explicit series-drived poisson for the small 00020 // remaining part of mu. This method is exact, and is substantially faster 00021 // than the method used by the base class. The implementation of this method 00022 // is in the RandPoissonQ class. 00023 00024 // ======================================================================= 00025 // M. Fischler - Created 26 Jan 2000 00026 // M Fischler - put and get to/from streams 12/10/04 00027 // ======================================================================= 00028 00029 #ifndef RandPoissonT_h 00030 #define RandPoissonT_h 1 00031 00032 #include "CLHEP/Random/defs.h" 00033 #include "CLHEP/Random/RandPoisson.h" 00034 00035 namespace CLHEP { 00036 00041 class RandPoissonT : public RandPoisson { 00042 00043 public: 00044 00045 RandPoissonT ( HepRandomEngine& anEngine, double m=1.0 ); 00046 RandPoissonT ( HepRandomEngine* anEngine, double m=1.0 ); 00047 // These constructors should be used to instantiate a RandPoissonT 00048 // distribution object defining a local engine for it. 00049 // The static generator will be skipped using the non-static methods 00050 // defined below. 00051 // If the engine is passed by pointer the corresponding engine object 00052 // will be deleted by the RandPoissonT destructor. 00053 // If the engine is passed by reference the corresponding engine object 00054 // will not be deleted by the RandPoissonT destructor. 00055 00056 virtual ~RandPoissonT(); 00057 // Destructor 00058 00059 // Save and restore to/from streams 00060 00061 std::ostream & put ( std::ostream & os ) const; 00062 std::istream & get ( std::istream & is ); 00063 00064 // Static methods to shoot random values using the static generator 00065 00066 static long shoot( double m=1.0 ); 00067 00068 static void shootArray ( const int size, long* vect, double m=1.0 ); 00069 00070 // Static methods to shoot random values using a given engine 00071 // by-passing the static generator. 00072 00073 static long shoot( HepRandomEngine* anEngine, double m=1.0 ); 00074 00075 static void shootArray ( HepRandomEngine* anEngine, 00076 const int size, long* vect, double m=1.0 ); 00077 00078 // Methods using the localEngine to shoot random values, by-passing 00079 // the static generator. 00080 00081 long fire(); 00082 long fire( double m ); 00083 00084 void fireArray ( const int size, long* vect ); 00085 void fireArray ( const int size, long* vect, double m); 00086 00087 double operator()(); 00088 double operator()( double m ); 00089 00090 std::string name() const; 00091 HepRandomEngine & engine(); 00092 00093 static std::string distributionName() {return "RandPoissonT";} 00094 // Provides the name of this distribution class 00095 00096 00097 private: 00098 00099 }; 00100 00101 } // namespace CLHEP 00102 00103 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 00104 // backwards compatibility will be enabled ONLY in CLHEP 1.9 00105 using namespace CLHEP; 00106 #endif 00107 00108 #include "CLHEP/Random/RandPoissonT.icc" 00109 00110 #endif