CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandPoisson.h

Go to the documentation of this file.
00001 // $Id: RandPoisson.h,v 1.3.4.1 2005/03/18 22:26:48 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                         --- RandPoisson ---
00007 //                          class header file
00008 // -----------------------------------------------------------------------
00009 // This file is part of Geant4 (simulation toolkit for HEP).
00010 
00011 // Class defining methods for shooting numbers according to the Poisson
00012 // distribution, given a mean (Algorithm taken from "W.H.Press et al.,
00013 // Numerical Recipes in C, Second Edition".
00014 // Default mean value is set to 1, value used for operator()().
00015 
00016 // =======================================================================
00017 // Gabriele Cosmo - Created: 5th September 1995
00018 //                - Added not static Shoot() method: 17th May 1996
00019 //                - Algorithm now operates on doubles : 31st Oct 1996
00020 //                - Added methods to shoot arrays: 28th July 1997
00021 // J.Marraffino   - Added default mean as attribute and
00022 //                  operator() with mean: 16th Feb 1998
00023 // Gabriele Cosmo - Relocated static data from HepRandom: 5th Jan 1999
00024 // M. Fischler    - Moved meanMax and defaultMean from private to protected
00025 //                  to accomodate derived classes RandPoissonQ & RandPoissonT
00026 // M Fischler      - put and get to/from streams 12/10/04
00027 // =======================================================================
00028 
00029 #ifndef RandPoisson_h
00030 #define RandPoisson_h 1
00031 
00032 #include "CLHEP/Random/defs.h"
00033 #include "CLHEP/Random/Random.h"
00034 
00035 namespace CLHEP {
00036 
00041 class RandPoisson : public HepRandom {
00042 
00043 public:
00044 
00045   inline RandPoisson ( HepRandomEngine& anEngine, double m=1.0 );
00046   inline RandPoisson ( HepRandomEngine* anEngine, double m=1.0 );
00047   // These constructors should be used to instantiate a RandPoisson
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 RandPoisson destructor.
00053   // If the engine is passed by reference the corresponding engine object
00054   // will not be deleted by the RandPoisson destructor.
00055 
00056   virtual ~RandPoisson();
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 "RandPoisson";}  
00094   // Provides the name of this distribution class
00095 
00096 protected:
00097 
00098   // Protected copy constructor. Defining it here disallows user use.
00099   RandPoisson(const RandPoisson& d);
00100 
00101   double meanMax;
00102   double defaultMean;
00103 
00104   static  double getOldMean() {return oldm_st;}
00105 
00106   static  double getMaxMean() {return meanMax_st;}
00107 
00108   static  void setOldMean( double val ){oldm_st = val;}
00109 
00110   static  double* getPStatus() {return status_st;}
00111 
00112   static void setPStatus(double sq, double alxm, double g) {
00113     status_st[0] = sq; status_st[1] = alxm; status_st[2] = g;
00114   }
00115 
00116   inline HepRandomEngine* getLocalEngine();
00117   
00118 private:
00119 
00120   HepRandomEngine* localEngine;
00121   bool deleteEngine;
00122   double status[3], oldm;
00123 
00124   // static data
00125   static double status_st[3];
00126   static double oldm_st;
00127   static const double meanMax_st;
00128 
00129 };
00130 
00131 }  // namespace CLHEP
00132 
00133 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00134 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00135 using namespace CLHEP;
00136 #endif
00137 
00138 #include "CLHEP/Random/RandPoisson.icc"
00139 
00140 #endif

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7