Geant4 9.6.0
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 m=1.0)
 
 RandPoissonQ (HepRandomEngine *anEngine, double m=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 m=1.0)
 
 RandPoisson (HepRandomEngine *anEngine, double m=1.0)
 
virtual ~RandPoisson ()
 
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::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)
 
virtual double operator() ()
 
virtual std::string name () const
 
virtual HepRandomEngineengine ()
 
virtual std::ostream & put (std::ostream &os) const
 
virtual std::istream & get (std::istream &is)
 

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

◆ RandPoissonQ() [1/2]

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

◆ RandPoissonQ() [2/2]

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

◆ ~RandPoissonQ()

CLHEP::RandPoissonQ::~RandPoissonQ ( )
virtual

Definition at line 79 of file RandPoissonQ.cc.

79 {
80}

Member Function Documentation

◆ distributionName()

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

Definition at line 102 of file RandPoissonQ.h.

102{return "RandPoissonQ";}

◆ engine()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 49 of file RandPoissonQ.cc.

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

◆ fire() [1/2]

long CLHEP::RandPoissonQ::fire ( )

Definition at line 132 of file RandPoissonQ.cc.

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

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

◆ fire() [2/2]

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

Definition at line 128 of file RandPoissonQ.cc.

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

◆ fireArray() [1/2]

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

Definition at line 184 of file RandPoissonQ.cc.

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

◆ fireArray() [2/2]

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

Definition at line 179 of file RandPoissonQ.cc.

179 {
180 for( long* v = vect; v != vect + size; ++v )
181 *v = fire( m );
182}

◆ get()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 571 of file RandPoissonQ.cc.

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

◆ name()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 48 of file RandPoissonQ.cc.

48{return "RandPoissonQ";}

Referenced by get(), and put().

◆ operator()() [1/2]

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 120 of file RandPoissonQ.cc.

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

◆ operator()() [2/2]

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

Definition at line 124 of file RandPoissonQ.cc.

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

◆ put()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 544 of file RandPoissonQ.cc.

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

◆ shoot() [1/2]

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

Definition at line 116 of file RandPoissonQ.cc.

116 {
117 return shoot(getTheEngine(), xm);
118}
static HepRandomEngine * getTheEngine()
Definition: Random.cc:165

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

◆ shoot() [2/2]

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

Definition at line 140 of file RandPoissonQ.cc.

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

◆ shootArray() [1/2]

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

Definition at line 171 of file RandPoissonQ.cc.

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

◆ shootArray() [2/2]

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

◆ 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 109 of file RandPoissonQ.h.


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