File indexing completed on 2025-10-31 08:58:58
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 
0014 
0015 
0016 
0017 
0018 
0019 
0020 
0021 
0022 
0023 
0024 
0025 
0026 
0027 
0028 
0029 #ifndef RandPoisson_h
0030 #define RandPoisson_h 1
0031 
0032 #include "CLHEP/Random/defs.h"
0033 #include "CLHEP/Random/Random.h"
0034 #include "CLHEP/Utility/memory.h"
0035 #include "CLHEP/Utility/thread_local.h"
0036 
0037 namespace CLHEP {
0038 
0039 
0040 
0041 
0042 
0043 class RandPoisson : public HepRandom {
0044 
0045 public:
0046 
0047   inline RandPoisson ( HepRandomEngine& anEngine, double a1=1.0 );
0048   inline RandPoisson ( HepRandomEngine* anEngine, double a1=1.0 );
0049   
0050   
0051   
0052   
0053   
0054   
0055   
0056   
0057 
0058   virtual ~RandPoisson();
0059   
0060 
0061   
0062   
0063   std::ostream & put ( std::ostream & os ) const;
0064   std::istream & get ( std::istream & is );
0065 
0066   
0067 
0068   static  long shoot( double mean=1.0 );
0069 
0070   static  void shootArray ( const int size, long* vect, double mean=1.0 );
0071 
0072   
0073   
0074 
0075   static  long shoot( HepRandomEngine* anEngine, double mean=1.0 );
0076 
0077   static  void shootArray ( HepRandomEngine* anEngine,
0078                             const int size, long* vect, double mean=1.0 );
0079 
0080   
0081   
0082 
0083   long  fire();
0084   long  fire( double mean );
0085 
0086   void fireArray ( const int size, long* vect );
0087   void fireArray ( const int size, long* vect, double mean);
0088 
0089   double operator()();
0090   double operator()( double mean );
0091   
0092   std::string name() const;
0093   HepRandomEngine & engine();
0094 
0095   static std::string distributionName() {return "RandPoisson";}  
0096   
0097 
0098 protected:
0099 
0100   double meanMax;
0101   double defaultMean;
0102 
0103   static  double getOldMean() {return oldm_st;}
0104 
0105   static  double getMaxMean() {return meanMax_st;}
0106 
0107   static  void setOldMean( double val ){oldm_st = val;}
0108 
0109   static  double* getPStatus() {return status_st;}
0110 
0111   static void setPStatus(double sq, double alxm, double g1) {
0112     status_st[0] = sq; status_st[1] = alxm; status_st[2] = g1;
0113   }
0114 
0115   inline HepRandomEngine* getLocalEngine();
0116   
0117 private:
0118 
0119   std::shared_ptr<HepRandomEngine> localEngine;
0120   double status[3], oldm;
0121 
0122   
0123   static CLHEP_THREAD_LOCAL double status_st[3];
0124   static CLHEP_THREAD_LOCAL double oldm_st;
0125   static const double meanMax_st;
0126 
0127 };
0128 
0129 }  
0130 
0131 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0132 
0133 using namespace CLHEP;
0134 #endif
0135 
0136 #include "CLHEP/Random/RandPoisson.icc"
0137 
0138 #endif