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

#include <RandGaussQ.h>

+ Inheritance diagram for CLHEP::RandGaussQ:

Public Member Functions

 RandGaussQ (HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
 
 RandGaussQ (HepRandomEngine *anEngine, double mean=0.0, double stdDev=1.0)
 
virtual ~RandGaussQ ()
 
double fire ()
 
double fire (double mean, double stdDev)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double mean, double stdDev)
 
virtual double operator() ()
 
virtual double operator() (double mean, double stdDev)
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
std::string name () const
 
HepRandomEngineengine ()
 
- Public Member Functions inherited from CLHEP::RandGauss
 RandGauss (HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
 
 RandGauss (HepRandomEngine *anEngine, double mean=0.0, double stdDev=1.0)
 
virtual ~RandGauss ()
 
double fire ()
 
double fire (double mean, double stdDev)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double mean, double stdDev)
 
virtual double operator() ()
 
virtual double operator() (double mean, double stdDev)
 
std::string name () const
 
HepRandomEngineengine ()
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
bool getF () const
 
void setF (bool val)
 
- 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 (double mean, double stdDev)
 
static void shootArray (const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static double shoot (HepRandomEngine *anotherEngine)
 
static double shoot (HepRandomEngine *anotherEngine, double mean, double stdDev)
 
static void shootArray (HepRandomEngine *anotherEngine, const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static std::string distributionName ()
 
- Static Public Member Functions inherited from CLHEP::RandGauss
static double shoot ()
 
static double shoot (double mean, double stdDev)
 
static void shootArray (const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, double mean, double stdDev)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static std::string distributionName ()
 
static bool getFlag ()
 
static void setFlag (bool val)
 
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 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 Protected Member Functions

static double transformQuick (double r)
 
static double transformSmall (double r)
 
- Static Protected Member Functions inherited from CLHEP::RandGauss
static double getVal ()
 
static void setVal (double nextVal)
 

Additional Inherited Members

- Protected Member Functions inherited from CLHEP::RandGauss
double normal ()
 
- Protected Attributes inherited from CLHEP::RandGauss
double defaultMean
 
double defaultStdDev
 
std::shared_ptr< HepRandomEnginelocalEngine
 
- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Author

Definition at line 30 of file RandGaussQ.h.

Constructor & Destructor Documentation

◆ RandGaussQ() [1/2]

CLHEP::RandGaussQ::RandGaussQ ( HepRandomEngine anEngine,
double  mean = 0.0,
double  stdDev = 1.0 
)
inline

◆ RandGaussQ() [2/2]

CLHEP::RandGaussQ::RandGaussQ ( HepRandomEngine anEngine,
double  mean = 0.0,
double  stdDev = 1.0 
)
inline

◆ ~RandGaussQ()

CLHEP::RandGaussQ::~RandGaussQ ( )
virtual

Definition at line 24 of file RandGaussQ.cc.

24 {
25}

Member Function Documentation

◆ distributionName()

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

Definition at line 102 of file RandGaussQ.h.

102{return "RandGaussQ";}

◆ engine()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 22 of file RandGaussQ.cc.

22{return RandGauss::engine();}
HepRandomEngine & engine()
Definition: RandGauss.cc:45

◆ fire() [1/2]

double CLHEP::RandGaussQ::fire ( )
inline

Referenced by fireArray().

◆ fire() [2/2]

double CLHEP::RandGaussQ::fire ( double  mean,
double  stdDev 
)
inline

◆ fireArray() [1/2]

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

Definition at line 50 of file RandGaussQ.cc.

51{
52 for( double* v = vect; v != vect + size; ++v )
54}
double defaultStdDev
Definition: RandGauss.h:152
double defaultMean
Definition: RandGauss.h:151

◆ fireArray() [2/2]

void CLHEP::RandGaussQ::fireArray ( const int  size,
double *  vect,
double  mean,
double  stdDev 
)

Definition at line 56 of file RandGaussQ.cc.

58{
59 for( double* v = vect; v != vect + size; ++v )
60 *v = fire( mean, stdDev );
61}

◆ get()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 173 of file RandGaussQ.cc.

173 {
174 std::string inName;
175 is >> inName;
176 if (inName != name()) {
177 is.clear(std::ios::badbit | is.rdstate());
178 std::cerr << "Mismatch when expecting to read state of a "
179 << name() << " distribution\n"
180 << "Name found was " << inName
181 << "\nistream is left in the badbit state\n";
182 return is;
183 }
184 RandGauss::get(is);
185 return is;
186}
std::string name() const
Definition: RandGaussQ.cc:21
std::istream & get(std::istream &is)
Definition: RandGauss.cc:277

◆ name()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 21 of file RandGaussQ.cc.

21{return "RandGaussQ";}

Referenced by get(), and put().

◆ operator()() [1/2]

double CLHEP::RandGaussQ::operator() ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 27 of file RandGaussQ.cc.

27 {
29}
static double transformQuick(double r)
Definition: RandGaussQ.cc:91
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154

◆ operator()() [2/2]

double CLHEP::RandGaussQ::operator() ( double  mean,
double  stdDev 
)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 31 of file RandGaussQ.cc.

31 {
32 return transformQuick(localEngine->flat()) * stdDev + mean;
33}

◆ put()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 165 of file RandGaussQ.cc.

165 {
166 int pr=os.precision(20);
167 os << " " << name() << "\n";
168 RandGauss::put(os);
169 os.precision(pr);
170 return os;
171}
std::ostream & put(std::ostream &os) const
Definition: RandGauss.cc:258

◆ shoot() [1/4]

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

Referenced by shootArray().

◆ shoot() [2/4]

static double CLHEP::RandGaussQ::shoot ( double  mean,
double  stdDev 
)
inlinestatic

◆ shoot() [3/4]

static double CLHEP::RandGaussQ::shoot ( HepRandomEngine anotherEngine)
inlinestatic

◆ shoot() [4/4]

static double CLHEP::RandGaussQ::shoot ( HepRandomEngine anotherEngine,
double  mean,
double  stdDev 
)
inlinestatic

◆ shootArray() [1/2]

void CLHEP::RandGaussQ::shootArray ( const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 35 of file RandGaussQ.cc.

37{
38 for( double* v = vect; v != vect + size; ++v )
39 *v = shoot(mean,stdDev);
40}
static double shoot()

◆ shootArray() [2/2]

void CLHEP::RandGaussQ::shootArray ( HepRandomEngine anotherEngine,
const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 42 of file RandGaussQ.cc.

45{
46 for( double* v = vect; v != vect + size; ++v )
47 *v = shoot(anEngine,mean,stdDev);
48}

◆ transformQuick()

double CLHEP::RandGaussQ::transformQuick ( double  r)
staticprotected

Definition at line 91 of file RandGaussQ.cc.

91 {
92 double sign = +1.0; // We always compute a negative number of
93 // sigmas. For r > 0 we will multiply by
94 // sign = -1 to return a positive number.
95 if ( r > .5 ) {
96 r = 1-r;
97 sign = -1.0;
98 }
99
100 int index;
101 double dx;
102
103 if ( r >= Table1step ) {
104 index = int((Table1size<<1) * r); // 1 to Table1size
105 if (index == Table1size) return 0.0;
106 dx = (Table1size<<1) * r - index; // fraction of way to next bin
107 index += Table1offset-1;
108 } else if ( r > Table0step ) {
109 double rr = r * Table0scale;
110 index = int(Table0size * rr); // 1 to Table0size
111 dx = Table0size * rr - index; // fraction of way to next bin
112 index += Table0offset-1;
113 } else { // r <= Table0step - not in tables
114 return sign*transformSmall(r);
115 }
116
117 double y0 = gaussTables [index++];
118 double y1 = gaussTables [index];
119
120 return (float) (sign * ( y1 * dx + y0 * (1.0-dx) ));
121
122} // transformQuick()
#define Table0scale
Definition: RandGaussQ.cc:80
static double transformSmall(double r)
Definition: RandGaussQ.cc:124
#define Table1offset
#define Table0step
#define Table0offset
#define Table0size
#define Table1step
#define Table1size
G4int sign(const T t)

Referenced by operator()().

◆ transformSmall()

double CLHEP::RandGaussQ::transformSmall ( double  r)
staticprotected

Definition at line 124 of file RandGaussQ.cc.

124 {
125
126 // Solve for -v in the asymtotic formula
127 //
128 // errInt (-v) = exp(-v*v/2) 1 1*3 1*3*5
129 // ------------ * (1 - ---- + ---- - ----- + ... )
130 // v*sqrt(2*pi) v**2 v**4 v**6
131
132 // The value of r (=errInt(-v)) supplied is going to less than 2.0E-13,
133 // which is such that v < -7.25. Since the value of r is meaningful only
134 // to an absolute error of 1E-16 (double precision accuracy for a number
135 // which on the high side could be of the form 1-epsilon), computing
136 // v to more than 3-4 digits of accuracy is suspect; however, to ensure
137 // smoothness with the table generator (which uses quite a few terms) we
138 // also use terms up to 1*3*5* ... *13/v**14, and insist on accuracy of
139 // solution at the level of 1.0e-7.
140
141 // This routine is called less than one time in a million firings, so
142 // speed is of no concern. As a matter of technique, we terminate the
143 // iterations in case they would be infinite, but this should not happen.
144
145 double eps = 1.0e-7;
146 double guess = 7.5;
147 double v;
148
149 for ( int i = 1; i < 50; i++ ) {
150 double vn2 = 1.0/(guess*guess);
151 double s1 = -13*11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2*vn2;
152 s1 += 11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2;
153 s1 += -9*7*5*3 * vn2*vn2*vn2*vn2*vn2;
154 s1 += 7*5*3 * vn2*vn2*vn2*vn2;
155 s1 += -5*3 * vn2*vn2*vn2;
156 s1 += 3 * vn2*vn2 - vn2 + 1.0;
157 v = std::sqrt ( 2.0 * std::log ( s1 / (r*guess*std::sqrt(CLHEP::twopi)) ) );
158 if ( std::fabs(v-guess) < eps ) break;
159 guess = v;
160 }
161 return -v;
162
163} // transformSmall()

Referenced by transformQuick().


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