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

#include <RandBinomial.h>

+ Inheritance diagram for CLHEP::RandBinomial:

Public Member Functions

 RandBinomial (HepRandomEngine &anEngine, long n=1, double p=0.5)
 
 RandBinomial (HepRandomEngine *anEngine, long n=1, double p=0.5)
 
virtual ~RandBinomial ()
 
double fire ()
 
double fire (long n, double p)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, long n, double p)
 
double operator() ()
 
double operator() (long n, double p)
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
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 double shoot ()
 
static double shoot (long n, double p)
 
static void shootArray (const int size, double *vect, long n=1, double p=0.5)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, long n, double p)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, long n=1, double p=0.5)
 
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 ()
 

Additional Inherited Members

- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Author

Definition at line 37 of file RandBinomial.h.

Constructor & Destructor Documentation

◆ RandBinomial() [1/2]

CLHEP::RandBinomial::RandBinomial ( HepRandomEngine anEngine,
long  n = 1,
double  p = 0.5 
)
inline

◆ RandBinomial() [2/2]

CLHEP::RandBinomial::RandBinomial ( HepRandomEngine anEngine,
long  n = 1,
double  p = 0.5 
)
inline

◆ ~RandBinomial()

CLHEP::RandBinomial::~RandBinomial ( )
virtual

Definition at line 29 of file RandBinomial.cc.

29 {
30}

Member Function Documentation

◆ distributionName()

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

Definition at line 99 of file RandBinomial.h.

99{return "RandBinomial";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 27 of file RandBinomial.cc.

27{return *localEngine;}

◆ fire() [1/2]

double CLHEP::RandBinomial::fire ( )
inline

Referenced by fireArray().

◆ fire() [2/2]

double CLHEP::RandBinomial::fire ( long  n,
double  p 
)

Definition at line 42 of file RandBinomial.cc.

42 {
43 return genBinomial( localEngine.get(), n, p );
44}

◆ fireArray() [1/2]

void CLHEP::RandBinomial::fireArray ( const int  size,
double *  vect 
)

Definition at line 61 of file RandBinomial.cc.

62{
63 for( double* v = vect; v != vect+size; ++v )
64 *v = fire(defaultN,defaultP);
65}

◆ fireArray() [2/2]

void CLHEP::RandBinomial::fireArray ( const int  size,
double *  vect,
long  n,
double  p 
)

Definition at line 67 of file RandBinomial.cc.

69{
70 for( double* v = vect; v != vect+size; ++v )
71 *v = fire(n,p);
72}

◆ get()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 340 of file RandBinomial.cc.

340 {
341 std::string inName;
342 is >> inName;
343 if (inName != name()) {
344 is.clear(std::ios::badbit | is.rdstate());
345 std::cerr << "Mismatch when expecting to read state of a "
346 << name() << " distribution\n"
347 << "Name found was " << inName
348 << "\nistream is left in the badbit state\n";
349 return is;
350 }
351 if (possibleKeywordInput(is, "Uvec", defaultN)) {
352 std::vector<unsigned long> t(2);
353 is >> defaultN >> defaultP;
354 is >> t[0] >> t[1]; defaultP = DoubConv::longs2double(t);
355 return is;
356 }
357 // is >> defaultN encompassed by possibleKeywordInput
358 is >> defaultP;
359 return is;
360}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:114
std::string name() const
Definition: RandBinomial.cc:26
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:167

◆ name()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 26 of file RandBinomial.cc.

26{return "RandBinomial";}

Referenced by get(), and put().

◆ operator()() [1/2]

double CLHEP::RandBinomial::operator() ( )
inlinevirtual

Reimplemented from CLHEP::HepRandom.

◆ operator()() [2/2]

double CLHEP::RandBinomial::operator() ( long  n,
double  p 
)
inline

◆ put()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 329 of file RandBinomial.cc.

329 {
330 int pr=os.precision(20);
331 std::vector<unsigned long> t(2);
332 os << " " << name() << "\n";
333 os << "Uvec" << "\n";
334 t = DoubConv::dto2longs(defaultP);
335 os << defaultN << " " << defaultP << " " << t[0] << " " << t[1] << "\n";
336 os.precision(pr);
337 return os;
338}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:98

◆ shoot() [1/4]

static double CLHEP::RandBinomial::shoot ( )
inlinestatic

Referenced by shootArray().

◆ shoot() [2/4]

static double CLHEP::RandBinomial::shoot ( HepRandomEngine anEngine)
inlinestatic

◆ shoot() [3/4]

double CLHEP::RandBinomial::shoot ( HepRandomEngine anEngine,
long  n,
double  p 
)
static

Definition at line 32 of file RandBinomial.cc.

33 {
34 return genBinomial( anEngine, n, p );
35}

◆ shoot() [4/4]

double CLHEP::RandBinomial::shoot ( long  n,
double  p 
)
static

Definition at line 37 of file RandBinomial.cc.

37 {
38 HepRandomEngine *anEngine = HepRandom::getTheEngine();
39 return genBinomial( anEngine, n, p );
40}
static HepRandomEngine * getTheEngine()
Definition: Random.cc:165

◆ shootArray() [1/2]

void CLHEP::RandBinomial::shootArray ( const int  size,
double *  vect,
long  n = 1,
double  p = 0.5 
)
static

Definition at line 46 of file RandBinomial.cc.

48{
49 for( double* v = vect; v != vect+size; ++v )
50 *v = shoot(n,p);
51}
static double shoot()

◆ shootArray() [2/2]

void CLHEP::RandBinomial::shootArray ( HepRandomEngine anEngine,
const int  size,
double *  vect,
long  n = 1,
double  p = 0.5 
)
static

Definition at line 53 of file RandBinomial.cc.

56{
57 for( double* v = vect; v != vect+size; ++v )
58 *v = shoot(anEngine,n,p);
59}

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