CLHEP VERSION 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.5 2010/06/16 17:24:53 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 #include "CLHEP/Utility/memory.h"
00035 
00036 namespace CLHEP {
00037 
00042 class RandPoisson : public HepRandom {
00043 
00044 public:
00045 
00046   inline RandPoisson ( HepRandomEngine& anEngine, double a1=1.0 );
00047   inline RandPoisson ( HepRandomEngine* anEngine, double a1=1.0 );
00048   // These constructors should be used to instantiate a RandPoisson
00049   // distribution object defining a local engine for it.
00050   // The static generator will be skipped using the non-static methods
00051   // defined below.
00052   // If the engine is passed by pointer the corresponding engine object
00053   // will be deleted by the RandPoisson destructor.
00054   // If the engine is passed by reference the corresponding engine object
00055   // will not be deleted by the RandPoisson destructor.
00056 
00057   virtual ~RandPoisson();
00058   // Destructor
00059 
00060   // Save and restore to/from streams
00061   
00062   std::ostream & put ( std::ostream & os ) const;
00063   std::istream & get ( std::istream & is );
00064 
00065   // Static methods to shoot random values using the static generator
00066 
00067   static  long shoot( double m=1.0 );
00068 
00069   static  void shootArray ( const int size, long* vect, double m=1.0 );
00070 
00071   //  Static methods to shoot random values using a given engine
00072   //  by-passing the static generator.
00073 
00074   static  long shoot( HepRandomEngine* anEngine, double m=1.0 );
00075 
00076   static  void shootArray ( HepRandomEngine* anEngine,
00077                             const int size, long* vect, double m=1.0 );
00078 
00079   //  Methods using the localEngine to shoot random values, by-passing
00080   //  the static generator.
00081 
00082   long  fire();
00083   long  fire( double m );
00084 
00085   void fireArray ( const int size, long* vect );
00086   void fireArray ( const int size, long* vect, double m);
00087 
00088   double operator()();
00089   double operator()( double m );
00090   
00091   std::string name() const;
00092   HepRandomEngine & engine();
00093 
00094   static std::string distributionName() {return "RandPoisson";}  
00095   // Provides the name of this distribution class
00096 
00097 protected:
00098 
00099   double meanMax;
00100   double defaultMean;
00101 
00102   static  double getOldMean() {return oldm_st;}
00103 
00104   static  double getMaxMean() {return meanMax_st;}
00105 
00106   static  void setOldMean( double val ){oldm_st = val;}
00107 
00108   static  double* getPStatus() {return status_st;}
00109 
00110   static void setPStatus(double sq, double alxm, double g1) {
00111     status_st[0] = sq; status_st[1] = alxm; status_st[2] = g1;
00112   }
00113 
00114   inline HepRandomEngine* getLocalEngine();
00115   
00116 private:
00117 
00118   shared_ptr<HepRandomEngine> localEngine;
00119   double status[3], oldm;
00120 
00121   // static data
00122   static double status_st[3];
00123   static double oldm_st;
00124   static const double meanMax_st;
00125 
00126 };
00127 
00128 }  // namespace CLHEP
00129 
00130 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00131 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00132 using namespace CLHEP;
00133 #endif
00134 
00135 #include "CLHEP/Random/RandPoisson.icc"
00136 
00137 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7