Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CLHEP::RandPoissonQ Class Reference

#include <RandPoissonQ.h>

Inheritance diagram for CLHEP::RandPoissonQ:
Collaboration diagram for CLHEP::RandPoissonQ:

Public Member Functions

 RandPoissonQ (HepRandomEngine &anEngine, double b1=1.0)
 
 RandPoissonQ (HepRandomEngine *anEngine, double b1=1.0)
 
virtual ~RandPoissonQ ()
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
long fire ()
 
long fire (double m)
 
void fireArray (const int size, long *vect)
 
void fireArray (const int size, long *vect, double m)
 
double operator() ()
 
double operator() (double m)
 
std::string name () const
 
HepRandomEngineengine ()
 
- Public Member Functions inherited from CLHEP::RandPoisson
 RandPoisson (HepRandomEngine &anEngine, double a1=1.0)
 
 RandPoisson (HepRandomEngine *anEngine, double a1=1.0)
 
virtual ~RandPoisson ()
 
long fire ()
 
long fire (double m)
 
void fireArray (const int size, long *vect)
 
void fireArray (const int size, long *vect, double m)
 
double operator() (double m)
 
- Public Member Functions inherited from CLHEP::HepRandom
 HepRandom ()
 
 HepRandom (long seed)
 
 HepRandom (HepRandomEngine &algorithm)
 
 HepRandom (HepRandomEngine *algorithm)
 
virtual ~HepRandom ()
 
double flat ()
 
void flatArray (const int size, double *vect)
 
double flat (HepRandomEngine *theNewEngine)
 
void flatArray (HepRandomEngine *theNewEngine, const int size, double *vect)
 

Static Public Member Functions

static long shoot (double m=1.0)
 
static void shootArray (const int size, long *vect, double m=1.0)
 
static long shoot (HepRandomEngine *anEngine, double m=1.0)
 
static void shootArray (HepRandomEngine *anEngine, const int size, long *vect, double m=1.0)
 
static std::string distributionName ()
 
static int tableBoundary ()
 
- Static Public Member Functions inherited from CLHEP::RandPoisson
static long shoot (double m=1.0)
 
static void shootArray (const int size, long *vect, double m=1.0)
 
static long shoot (HepRandomEngine *anEngine, double m=1.0)
 
static void shootArray (HepRandomEngine *anEngine, const int size, long *vect, double m=1.0)
 
static std::string distributionName ()
 
- Static Public Member Functions inherited from CLHEP::HepRandom
static void setTheSeed (long seed, int lux=3)
 
static long getTheSeed ()
 
static void setTheSeeds (const long *seeds, int aux=-1)
 
static const long * getTheSeeds ()
 
static void getTheTableSeeds (long *seeds, int index)
 
static HepRandomgetTheGenerator ()
 
static void setTheEngine (HepRandomEngine *theNewEngine)
 
static HepRandomEnginegetTheEngine ()
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::istream & restoreFullState (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static std::istream & restoreDistState (std::istream &is)
 
static std::ostream & saveStaticRandomStates (std::ostream &os)
 
static std::istream & restoreStaticRandomStates (std::istream &is)
 
static void showEngineStatus ()
 
static int createInstance ()
 
static std::string distributionName ()
 

Static Public Attributes

static const double MAXIMUM_POISSON_DEVIATE = 2.0E9
 

Additional Inherited Members

- Protected Member Functions inherited from CLHEP::RandPoisson
HepRandomEnginegetLocalEngine ()
 
- Static Protected Member Functions inherited from CLHEP::RandPoisson
static double getOldMean ()
 
static double getMaxMean ()
 
static void setOldMean (double val)
 
static double * getPStatus ()
 
static void setPStatus (double sq, double alxm, double g1)
 
- Protected Attributes inherited from CLHEP::RandPoisson
double meanMax
 
double defaultMean
 
- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Author

Definition at line 32 of file RandPoissonQ.h.

Constructor & Destructor Documentation

CLHEP::RandPoissonQ::RandPoissonQ ( HepRandomEngine anEngine,
double  b1 = 1.0 
)
inline
CLHEP::RandPoissonQ::RandPoissonQ ( HepRandomEngine anEngine,
double  b1 = 1.0 
)
inline
CLHEP::RandPoissonQ::~RandPoissonQ ( )
virtual

Definition at line 80 of file RandPoissonQ.cc.

80  {
81 }

Member Function Documentation

static std::string CLHEP::RandPoissonQ::distributionName ( )
inlinestatic

Definition at line 102 of file RandPoissonQ.h.

102 {return "RandPoissonQ";}
HepRandomEngine & CLHEP::RandPoissonQ::engine ( )
virtual

Reimplemented from CLHEP::RandPoisson.

Definition at line 50 of file RandPoissonQ.cc.

50 {return RandPoisson::engine();}
HepRandomEngine & engine()
Definition: RandPoisson.cc:36

Here is the call graph for this function:

long CLHEP::RandPoissonQ::fire ( )

Definition at line 133 of file RandPoissonQ.cc.

133  {
134  if ( defaultMean < LAST_MU + S ) {
135  return poissonDeviateSmall ( getLocalEngine(), defaultMean );
136  } else {
137  return poissonDeviateQuick ( getLocalEngine(), a0, a1, a2, sigma );
138  }
139 } // fire()
const G4double a0
double S(double temp)
HepRandomEngine * getLocalEngine()

Here is the call graph for this function:

Here is the caller graph for this function:

long CLHEP::RandPoissonQ::fire ( double  m)

Definition at line 129 of file RandPoissonQ.cc.

129  {
130  return shoot(getLocalEngine(), mean);
131 }
HepRandomEngine * getLocalEngine()
static long shoot(double m=1.0)

Here is the call graph for this function:

void CLHEP::RandPoissonQ::fireArray ( const int  size,
long *  vect 
)

Definition at line 185 of file RandPoissonQ.cc.

185  {
186  for( long* v = vect; v != vect + size; ++v )
187  *v = fire( defaultMean );
188 }

Here is the call graph for this function:

void CLHEP::RandPoissonQ::fireArray ( const int  size,
long *  vect,
double  m 
)

Definition at line 180 of file RandPoissonQ.cc.

180  {
181  for( long* v = vect; v != vect + size; ++v )
182  *v = fire( m );
183 }
static constexpr double m

Here is the call graph for this function:

std::istream & CLHEP::RandPoissonQ::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::RandPoisson.

Definition at line 572 of file RandPoissonQ.cc.

572  {
573  std::string inName;
574  is >> inName;
575  if (inName != name()) {
576  is.clear(std::ios::badbit | is.rdstate());
577  std::cerr << "Mismatch when expecting to read state of a "
578  << name() << " distribution\n"
579  << "Name found was " << inName
580  << "\nistream is left in the badbit state\n";
581  return is;
582  }
583  if (possibleKeywordInput(is, "Uvec", a0)) {
584  std::vector<unsigned long> t(2);
585  is >> a0 >> t[0] >> t[1]; a0 = DoubConv::longs2double(t);
586  is >> a1 >> t[0] >> t[1]; a1 = DoubConv::longs2double(t);
587  is >> a2 >> t[0] >> t[1]; a2 = DoubConv::longs2double(t);
588  is >> sigma >> t[0] >> t[1]; sigma = DoubConv::longs2double(t);
589  RandPoisson::get(is);
590  return is;
591  }
592  // is >> a0 encompassed by possibleKeywordInput
593  is >> a1 >> a2 >> sigma;
594  RandPoisson::get(is);
595  return is;
596 }
const G4double a0
std::string name() const
Definition: RandPoissonQ.cc:49
std::istream & get(std::istream &is)
Definition: RandPoisson.cc:302
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:167
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:114

Here is the call graph for this function:

std::string CLHEP::RandPoissonQ::name ( ) const
virtual

Reimplemented from CLHEP::RandPoisson.

Definition at line 49 of file RandPoissonQ.cc.

49 {return "RandPoissonQ";}

Here is the caller graph for this function:

double CLHEP::RandPoissonQ::operator() ( )
virtual

Reimplemented from CLHEP::RandPoisson.

Definition at line 121 of file RandPoissonQ.cc.

121  {
122  return (double) fire();
123 }

Here is the call graph for this function:

double CLHEP::RandPoissonQ::operator() ( double  m)

Definition at line 125 of file RandPoissonQ.cc.

125  {
126  return (double) fire(mean);
127 }

Here is the call graph for this function:

std::ostream & CLHEP::RandPoissonQ::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::RandPoisson.

Definition at line 545 of file RandPoissonQ.cc.

545  {
546  int pr=os.precision(20);
547  std::vector<unsigned long> t(2);
548  os << " " << name() << "\n";
549  os << "Uvec" << "\n";
550  t = DoubConv::dto2longs(a0);
551  os << a0 << " " << t[0] << " " << t[1] << "\n";
552  t = DoubConv::dto2longs(a1);
553  os << a1 << " " << t[0] << " " << t[1] << "\n";
554  t = DoubConv::dto2longs(a2);
555  os << a2 << " " << t[0] << " " << t[1] << "\n";
556  t = DoubConv::dto2longs(sigma);
557  os << sigma << " " << t[0] << " " << t[1] << "\n";
558  RandPoisson::put(os);
559  os.precision(pr);
560  return os;
561 #ifdef REMOVED
562  int pr=os.precision(20);
563  os << " " << name() << "\n";
564  os << a0 << " " << a1 << " " << a2 << "\n";
565  os << sigma << "\n";
566  RandPoisson::put(os);
567  os.precision(pr);
568  return os;
569 #endif
570 }
const G4double a0
std::string name() const
Definition: RandPoissonQ.cc:49
std::ostream & put(std::ostream &os) const
Definition: RandPoisson.cc:281
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:98

Here is the call graph for this function:

long CLHEP::RandPoissonQ::shoot ( double  m = 1.0)
static

Definition at line 117 of file RandPoissonQ.cc.

117  {
118  return shoot(getTheEngine(), xm);
119 }
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265
static long shoot(double m=1.0)

Here is the call graph for this function:

Here is the caller graph for this function:

long CLHEP::RandPoissonQ::shoot ( HepRandomEngine anEngine,
double  m = 1.0 
)
static

Definition at line 141 of file RandPoissonQ.cc.

141  {
142 
143  // The following variables, static to this method, apply to the
144  // last time a large mean was supplied; they obviate certain calculations
145  // if consecutive calls use the same mean.
146 
147  static CLHEP_THREAD_LOCAL double lastLargeMean = -1.; // Mean from previous shoot
148  // requiring poissonDeviateQuick()
149  static CLHEP_THREAD_LOCAL double lastA0;
150  static CLHEP_THREAD_LOCAL double lastA1;
151  static CLHEP_THREAD_LOCAL double lastA2;
152  static CLHEP_THREAD_LOCAL double lastSigma;
153 
154  if ( mean < LAST_MU + S ) {
155  return poissonDeviateSmall ( anEngine, mean );
156  } else {
157  if ( mean != lastLargeMean ) {
158  // Compute the coefficients defining the quadratic transformation from a
159  // Gaussian to a Poisson for this mean. Also save these for next time.
160  double sig2 = mean * (.9998654 - .08346/mean);
161  lastSigma = std::sqrt(sig2);
162  double t = 1./sig2;
163  lastA2 = t*(1./6.) + t*t*(1./324.);
164  lastA1 = std::sqrt (1-2*lastA2*lastA2*sig2);
165  lastA0 = mean + .5 - sig2 * lastA2;
166  }
167  return poissonDeviateQuick ( anEngine, lastA0, lastA1, lastA2, lastSigma );
168  }
169 
170 } // shoot (anEngine, mean)
double S(double temp)
#define CLHEP_THREAD_LOCAL
Definition: thread_local.h:25
void CLHEP::RandPoissonQ::shootArray ( const int  size,
long *  vect,
double  m = 1.0 
)
static

Definition at line 172 of file RandPoissonQ.cc.

172  {
173  for( long* v = vect; v != vect + size; ++v )
174  *v = shoot(m);
175  // Note: We could test for m > 100, and if it is, precompute a0, a1, a2,
176  // and sigma and call the appropriate form of poissonDeviateQuick.
177  // But since those are cached anyway, not much time would be saved.
178 }
static constexpr double m
static long shoot(double m=1.0)

Here is the call graph for this function:

static void CLHEP::RandPoissonQ::shootArray ( HepRandomEngine anEngine,
const int  size,
long *  vect,
double  m = 1.0 
)
static
static int CLHEP::RandPoissonQ::tableBoundary ( )
inlinestatic

Member Data Documentation

const double CLHEP::RandPoissonQ::MAXIMUM_POISSON_DEVIATE = 2.0E9
static

Definition at line 109 of file RandPoissonQ.h.


The documentation for this class was generated from the following files: