Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
CLHEP::RandPoissonQ Class Reference

#include <RandPoissonQ.h>

+ Inheritance 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 mean)
 
void fireArray (const int size, long *vect)
 
void fireArray (const int size, long *vect, double mean)
 
double operator() ()
 
double operator() (double mean)
 
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 mean)
 
void fireArray (const int size, long *vect)
 
void fireArray (const int size, long *vect, double mean)
 
double operator() (double mean)
 
- 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 mean=1.0)
 
static void shootArray (const int size, long *vect, double mean=1.0)
 
static long shoot (HepRandomEngine *anEngine, double mean=1.0)
 
static void shootArray (HepRandomEngine *anEngine, const int size, long *vect, double mean=1.0)
 
static std::string distributionName ()
 
static int tableBoundary ()
 
- Static Public Member Functions inherited from CLHEP::RandPoisson
static long shoot (double mean=1.0)
 
static void shootArray (const int size, long *vect, double mean=1.0)
 
static long shoot (HepRandomEngine *anEngine, double mean=1.0)
 
static void shootArray (HepRandomEngine *anEngine, const int size, long *vect, double mean=1.0)
 
static std::string distributionName ()
 
- Static Public Member Functions inherited from CLHEP::HepRandom
static void setTheSeed (long seed, int lxr=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 31 of file RandPoissonQ.h.

Constructor & Destructor Documentation

◆ RandPoissonQ() [1/2]

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

◆ RandPoissonQ() [2/2]

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

◆ ~RandPoissonQ()

CLHEP::RandPoissonQ::~RandPoissonQ ( )
virtual

Definition at line 82 of file RandPoissonQ.cc.

82 {
83}

Member Function Documentation

◆ distributionName()

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

Definition at line 101 of file RandPoissonQ.h.

101{return "RandPoissonQ";}

◆ engine()

HepRandomEngine & CLHEP::RandPoissonQ::engine ( )
virtual

Reimplemented from CLHEP::RandPoisson.

Definition at line 52 of file RandPoissonQ.cc.

52{return RandPoisson::engine();}
HepRandomEngine & engine()

◆ fire() [1/2]

long CLHEP::RandPoissonQ::fire ( )

Definition at line 135 of file RandPoissonQ.cc.

135 {
136 if ( defaultMean < LAST_MU + S ) {
137 return poissonDeviateSmall ( getLocalEngine(), defaultMean );
138 } else {
139 return poissonDeviateQuick ( getLocalEngine(), a0, a1, a2, sigma );
140 }
141} // fire()
HepRandomEngine * getLocalEngine()

Referenced by fireArray(), fireArray(), operator()(), and operator()().

◆ fire() [2/2]

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

Definition at line 131 of file RandPoissonQ.cc.

131 {
132 return shoot(getLocalEngine(), mean);
133}
static long shoot(double mean=1.0)

◆ fireArray() [1/2]

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

Definition at line 193 of file RandPoissonQ.cc.

193 {
194 for( long* v = vect; v != vect + size; ++v )
195 *v = fire( defaultMean );
196}

◆ fireArray() [2/2]

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

Definition at line 188 of file RandPoissonQ.cc.

188 {
189 for( long* v = vect; v != vect + size; ++v )
190 *v = fire( m );
191}

◆ get()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 580 of file RandPoissonQ.cc.

580 {
581 std::string inName;
582 is >> inName;
583 if (inName != name()) {
584 is.clear(std::ios::badbit | is.rdstate());
585 std::cerr << "Mismatch when expecting to read state of a "
586 << name() << " distribution\n"
587 << "Name found was " << inName
588 << "\nistream is left in the badbit state\n";
589 return is;
590 }
591 if (possibleKeywordInput(is, "Uvec", a0)) {
592 std::vector<unsigned long> t(2);
593 is >> a0 >> t[0] >> t[1]; a0 = DoubConv::longs2double(t);
594 is >> a1 >> t[0] >> t[1]; a1 = DoubConv::longs2double(t);
595 is >> a2 >> t[0] >> t[1]; a2 = DoubConv::longs2double(t);
596 is >> sigma >> t[0] >> t[1]; sigma = DoubConv::longs2double(t);
598 return is;
599 }
600 // is >> a0 encompassed by possibleKeywordInput
601 is >> a1 >> a2 >> sigma;
603 return is;
604}
static double longs2double(const std::vector< unsigned long > &v)
Definition DoubConv.cc:110
std::string name() const
std::istream & get(std::istream &is)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)

◆ name()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 51 of file RandPoissonQ.cc.

51{return "RandPoissonQ";}

Referenced by get(), and put().

◆ operator()() [1/2]

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 123 of file RandPoissonQ.cc.

123 {
124 return (double) fire();
125}

◆ operator()() [2/2]

double CLHEP::RandPoissonQ::operator() ( double mean)

Definition at line 127 of file RandPoissonQ.cc.

127 {
128 return (double) fire(mean);
129}

◆ put()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 553 of file RandPoissonQ.cc.

553 {
554 long pr=os.precision(20);
555 std::vector<unsigned long> t(2);
556 os << " " << name() << "\n";
557 os << "Uvec" << "\n";
558 t = DoubConv::dto2longs(a0);
559 os << a0 << " " << t[0] << " " << t[1] << "\n";
560 t = DoubConv::dto2longs(a1);
561 os << a1 << " " << t[0] << " " << t[1] << "\n";
562 t = DoubConv::dto2longs(a2);
563 os << a2 << " " << t[0] << " " << t[1] << "\n";
564 t = DoubConv::dto2longs(sigma);
565 os << sigma << " " << t[0] << " " << t[1] << "\n";
567 os.precision(pr);
568 return os;
569#ifdef REMOVED
570 int pr=os.precision(20);
571 os << " " << name() << "\n";
572 os << a0 << " " << a1 << " " << a2 << "\n";
573 os << sigma << "\n";
575 os.precision(pr);
576 return os;
577#endif
578}
static std::vector< unsigned long > dto2longs(double d)
Definition DoubConv.cc:94
std::ostream & put(std::ostream &os) const

◆ shoot() [1/2]

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

Definition at line 119 of file RandPoissonQ.cc.

119 {
120 return shoot(getTheEngine(), xm);
121}
static HepRandomEngine * getTheEngine()
Definition Random.cc:268

Referenced by fire(), shoot(), shootArray(), and shootArray().

◆ shoot() [2/2]

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

Definition at line 143 of file RandPoissonQ.cc.

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

◆ shootArray() [1/2]

void CLHEP::RandPoissonQ::shootArray ( const int size,
long * vect,
double mean = 1.0 )
static

Definition at line 174 of file RandPoissonQ.cc.

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

◆ shootArray() [2/2]

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

Definition at line 182 of file RandPoissonQ.cc.

183 {
184 for( long* v = vect; v != vect + size; ++v )
185 *v = shoot(anEngine,m1);
186}

◆ tableBoundary()

static int CLHEP::RandPoissonQ::tableBoundary ( )
inlinestatic

Member Data Documentation

◆ MAXIMUM_POISSON_DEVIATE

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

Definition at line 108 of file RandPoissonQ.h.


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