Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Static Protected Member Functions
CLHEP::RandGaussQ Class Reference

#include <RandGaussQ.h>

Inheritance diagram for CLHEP::RandGaussQ:
CLHEP::RandGauss CLHEP::HepRandom

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

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 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 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
 
shared_ptr< HepRandomEnginelocalEngine
 
- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Author

Definition at line 31 of file RandGaussQ.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file RandGaussQ.cc.

25  {
26 }

Member Function Documentation

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

Definition at line 103 of file RandGaussQ.h.

103 {return "RandGaussQ";}
HepRandomEngine & CLHEP::RandGaussQ::engine ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 23 of file RandGaussQ.cc.

References CLHEP::RandGauss::engine().

23 {return RandGauss::engine();}
HepRandomEngine & engine()
Definition: RandGauss.cc:43
double CLHEP::RandGaussQ::fire ( )
inline

Referenced by fireArray().

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

Definition at line 51 of file RandGaussQ.cc.

References CLHEP::RandGauss::defaultMean, CLHEP::RandGauss::defaultStdDev, fire(), and test::v.

52 {
53  for( double* v = vect; v != vect + size; ++v )
55 }
double defaultStdDev
Definition: RandGauss.h:152
double defaultMean
Definition: RandGauss.h:151
void CLHEP::RandGaussQ::fireArray ( const int  size,
double *  vect,
double  mean,
double  stdDev 
)

Definition at line 57 of file RandGaussQ.cc.

References fire(), and test::v.

59 {
60  for( double* v = vect; v != vect + size; ++v )
61  *v = fire( mean, stdDev );
62 }
std::istream & CLHEP::RandGaussQ::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 174 of file RandGaussQ.cc.

References CLHEP::RandGauss::get(), and name().

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

Reimplemented from CLHEP::RandGauss.

Definition at line 22 of file RandGaussQ.cc.

Referenced by get(), and put().

22 {return "RandGaussQ";}
double CLHEP::RandGaussQ::operator() ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 28 of file RandGaussQ.cc.

References CLHEP::RandGauss::defaultMean, CLHEP::RandGauss::defaultStdDev, CLHEP::RandGauss::localEngine, and transformQuick().

28  {
30 }
double defaultStdDev
Definition: RandGauss.h:152
static double transformQuick(double r)
Definition: RandGaussQ.cc:92
shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154
double defaultMean
Definition: RandGauss.h:151
double CLHEP::RandGaussQ::operator() ( double  mean,
double  stdDev 
)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 32 of file RandGaussQ.cc.

References CLHEP::RandGauss::localEngine, and transformQuick().

32  {
33  return transformQuick(localEngine->flat()) * stdDev + mean;
34 }
static double transformQuick(double r)
Definition: RandGaussQ.cc:92
shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154
std::ostream & CLHEP::RandGaussQ::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 166 of file RandGaussQ.cc.

References name(), gammaraytel::pr, and CLHEP::RandGauss::put().

166  {
167  int pr=os.precision(20);
168  os << " " << name() << "\n";
169  RandGauss::put(os);
170  os.precision(pr);
171  return os;
172 }
std::string name() const
Definition: RandGaussQ.cc:22
std::ostream & put(std::ostream &os) const
Definition: RandGauss.cc:236
static double CLHEP::RandGaussQ::shoot ( )
inlinestatic

Referenced by shootArray().

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

Definition at line 36 of file RandGaussQ.cc.

References shoot(), and test::v.

38 {
39  for( double* v = vect; v != vect + size; ++v )
40  *v = shoot(mean,stdDev);
41 }
static double shoot()
void CLHEP::RandGaussQ::shootArray ( HepRandomEngine anotherEngine,
const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 43 of file RandGaussQ.cc.

References shoot(), and test::v.

46 {
47  for( double* v = vect; v != vect + size; ++v )
48  *v = shoot(anEngine,mean,stdDev);
49 }
static double shoot()
double CLHEP::RandGaussQ::transformQuick ( double  r)
staticprotected

Definition at line 92 of file RandGaussQ.cc.

References int(), G4INCL::Math::sign(), Table0offset, Table0scale, Table0size, Table0step, Table1offset, Table1size, Table1step, and transformSmall().

Referenced by operator()().

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

Definition at line 125 of file RandGaussQ.cc.

References test::v.

Referenced by transformQuick().

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

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