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 | Static Protected Attributes
CLHEP::RandGaussZiggurat Class Reference

#include <RandGaussZiggurat.h>

Inheritance diagram for CLHEP::RandGaussZiggurat:
CLHEP::RandGauss CLHEP::HepRandom

Public Member Functions

 RandGaussZiggurat (HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
 
 RandGaussZiggurat (HepRandomEngine *anEngine, double mean=0.0, double stdDev=1.0)
 
virtual ~RandGaussZiggurat ()
 
float fire ()
 
float fire (float mean, float stdDev)
 
void fireArray (const int size, float *vect)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, float *vect, float mean, float stdDev)
 
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 float shoot ()
 
static float shoot (float mean, float stdDev)
 
static void shootArray (const int size, float *vect, float mean=0.0, float stdDev=1.0)
 
static void shootArray (const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static float shoot (HepRandomEngine *anotherEngine)
 
static float shoot (HepRandomEngine *anotherEngine, float mean, float stdDev)
 
static void shootArray (HepRandomEngine *anotherEngine, const int size, float *vect, float mean=0.0, float stdDev=1.0)
 
static void shootArray (HepRandomEngine *anotherEngine, const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static std::string distributionName ()
 
static bool ziggurat_init ()
 
- 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 unsigned long ziggurat_SHR3 (HepRandomEngine *anEngine)
 
static float ziggurat_UNI (HepRandomEngine *anEngine)
 
static float ziggurat_RNOR (HepRandomEngine *anEngine)
 
static float ziggurat_nfix (long hz, HepRandomEngine *anEngine)
 
- Static Protected Member Functions inherited from CLHEP::RandGauss
static double getVal ()
 
static void setVal (double nextVal)
 

Static Protected Attributes

static unsigned long kn [128]
 
static unsigned long ke [256]
 
static float wn [128]
 
static float fn [128]
 
static float we [256]
 
static float fe [256]
 
static bool ziggurat_is_init =RandGaussZiggurat::ziggurat_init()
 
- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

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
 

Detailed Description

Author
ATLAS

Definition at line 36 of file RandGaussZiggurat.h.

Constructor & Destructor Documentation

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

Definition at line 135 of file RandGaussZiggurat.h.

References ziggurat_init(), and ziggurat_is_init.

135  : RandGauss(anEngine, mean, stdDev)
136 {
138 }
RandGauss(HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
CLHEP::RandGaussZiggurat::RandGaussZiggurat ( HepRandomEngine anEngine,
double  mean = 0.0,
double  stdDev = 1.0 
)
inline

Definition at line 140 of file RandGaussZiggurat.h.

References ziggurat_init(), and ziggurat_is_init.

140  : RandGauss(anEngine, mean, stdDev)
141 {
143 }
RandGauss(HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
CLHEP::RandGaussZiggurat::~RandGaussZiggurat ( )
virtual

Definition at line 15 of file RandGaussZiggurat.cc.

15  {
16 }

Member Function Documentation

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

Definition at line 86 of file RandGaussZiggurat.h.

86 {return "RandGaussZiggurat";}
HepRandomEngine & CLHEP::RandGaussZiggurat::engine ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 13 of file RandGaussZiggurat.cc.

References CLHEP::RandGauss::engine().

13 {return RandGauss::engine();}
HepRandomEngine & engine()
Definition: RandGauss.cc:43
float CLHEP::RandGaussZiggurat::fire ( )
inline

Definition at line 66 of file RandGaussZiggurat.h.

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

Referenced by fireArray().

double defaultStdDev
Definition: RandGauss.h:152
shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154
double defaultMean
Definition: RandGauss.h:151
static float ziggurat_RNOR(HepRandomEngine *anEngine)
float CLHEP::RandGaussZiggurat::fire ( float  mean,
float  stdDev 
)
inline

Definition at line 68 of file RandGaussZiggurat.h.

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

68 {return ziggurat_RNOR(localEngine.get()) * stdDev + mean;};
shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154
static float ziggurat_RNOR(HepRandomEngine *anEngine)
void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
float *  vect 
)

Definition at line 137 of file RandGaussZiggurat.cc.

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

138 {
139  for (int i=0; i<size; ++i) {
140  vect[i] = fire( defaultMean, defaultStdDev );
141  }
142 }
double defaultStdDev
Definition: RandGauss.h:152
double defaultMean
Definition: RandGauss.h:151
void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
double *  vect 
)

Definition at line 144 of file RandGaussZiggurat.cc.

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

145 {
146  for (int i=0; i<size; ++i) {
147  vect[i] = fire( defaultMean, defaultStdDev );
148  }
149 }
double defaultStdDev
Definition: RandGauss.h:152
double defaultMean
Definition: RandGauss.h:151
void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
float *  vect,
float  mean,
float  stdDev 
)

Definition at line 151 of file RandGaussZiggurat.cc.

References fire().

152 {
153  for (int i=0; i<size; ++i) {
154  vect[i] = fire( mean, stdDev );
155  }
156 }
void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
double *  vect,
double  mean,
double  stdDev 
)

Definition at line 158 of file RandGaussZiggurat.cc.

References fire().

159 {
160  for (int i=0; i<size; ++i) {
161  vect[i] = fire( mean, stdDev );
162  }
163 }
std::istream & CLHEP::RandGaussZiggurat::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 173 of file RandGaussZiggurat.cc.

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

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::istream & get(std::istream &is)
Definition: RandGauss.cc:255
std::string name() const
std::string CLHEP::RandGaussZiggurat::name ( ) const
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 18 of file RandGaussZiggurat.cc.

Referenced by get(), and put().

19 {
20  return "RandGaussZiggurat";
21 }
double CLHEP::RandGaussZiggurat::operator() ( )
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 101 of file RandGaussZiggurat.cc.

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

101  {
103 }
double defaultStdDev
Definition: RandGauss.h:152
shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154
double defaultMean
Definition: RandGauss.h:151
static float ziggurat_RNOR(HepRandomEngine *anEngine)
double CLHEP::RandGaussZiggurat::operator() ( double  mean,
double  stdDev 
)
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 105 of file RandGaussZiggurat.cc.

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

105  {
106  return ziggurat_RNOR(localEngine.get()) * stdDev + mean;
107 }
shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154
static float ziggurat_RNOR(HepRandomEngine *anEngine)
std::ostream & CLHEP::RandGaussZiggurat::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::RandGauss.

Definition at line 165 of file RandGaussZiggurat.cc.

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

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

Definition at line 48 of file RandGaussZiggurat.h.

References CLHEP::HepRandom::getTheEngine(), and ziggurat_RNOR().

Referenced by shootArray().

static HepRandomEngine * getTheEngine()
Definition: Random.cc:165
static float ziggurat_RNOR(HepRandomEngine *anEngine)
static float CLHEP::RandGaussZiggurat::shoot ( float  mean,
float  stdDev 
)
inlinestatic

Definition at line 49 of file RandGaussZiggurat.h.

References shoot().

Referenced by shoot().

49 {return shoot()*stdDev + mean;};
static float CLHEP::RandGaussZiggurat::shoot ( HepRandomEngine anotherEngine)
inlinestatic

Definition at line 57 of file RandGaussZiggurat.h.

References ziggurat_RNOR().

57 {return ziggurat_RNOR(anotherEngine);};
static float ziggurat_RNOR(HepRandomEngine *anEngine)
static float CLHEP::RandGaussZiggurat::shoot ( HepRandomEngine anotherEngine,
float  mean,
float  stdDev 
)
inlinestatic

Definition at line 58 of file RandGaussZiggurat.h.

References shoot().

Referenced by shoot().

58 {return shoot(anotherEngine)*stdDev + mean;};
void CLHEP::RandGaussZiggurat::shootArray ( const int  size,
float *  vect,
float  mean = 0.0,
float  stdDev = 1.0 
)
static

Definition at line 109 of file RandGaussZiggurat.cc.

References shoot().

110 {
111  for (int i=0; i<size; ++i) {
112  vect[i] = shoot(mean,stdDev);
113  }
114 }
void CLHEP::RandGaussZiggurat::shootArray ( const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 116 of file RandGaussZiggurat.cc.

References shoot().

117 {
118  for (int i=0; i<size; ++i) {
119  vect[i] = shoot(mean,stdDev);
120  }
121 }
void CLHEP::RandGaussZiggurat::shootArray ( HepRandomEngine anotherEngine,
const int  size,
float *  vect,
float  mean = 0.0,
float  stdDev = 1.0 
)
static

Definition at line 123 of file RandGaussZiggurat.cc.

References shoot().

124 {
125  for (int i=0; i<size; ++i) {
126  vect[i] = shoot(anEngine,mean,stdDev);
127  }
128 }
void CLHEP::RandGaussZiggurat::shootArray ( HepRandomEngine anotherEngine,
const int  size,
double *  vect,
double  mean = 0.0,
double  stdDev = 1.0 
)
static

Definition at line 130 of file RandGaussZiggurat.cc.

References shoot().

131 {
132  for (int i=0; i<size; ++i) {
133  vect[i] = shoot(anEngine,mean,stdDev);
134  }
135 }
bool CLHEP::RandGaussZiggurat::ziggurat_init ( )
static

Definition at line 23 of file RandGaussZiggurat.cc.

References fe, fn, ke, kn, we, wn, and ziggurat_is_init.

Referenced by RandGaussZiggurat().

24 {
25  const double rzm1 = 2147483648.0, rzm2 = 4294967296.;
26  double dn=3.442619855899,tn=dn,vn=9.91256303526217e-3, q;
27  double de=7.697117470131487, te=de, ve=3.949659822581572e-3;
28  int i;
29 
30 /* Set up tables for RNOR */
31  q=vn/std::exp(-.5*dn*dn);
32  kn[0]=(unsigned long)((dn/q)*rzm1);
33  kn[1]=0;
34 
35  wn[0]=q/rzm1;
36  wn[127]=dn/rzm1;
37 
38  fn[0]=1.;
39  fn[127]=std::exp(-.5*dn*dn);
40 
41  for(i=126;i>=1;i--) {
42  dn=std::sqrt(-2.*std::log(vn/dn+std::exp(-.5*dn*dn)));
43  kn[i+1]=(unsigned long)((dn/tn)*rzm1);
44  tn=dn;
45  fn[i]=std::exp(-.5*dn*dn);
46  wn[i]=dn/rzm1;
47  }
48 
49 /* Set up tables for REXP */
50  q = ve/std::exp(-de);
51  ke[0]=(unsigned long)((de/q)*rzm2);
52  ke[1]=0;
53 
54  we[0]=q/rzm2;
55  we[255]=de/rzm2;
56 
57  fe[0]=1.;
58  fe[255]=std::exp(-de);
59 
60  for(i=254;i>=1;i--) {
61  de=-std::log(ve/de+std::exp(-de));
62  ke[i+1]= (unsigned long)((de/te)*rzm2);
63  te=de;
64  fe[i]=std::exp(-de);
65  we[i]=de/rzm2;
66  }
67  ziggurat_is_init=true;
68 
69  //std::cout<<"Done RandGaussZiggurat::ziggurat_init()"<<std::endl;
70 
71  return true;
72 }
static unsigned long ke[256]
static unsigned long kn[128]
float CLHEP::RandGaussZiggurat::ziggurat_nfix ( long  hz,
HepRandomEngine anEngine 
)
staticprotected

Definition at line 74 of file RandGaussZiggurat.cc.

References fn, iz, kn, wn, test::x, ziggurat_SHR3(), and ziggurat_UNI().

Referenced by ziggurat_RNOR().

75 {
76  const float r = 3.442620f; /* The start of the right tail */
77  float x, y;
78  unsigned long iz=hz&127;
79  for(;;)
80  {
81  x=hz*wn[iz]; /* iz==0, handles the base strip */
82  if(iz==0) {
83  do {
84  /* change to (1.0 - UNI) as argument to std::log(), because CLHEP generates [0,1),
85  while the original UNI generates (0,1] */
86  x=-std::log(1.0 - ziggurat_UNI(anEngine))*0.2904764; /* .2904764 is 1/r */
87  y=-std::log(1.0 - ziggurat_UNI(anEngine));
88  } while(y+y<x*x);
89  return (hz>0)? r+x : -r-x;
90  }
91  /* iz>0, handle the wedges of other strips */
92  if( fn[iz]+(1.0 - ziggurat_UNI(anEngine))*(fn[iz-1]-fn[iz]) < std::exp(-.5*x*x) ) return x;
93 
94  /* initiate, try to exit for(;;) for loop*/
95  hz=(signed)ziggurat_SHR3(anEngine);
96  iz=hz&127;
97  if((unsigned long)abs(hz)<kn[iz]) return (hz*wn[iz]);
98  }
99 }
static float ziggurat_UNI(HepRandomEngine *anEngine)
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
G4double iz
Definition: TRTMaterials.hh:39
static unsigned long kn[128]
static float CLHEP::RandGaussZiggurat::ziggurat_RNOR ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 114 of file RandGaussZiggurat.h.

References iz, kn, wn, ziggurat_nfix(), and ziggurat_SHR3().

Referenced by fire(), operator()(), and shoot().

114  {
115  long hz=(signed)ziggurat_SHR3(anEngine);
116  unsigned long iz=hz&127;
117  return ((unsigned long)abs(hz)<kn[iz]) ? hz*wn[iz] : ziggurat_nfix(hz,anEngine);
118  };
static float ziggurat_nfix(long hz, HepRandomEngine *anEngine)
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)
G4double iz
Definition: TRTMaterials.hh:39
static unsigned long kn[128]
static unsigned long CLHEP::RandGaussZiggurat::ziggurat_SHR3 ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 112 of file RandGaussZiggurat.h.

Referenced by ziggurat_nfix(), and ziggurat_RNOR().

112 {return (unsigned int)(*anEngine);};
static float CLHEP::RandGaussZiggurat::ziggurat_UNI ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 113 of file RandGaussZiggurat.h.

References CLHEP::HepRandomEngine::flat().

Referenced by ziggurat_nfix().

113 {return anEngine->flat();};

Field Documentation

float CLHEP::RandGaussZiggurat::fe
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

Referenced by ziggurat_init().

float CLHEP::RandGaussZiggurat::fn
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

Referenced by ziggurat_init(), and ziggurat_nfix().

unsigned long CLHEP::RandGaussZiggurat::ke
staticprotected

Definition at line 107 of file RandGaussZiggurat.h.

Referenced by ziggurat_init().

unsigned long CLHEP::RandGaussZiggurat::kn
staticprotected

Definition at line 107 of file RandGaussZiggurat.h.

Referenced by ziggurat_init(), ziggurat_nfix(), and ziggurat_RNOR().

float CLHEP::RandGaussZiggurat::we
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

Referenced by ziggurat_init().

float CLHEP::RandGaussZiggurat::wn
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

Referenced by ziggurat_init(), ziggurat_nfix(), and ziggurat_RNOR().

bool CLHEP::RandGaussZiggurat::ziggurat_is_init =RandGaussZiggurat::ziggurat_init()
staticprotected

Definition at line 110 of file RandGaussZiggurat.h.

Referenced by RandGaussZiggurat(), and ziggurat_init().


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