CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
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 ()
 
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::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 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 doublegetPStatus ()
 
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 33 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 84 of file RandPoissonQ.cc.

84 {
85}

Member Function Documentation

◆ distributionName()

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

Definition at line 103 of file RandPoissonQ.h.

103{return "RandPoissonQ";}

◆ engine()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 54 of file RandPoissonQ.cc.

54{return RandPoisson::engine();}
HepRandomEngine & engine()
Definition: RandPoisson.cc:40

◆ fire() [1/2]

long CLHEP::RandPoissonQ::fire ( )

Definition at line 137 of file RandPoissonQ.cc.

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

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

◆ fire() [2/2]

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

Definition at line 133 of file RandPoissonQ.cc.

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

◆ fireArray() [1/2]

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

Definition at line 189 of file RandPoissonQ.cc.

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

◆ fireArray() [2/2]

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

Definition at line 184 of file RandPoissonQ.cc.

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

◆ get()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 576 of file RandPoissonQ.cc.

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

◆ name()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 53 of file RandPoissonQ.cc.

53{return "RandPoissonQ";}

Referenced by get(), and put().

◆ operator()() [1/2]

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 125 of file RandPoissonQ.cc.

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

◆ operator()() [2/2]

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

Definition at line 129 of file RandPoissonQ.cc.

129 {
130 return (double) fire(mean);
131}

◆ put()

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

Reimplemented from CLHEP::RandPoisson.

Definition at line 549 of file RandPoissonQ.cc.

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

◆ shoot() [1/2]

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

Definition at line 121 of file RandPoissonQ.cc.

121 {
122 return shoot(getTheEngine(), xm);
123}
static HepRandomEngine * getTheEngine()
Definition: Random.cc:270

Referenced by captureStatics(), CLHEP::RandPoissonT::fire(), fire(), main(), randomizeStatics(), shoot(), CLHEP::RandPoissonT::shoot(), and shootArray().

◆ shoot() [2/2]

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

Definition at line 145 of file RandPoissonQ.cc.

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

◆ shootArray() [1/2]

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

Definition at line 176 of file RandPoissonQ.cc.

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

◆ shootArray() [2/2]

static void CLHEP::RandPoissonQ::shootArray ( HepRandomEngine anEngine,
const int  size,
long *  vect,
double  mean = 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 110 of file RandPoissonQ.h.


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