00001 // $Id: RandPoissonT.h,v 1.5 2002/04/12 15:02:45 evc 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 // ======================================================================= 00027 00028 #ifndef RandPoissonT_h 00029 #define RandPoissonT_h 1 00030 00031 #include "CLHEP/Random/RandPoisson.h" 00032 00037 class RandPoissonT : public RandPoisson { 00038 00039 public: 00040 00041 RandPoissonT ( HepRandomEngine& anEngine, double m=1.0 ); 00042 RandPoissonT ( HepRandomEngine* anEngine, double m=1.0 ); 00043 // These constructors should be used to instantiate a RandPoissonT 00044 // distribution object defining a local engine for it. 00045 // The static generator will be skipped using the non-static methods 00046 // defined below. 00047 // If the engine is passed by pointer the corresponding engine object 00048 // will be deleted by the RandPoissonT destructor. 00049 // If the engine is passed by reference the corresponding engine object 00050 // will not be deleted by the RandPoissonT destructor. 00051 00052 virtual ~RandPoissonT(); 00053 // Destructor 00054 00055 // Static methods to shoot random values using the static generator 00056 00057 static long shoot( double m=1.0 ); 00058 00059 static void shootArray ( const int size, long* vect, double m=1.0 ); 00060 00061 // Static methods to shoot random values using a given engine 00062 // by-passing the static generator. 00063 00064 static long shoot( HepRandomEngine* anEngine, double m=1.0 ); 00065 00066 static void shootArray ( HepRandomEngine* anEngine, 00067 const int size, long* vect, double m=1.0 ); 00068 00069 // Methods using the localEngine to shoot random values, by-passing 00070 // the static generator. 00071 00072 long fire(); 00073 long fire( double m ); 00074 00075 void fireArray ( const int size, long* vect ); 00076 void fireArray ( const int size, long* vect, double m); 00077 00078 double operator()(); 00079 double operator()( double m ); 00080 00081 private: 00082 00083 // Private copy constructor. Defining it here disallows use. 00084 RandPoissonT(const RandPoissonT& d); 00085 00086 }; 00087 00088 #include "CLHEP/Random/RandPoissonT.icc" 00089 00090 #endif