|
||||
File indexing completed on 2025-01-18 09:54:38
0001 // $Id: RandPoissonT.h,v 1.5 2010/06/16 17:24:53 garren Exp $ 0002 // -*- C++ -*- 0003 // 0004 // ----------------------------------------------------------------------- 0005 // HEP Random 0006 // --- RandPoissonT --- 0007 // class header file 0008 // ----------------------------------------------------------------------- 0009 0010 // Class defining methods for shooting numbers according to the Poisson 0011 // distribution, given a mean. RandPoissonT is derived from RandPoisson 0012 // and shares the identical user interface. RandPoissonT is always 0013 // perfectly accurate for any value of mu. 0014 0015 // For mu > 100 the algorithm used is taken from the base class RandPoisson 0016 // (Algorithm from "W.H.Press et al., Numerical Recipes in C, Second Edition".) 0017 // 0018 // For mu < 100, algorithm used is a table lookup based on [mu/K] for some 0019 // smallish K, followed by an explicit series-drived poisson for the small 0020 // remaining part of mu. This method is exact, and is substantially faster 0021 // than the method used by the base class. The implementation of this method 0022 // is in the RandPoissonQ class. 0023 0024 // ======================================================================= 0025 // M. Fischler - Created 26 Jan 2000 0026 // M. Fischler - put and get to/from streams 12/10/04 0027 // ======================================================================= 0028 0029 #ifndef RandPoissonT_h 0030 #define RandPoissonT_h 1 0031 0032 #include "CLHEP/Random/defs.h" 0033 #include "CLHEP/Random/RandPoisson.h" 0034 0035 namespace CLHEP { 0036 0037 /** 0038 * @author 0039 * @ingroup random 0040 */ 0041 class RandPoissonT : public RandPoisson { 0042 0043 public: 0044 0045 RandPoissonT ( HepRandomEngine& anEngine, double mean=1.0 ); 0046 RandPoissonT ( HepRandomEngine* anEngine, double mean=1.0 ); 0047 // These constructors should be used to instantiate a RandPoissonT 0048 // distribution object defining a local engine for it. 0049 // The static generator will be skipped using the non-static methods 0050 // defined below. 0051 // If the engine is passed by pointer the corresponding engine object 0052 // will be deleted by the RandPoissonT destructor. 0053 // If the engine is passed by reference the corresponding engine object 0054 // will not be deleted by the RandPoissonT destructor. 0055 0056 virtual ~RandPoissonT(); 0057 // Destructor 0058 0059 // Save and restore to/from streams 0060 0061 std::ostream & put ( std::ostream & os ) const; 0062 std::istream & get ( std::istream & is ); 0063 0064 // Static methods to shoot random values using the static generator 0065 0066 static long shoot( double mean=1.0 ); 0067 0068 static void shootArray ( const int size, long* vect, double mean=1.0 ); 0069 0070 // Static methods to shoot random values using a given engine 0071 // by-passing the static generator. 0072 0073 static long shoot( HepRandomEngine* anEngine, double mean=1.0 ); 0074 0075 static void shootArray ( HepRandomEngine* anEngine, 0076 const int size, long* vect, double mean=1.0 ); 0077 0078 // Methods using the localEngine to shoot random values, by-passing 0079 // the static generator. 0080 0081 long fire(); 0082 long fire( double m ); 0083 0084 void fireArray ( const int size, long* vect ); 0085 void fireArray ( const int size, long* vect, double mean); 0086 0087 double operator()(); 0088 double operator()( double mean ); 0089 0090 std::string name() const; 0091 HepRandomEngine & engine(); 0092 0093 static std::string distributionName() {return "RandPoissonT";} 0094 // Provides the name of this distribution class 0095 0096 0097 private: 0098 0099 }; 0100 0101 } // namespace CLHEP 0102 0103 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 0104 // backwards compatibility will be enabled ONLY in CLHEP 1.9 0105 using namespace CLHEP; 0106 #endif 0107 0108 #include "CLHEP/Random/RandPoissonT.icc" 0109 0110 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |