Geant4 10.7.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 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 ()
 
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 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()
Definition: RandPoisson.cc:38

◆ 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(), and operator()().

◆ fire() [2/2]

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

Definition at line 131 of file RandPoissonQ.cc.

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

◆ fireArray() [1/2]

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

Definition at line 187 of file RandPoissonQ.cc.

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

◆ fireArray() [2/2]

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

Definition at line 182 of file RandPoissonQ.cc.

182 {
183 for( long* v = vect; v != vect + size; ++v )
184 *v = fire( m );
185}

◆ get()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 574 of file RandPoissonQ.cc.

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

◆ 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  m)

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 547 of file RandPoissonQ.cc.

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

◆ shoot() [1/2]

long CLHEP::RandPoissonQ::shoot ( double  m = 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(), and shootArray().

◆ shoot() [2/2]

long CLHEP::RandPoissonQ::shoot ( HepRandomEngine anEngine,
double  m = 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
Definition: thread_local.h:13

◆ shootArray() [1/2]

void CLHEP::RandPoissonQ::shootArray ( const int  size,
long *  vect,
double  m = 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]

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


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