Geant4-11
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CLHEP::RandGaussZiggurat Class Reference

#include <RandGaussZiggurat.h>

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

Public Member Functions

HepRandomEngineengine ()
 
float fire ()
 
double fire (double mean, double stdDev)
 
float fire (float mean, float stdDev)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double mean, double stdDev)
 
void fireArray (const int size, float *vect)
 
void fireArray (const int size, float *vect, float mean, float stdDev)
 
double flat ()
 
double flat (HepRandomEngine *theNewEngine)
 
void flatArray (const int size, double *vect)
 
void flatArray (HepRandomEngine *theNewEngine, const int size, double *vect)
 
std::istream & get (std::istream &is)
 
bool getF () const
 
std::string name () const
 
virtual double operator() ()
 
virtual double operator() (double mean, double stdDev)
 
std::ostream & put (std::ostream &os) const
 
 RandGaussZiggurat (HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)
 
 RandGaussZiggurat (HepRandomEngine *anEngine, double mean=0.0, double stdDev=1.0)
 
void setF (bool val)
 
virtual ~RandGaussZiggurat ()
 

Static Public Member Functions

static int createInstance ()
 
static std::string distributionName ()
 
static bool getFlag ()
 
static HepRandomEnginegetTheEngine ()
 
static HepRandomgetTheGenerator ()
 
static long getTheSeed ()
 
static const long * getTheSeeds ()
 
static void getTheTableSeeds (long *seeds, int index)
 
static std::istream & restoreDistState (std::istream &is)
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::istream & restoreFullState (std::istream &is)
 
static std::istream & restoreStaticRandomStates (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::ostream & saveStaticRandomStates (std::ostream &os)
 
static void setFlag (bool val)
 
static void setTheEngine (HepRandomEngine *theNewEngine)
 
static void setTheSeed (long seed, int lxr=3)
 
static void setTheSeeds (const long *seeds, int aux=-1)
 
static float shoot ()
 
static double shoot (double mean, double stdDev)
 
static float shoot (float mean, float stdDev)
 
static double shoot (HepRandomEngine *anEngine, double mean, double stdDev)
 
static float shoot (HepRandomEngine *anotherEngine)
 
static float shoot (HepRandomEngine *anotherEngine, float mean, float stdDev)
 
static void shootArray (const int size, double *vect, double mean=0.0, double stdDev=1.0)
 
static void shootArray (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 void shootArray (HepRandomEngine *anotherEngine, const int size, float *vect, float mean=0.0, float stdDev=1.0)
 
static void showEngineStatus ()
 
static bool ziggurat_init ()
 

Protected Member Functions

double normal ()
 

Static Protected Member Functions

static double getVal ()
 
static void setVal (double nextVal)
 
static float ziggurat_nfix (long hz, HepRandomEngine *anEngine)
 
static float ziggurat_RNOR (HepRandomEngine *anEngine)
 
static unsigned long ziggurat_SHR3 (HepRandomEngine *anEngine)
 
static float ziggurat_UNI (HepRandomEngine *anEngine)
 

Protected Attributes

double defaultMean
 
double defaultStdDev
 
std::shared_ptr< HepRandomEnginelocalEngine
 

Static Protected Attributes

static CLHEP_THREAD_LOCAL float fe [256]
 
static CLHEP_THREAD_LOCAL float fn [128]
 
static CLHEP_THREAD_LOCAL unsigned long ke [256]
 
static CLHEP_THREAD_LOCAL unsigned long kn [128]
 
static const long seedTable [215][2]
 
static CLHEP_THREAD_LOCAL float we [256]
 
static CLHEP_THREAD_LOCAL float wn [128]
 
static CLHEP_THREAD_LOCAL bool ziggurat_is_init = false
 

Private Member Functions

 RandGaussZiggurat (const RandGaussZiggurat &d)
 

Private Attributes

double nextGauss
 
bool set
 

Static Private Attributes

static CLHEP_THREAD_LOCAL double nextGauss_st = 0.0
 
static CLHEP_THREAD_LOCAL bool set_st = false
 

Detailed Description

Author
ATLAS

Definition at line 37 of file RandGaussZiggurat.h.

Constructor & Destructor Documentation

◆ RandGaussZiggurat() [1/3]

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

Definition at line 137 of file RandGaussZiggurat.h.

137 : RandGauss(anEngine, mean, stdDev)
138{
139}
RandGauss(HepRandomEngine &anEngine, double mean=0.0, double stdDev=1.0)

◆ RandGaussZiggurat() [2/3]

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

Definition at line 141 of file RandGaussZiggurat.h.

141 : RandGauss(anEngine, mean, stdDev)
142{
143}

◆ ~RandGaussZiggurat()

CLHEP::RandGaussZiggurat::~RandGaussZiggurat ( )
virtual

Definition at line 14 of file RandGaussZiggurat.cc.

14 {
15}

◆ RandGaussZiggurat() [3/3]

CLHEP::RandGaussZiggurat::RandGaussZiggurat ( const RandGaussZiggurat d)
private

Member Function Documentation

◆ createInstance()

int CLHEP::HepRandom::createInstance ( )
staticinherited

◆ distributionName()

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

Definition at line 87 of file RandGaussZiggurat.h.

87{return "RandGaussZiggurat";}

◆ engine()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 12 of file RandGaussZiggurat.cc.

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

References CLHEP::RandGauss::engine().

◆ fire() [1/3]

float CLHEP::RandGaussZiggurat::fire ( )
inline

Definition at line 67 of file RandGaussZiggurat.h.

67{return float(ziggurat_RNOR(localEngine.get()) * defaultStdDev + defaultMean);}
static float ziggurat_RNOR(HepRandomEngine *anEngine)
double defaultStdDev
Definition: RandGauss.h:152
double defaultMean
Definition: RandGauss.h:151
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:154

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

Referenced by fireArray().

◆ fire() [2/3]

double CLHEP::RandGauss::fire ( double  mean,
double  stdDev 
)
inlineinherited

◆ fire() [3/3]

float CLHEP::RandGaussZiggurat::fire ( float  mean,
float  stdDev 
)
inline

Definition at line 69 of file RandGaussZiggurat.h.

69{return ziggurat_RNOR(localEngine.get()) * stdDev + mean;}

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

◆ fireArray() [1/4]

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

Definition at line 144 of file RandGaussZiggurat.cc.

145{
146 for (int i=0; i<size; ++i) {
147 vect[i] = fire( defaultMean, defaultStdDev );
148 }
149}

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

◆ fireArray() [2/4]

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

Definition at line 158 of file RandGaussZiggurat.cc.

159{
160 for (int i=0; i<size; ++i) {
161 vect[i] = fire( mean, stdDev );
162 }
163}

References fire().

◆ fireArray() [3/4]

void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
float *  vect 
)

Definition at line 137 of file RandGaussZiggurat.cc.

138{
139 for (int i=0; i<size; ++i) {
140 vect[i] = fire( defaultMean, defaultStdDev );
141 }
142}

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

◆ fireArray() [4/4]

void CLHEP::RandGaussZiggurat::fireArray ( const int  size,
float *  vect,
float  mean,
float  stdDev 
)

Definition at line 151 of file RandGaussZiggurat.cc.

152{
153 for (int i=0; i<size; ++i) {
154 vect[i] = fire( mean, stdDev );
155 }
156}

References fire().

◆ flat() [1/2]

double CLHEP::HepRandom::flat ( )
inherited

◆ flat() [2/2]

double CLHEP::HepRandom::flat ( HepRandomEngine theNewEngine)
inlineinherited

◆ flatArray() [1/2]

void CLHEP::HepRandom::flatArray ( const int  size,
double *  vect 
)
inherited

◆ flatArray() [2/2]

void CLHEP::HepRandom::flatArray ( HepRandomEngine theNewEngine,
const int  size,
double *  vect 
)
inlineinherited

◆ get()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 173 of file RandGaussZiggurat.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
std::istream & get(std::istream &is)
Definition: RandGauss.cc:277

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

◆ getF()

bool CLHEP::RandGauss::getF ( ) const
inlineinherited

Definition at line 115 of file RandGauss.h.

115{return set;}

References CLHEP::RandGauss::set.

◆ getFlag()

bool CLHEP::RandGauss::getFlag ( )
staticinherited

Definition at line 171 of file RandGauss.cc.

172{
173 return set_st;
174}
static CLHEP_THREAD_LOCAL bool set_st
Definition: RandGauss.h:162

References CLHEP::RandGauss::set_st.

Referenced by CLHEP::RandGauss::saveDistState(), CLHEP::RandGauss::saveEngineStatus(), and CLHEP::RandGauss::shoot().

◆ getTheEngine()

HepRandomEngine * CLHEP::HepRandom::getTheEngine ( )
staticinherited

◆ getTheGenerator()

HepRandom * CLHEP::HepRandom::getTheGenerator ( )
staticinherited

◆ getTheSeed()

long CLHEP::HepRandom::getTheSeed ( )
staticinherited

◆ getTheSeeds()

const long * CLHEP::HepRandom::getTheSeeds ( )
staticinherited

◆ getTheTableSeeds()

void CLHEP::HepRandom::getTheTableSeeds ( long *  seeds,
int  index 
)
staticinherited

Definition at line 254 of file Random.cc.

255{
256 if ((index >= 0) && (index < 215)) {
257 seeds[0] = seedTable[index][0];
258 seeds[1] = seedTable[index][1];
259 }
260 else seeds = NULL;
261}
static const long seedTable[215][2]
Definition: Random.h:156

Referenced by CLHEP::HepJamesRandom::HepJamesRandom(), CLHEP::MTwistEngine::MTwistEngine(), CLHEP::RanecuEngine::RanecuEngine(), CLHEP::Ranlux64Engine::Ranlux64Engine(), CLHEP::RanluxEngine::RanluxEngine(), and CLHEP::RanecuEngine::setSeed().

◆ getVal()

double CLHEP::RandGauss::getVal ( )
staticprotectedinherited

Definition at line 181 of file RandGauss.cc.

182{
183 return nextGauss_st;
184}
static CLHEP_THREAD_LOCAL double nextGauss_st
Definition: RandGauss.h:163

References CLHEP::RandGauss::nextGauss_st.

Referenced by CLHEP::RandGauss::saveDistState(), CLHEP::RandGauss::saveEngineStatus(), and CLHEP::RandGauss::shoot().

◆ name()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 17 of file RandGaussZiggurat.cc.

18{
19 return "RandGaussZiggurat";
20}

Referenced by source.g4viscp.G4Scene::create_scene(), get(), mcscore.MCParticle::printout(), put(), and source.g4viscp.G4Scene::update_scene().

◆ normal()

double CLHEP::RandGauss::normal ( )
protectedinherited

Definition at line 132 of file RandGauss.cc.

133{
134 // Gaussian random numbers are generated two at the time, so every other
135 // time this is called we just return a number generated the time before.
136
137 if ( set ) {
138 set = false;
139 return nextGauss;
140 }
141
142 double r;
143 double v1,v2,fac,val;
144
145 do {
146 v1 = 2.0 * localEngine->flat() - 1.0;
147 v2 = 2.0 * localEngine->flat() - 1.0;
148 r = v1*v1 + v2*v2;
149 } while ( r > 1.0 );
150
151 fac = std::sqrt(-2.0*std::log(r)/r);
152 val = v1*fac;
153 nextGauss = val;
154 set = true;
155 return v2*fac;
156}
static const G4double fac
double nextGauss
Definition: RandGauss.h:159

References fac, CLHEP::RandGauss::localEngine, CLHEP::RandGauss::nextGauss, and CLHEP::RandGauss::set.

◆ operator()() [1/2]

double CLHEP::RandGaussZiggurat::operator() ( )
virtual

◆ operator()() [2/2]

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

Reimplemented from CLHEP::RandGauss.

Definition at line 105 of file RandGaussZiggurat.cc.

105 {
106 return ziggurat_RNOR(localEngine.get()) * stdDev + mean;
107}

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

◆ put()

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

Reimplemented from CLHEP::RandGauss.

Definition at line 165 of file RandGaussZiggurat.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

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

◆ restoreDistState()

std::istream & CLHEP::RandGauss::restoreDistState ( std::istream &  is)
staticinherited

Definition at line 346 of file RandGauss.cc.

346 {
347 std::string inName;
348 is >> inName;
349 if (inName != distributionName()) {
350 is.clear(std::ios::badbit | is.rdstate());
351 std::cerr << "Mismatch when expecting to read static state of a "
352 << distributionName() << " distribution\n"
353 << "Name found was " << inName
354 << "\nistream is left in the badbit state\n";
355 return is;
356 }
357 std::string c1;
358 std::string c2;
359 if (possibleKeywordInput(is, "Uvec", c1)) {
360 std::vector<unsigned long> t(2);
361 std::string ng;
362 is >> ng;
363 setFlag (false);
364 if (ng == "nextGauss_st") {
365 is >> nextGauss_st >> t[0] >> t[1];
367 setFlag (true);
368 }
369 return is;
370 }
371 // is >> c1 encompassed by possibleKeywordInput
372 is >> c2 >> nextGauss_st;
373 if ( (!is) || (c1 != "RANDGAUSS") ) {
374 is.clear(std::ios::badbit | is.rdstate());
375 std::cerr << "Failure when reading caching state of static RandGauss\n";
376 return is;
377 }
378 if (c2 == "CACHED_GAUSSIAN:") {
379 setFlag(true);
380 } else if (c2 == "NO_CACHED_GAUSSIAN:") {
381 setFlag(false);
382 } else {
383 is.clear(std::ios::badbit | is.rdstate());
384 std::cerr << "Unexpected caching state keyword of static RandGauss:" << c2
385 << "\nistream is left in the badbit state\n";
386 }
387 return is;
388}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110
static void setFlag(bool val)
Definition: RandGauss.cc:176
static std::string distributionName()
Definition: RandGauss.h:99
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:166

References CLHEP::RandGauss::distributionName(), CLHEP::DoubConv::longs2double(), CLHEP::RandGauss::nextGauss_st, CLHEP::possibleKeywordInput(), and CLHEP::RandGauss::setFlag().

Referenced by CLHEP::StaticRandomStates::restore(), and CLHEP::RandGauss::restoreFullState().

◆ restoreEngineStatus()

void CLHEP::RandGauss::restoreEngineStatus ( const char  filename[] = "Config.conf")
staticinherited

Definition at line 211 of file RandGauss.cc.

211 {
212
213 // First restore the engine status just like the base class would do:
214 getTheEngine()->restoreStatus( filename );
215
216 // Now find the line describing the cached variate:
217
218 std::ifstream infile ( filename, std::ios::in );
219 if (!infile) return;
220
221 char inputword[] = "NO_KEYWORD "; // leaves room for 14 characters plus \0
222 while (true) {
223 infile.width(13);
224 infile >> inputword;
225 if (strcmp(inputword,"RANDGAUSS")==0) break;
226 if (infile.eof()) break;
227 // If the file ends without the RANDGAUSS line, that means this
228 // was a file produced by an earlier version of RandGauss. We will
229 // replicated the old behavior in that case: set_st is cleared.
230 }
231
232 // Then read and use the caching info:
233
234 if (strcmp(inputword,"RANDGAUSS")==0) {
235 char setword[40]; // the longest, staticFirstUnusedBit: has length 21
236 infile.width(39);
237 infile >> setword; // setword should be CACHED_GAUSSIAN:
238 if (strcmp(setword,"CACHED_GAUSSIAN:") ==0) {
239 if (possibleKeywordInput(infile, "Uvec", nextGauss_st)) {
240 std::vector<unsigned long> t(2);
241 infile >> nextGauss_st >> t[0] >> t[1];
243 }
244 // is >> nextGauss_st encompassed by possibleKeywordInput
245 setFlag(true);
246 } else {
247 setFlag(false);
248 infile >> nextGauss_st; // because a 0 will have been output
249 }
250 } else {
251 setFlag(false);
252 }
253
254} // restoreEngineStatus
virtual void restoreStatus(const char filename[]="Config.conf")=0
static HepRandomEngine * getTheEngine()
Definition: Random.cc:268

References CLHEP::HepRandom::getTheEngine(), CLHEP::DoubConv::longs2double(), CLHEP::RandGauss::nextGauss_st, CLHEP::possibleKeywordInput(), CLHEP::HepRandomEngine::restoreStatus(), and CLHEP::RandGauss::setFlag().

◆ restoreFullState()

std::istream & CLHEP::RandGauss::restoreFullState ( std::istream &  is)
staticinherited

Definition at line 396 of file RandGauss.cc.

396 {
399 return is;
400}
static std::istream & restoreFullState(std::istream &is)
Definition: Random.cc:293
static std::istream & restoreDistState(std::istream &is)
Definition: RandGauss.cc:346

References CLHEP::RandGauss::restoreDistState(), and CLHEP::HepRandom::restoreFullState().

◆ restoreStaticRandomStates()

std::istream & CLHEP::HepRandom::restoreStaticRandomStates ( std::istream &  is)
staticinherited

Definition at line 302 of file Random.cc.

302 {
304}
static std::istream & restore(std::istream &is)

References CLHEP::StaticRandomStates::restore().

◆ saveDistState()

std::ostream & CLHEP::RandGauss::saveDistState ( std::ostream &  os)
staticinherited

Definition at line 331 of file RandGauss.cc.

331 {
332 int prec = os.precision(20);
333 std::vector<unsigned long> t(2);
334 os << distributionName() << "\n";
335 os << "Uvec\n";
336 if ( getFlag() ) {
338 os << "nextGauss_st " << getVal() << " " << t[0] << " " << t[1] << "\n";
339 } else {
340 os << "no_cached_nextGauss_st \n";
341 }
342 os.precision(prec);
343 return os;
344}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94
static bool getFlag()
Definition: RandGauss.cc:171
static double getVal()
Definition: RandGauss.cc:181
static const double prec
Definition: RanecuEngine.cc:61

References CLHEP::RandGauss::distributionName(), CLHEP::DoubConv::dto2longs(), CLHEP::RandGauss::getFlag(), CLHEP::RandGauss::getVal(), and CLHEP::prec.

Referenced by CLHEP::RandGauss::saveFullState().

◆ saveEngineStatus()

void CLHEP::RandGauss::saveEngineStatus ( const char  filename[] = "Config.conf")
staticinherited

Definition at line 191 of file RandGauss.cc.

191 {
192
193 // First save the engine status just like the base class would do:
194 getTheEngine()->saveStatus( filename );
195
196 // Now append the cached variate, if any:
197
198 std::ofstream outfile ( filename, std::ios::app );
199
200 if ( getFlag() ) {
201 std::vector<unsigned long> t(2);
203 outfile << "RANDGAUSS CACHED_GAUSSIAN: Uvec "
204 << getVal() << " " << t[0] << " " << t[1] << "\n";
205 } else {
206 outfile << "RANDGAUSS NO_CACHED_GAUSSIAN: 0 \n" ;
207 }
208
209} // saveEngineStatus
virtual void saveStatus(const char filename[]="Config.conf") const =0
app
Definition: demo.py:189

References demo::app, CLHEP::DoubConv::dto2longs(), CLHEP::RandGauss::getFlag(), CLHEP::HepRandom::getTheEngine(), CLHEP::RandGauss::getVal(), and CLHEP::HepRandomEngine::saveStatus().

◆ saveFullState()

std::ostream & CLHEP::RandGauss::saveFullState ( std::ostream &  os)
staticinherited

Definition at line 390 of file RandGauss.cc.

390 {
392 saveDistState(os);
393 return os;
394}
static std::ostream & saveFullState(std::ostream &os)
Definition: Random.cc:288
static std::ostream & saveDistState(std::ostream &os)
Definition: RandGauss.cc:331

References CLHEP::RandGauss::saveDistState(), and CLHEP::HepRandom::saveFullState().

Referenced by CLHEP::StaticRandomStates::save().

◆ saveStaticRandomStates()

std::ostream & CLHEP::HepRandom::saveStaticRandomStates ( std::ostream &  os)
staticinherited

Definition at line 298 of file Random.cc.

298 {
299 return StaticRandomStates::save(os);
300}
static std::ostream & save(std::ostream &os)

References CLHEP::StaticRandomStates::save().

◆ setF()

void CLHEP::RandGauss::setF ( bool  val)
inlineinherited

Definition at line 117 of file RandGauss.h.

117{set = val;}

References CLHEP::RandGauss::set.

◆ setFlag()

void CLHEP::RandGauss::setFlag ( bool  val)
staticinherited

◆ setTheEngine()

void CLHEP::HepRandom::setTheEngine ( HepRandomEngine theNewEngine)
staticinherited

Definition at line 273 of file Random.cc.

274{
275 theDefaults().theEngine.reset( theNewEngine, do_nothing_deleter() );
276}

References CLHEP::anonymous_namespace{Random.cc}::theDefaults(), and CLHEP::anonymous_namespace{Random.cc}::defaults::theEngine.

Referenced by CLHEP::StaticRandomStates::restore().

◆ setTheSeed()

void CLHEP::HepRandom::setTheSeed ( long  seed,
int  lxr = 3 
)
staticinherited

Definition at line 234 of file Random.cc.

235{
236 theDefaults().theEngine->setSeed(seed,lux);
237}
static constexpr double lux

References CLHEP::lux, CLHEP::anonymous_namespace{Random.cc}::theDefaults(), and CLHEP::anonymous_namespace{Random.cc}::defaults::theEngine.

◆ setTheSeeds()

void CLHEP::HepRandom::setTheSeeds ( const long *  seeds,
int  aux = -1 
)
staticinherited

◆ setVal()

void CLHEP::RandGauss::setVal ( double  nextVal)
staticprotectedinherited

Definition at line 186 of file RandGauss.cc.

187{
188 nextGauss_st = nextVal;
189}

References CLHEP::RandGauss::nextGauss_st.

Referenced by CLHEP::RandGauss::shoot().

◆ shoot() [1/6]

static float CLHEP::RandGaussZiggurat::shoot ( )
inlinestatic

Definition at line 49 of file RandGaussZiggurat.h.

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

Referenced by shootArray().

◆ shoot() [2/6]

static double CLHEP::RandGauss::shoot ( double  mean,
double  stdDev 
)
inlinestaticinherited

◆ shoot() [3/6]

static float CLHEP::RandGaussZiggurat::shoot ( float  mean,
float  stdDev 
)
inlinestatic

Definition at line 50 of file RandGaussZiggurat.h.

50{return shoot()*stdDev + mean;}

References shoot().

Referenced by shoot().

◆ shoot() [4/6]

static double CLHEP::RandGauss::shoot ( HepRandomEngine anEngine,
double  mean,
double  stdDev 
)
inlinestaticinherited

◆ shoot() [5/6]

static float CLHEP::RandGaussZiggurat::shoot ( HepRandomEngine anotherEngine)
inlinestatic

Definition at line 58 of file RandGaussZiggurat.h.

58{return ziggurat_RNOR(anotherEngine);}

References ziggurat_RNOR().

◆ shoot() [6/6]

static float CLHEP::RandGaussZiggurat::shoot ( HepRandomEngine anotherEngine,
float  mean,
float  stdDev 
)
inlinestatic

Definition at line 59 of file RandGaussZiggurat.h.

59{return shoot(anotherEngine)*stdDev + mean;}

References shoot().

Referenced by shoot().

◆ shootArray() [1/4]

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.

117{
118 for (int i=0; i<size; ++i) {
119 vect[i] = shoot(mean,stdDev);
120 }
121}

References shoot().

◆ shootArray() [2/4]

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.

110{
111 for (int i=0; i<size; ++i) {
112 vect[i] = shoot(mean,stdDev);
113 }
114}

References shoot().

◆ shootArray() [3/4]

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.

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

References shoot().

◆ shootArray() [4/4]

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.

124{
125 for (int i=0; i<size; ++i) {
126 vect[i] = shoot(anEngine,mean,stdDev);
127 }
128}

References shoot().

◆ showEngineStatus()

void CLHEP::HepRandom::showEngineStatus ( )
staticinherited

◆ ziggurat_init()

bool CLHEP::RandGaussZiggurat::ziggurat_init ( )
static

Definition at line 22 of file RandGaussZiggurat.cc.

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

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

Referenced by ziggurat_nfix(), and ziggurat_RNOR().

◆ ziggurat_nfix()

float CLHEP::RandGaussZiggurat::ziggurat_nfix ( long  hz,
HepRandomEngine anEngine 
)
staticprotected

Definition at line 73 of file RandGaussZiggurat.cc.

74{
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)std::abs(hz)<kn[iz]) return (hz*wn[iz]);
98 }
99}
static float ziggurat_UNI(HepRandomEngine *anEngine)
static unsigned long ziggurat_SHR3(HepRandomEngine *anEngine)

References fn, kn, wn, ziggurat_init(), ziggurat_is_init, ziggurat_SHR3(), and ziggurat_UNI().

Referenced by ziggurat_RNOR().

◆ ziggurat_RNOR()

static float CLHEP::RandGaussZiggurat::ziggurat_RNOR ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 115 of file RandGaussZiggurat.h.

115 {
117 long hz=(signed)ziggurat_SHR3(anEngine);
118 unsigned long iz=hz&127;
119 return ((unsigned long)std::abs(hz)<kn[iz]) ? hz*wn[iz] : ziggurat_nfix(hz,anEngine);
120 }
static float ziggurat_nfix(long hz, HepRandomEngine *anEngine)

References kn, wn, ziggurat_init(), ziggurat_is_init, ziggurat_nfix(), and ziggurat_SHR3().

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

◆ ziggurat_SHR3()

static unsigned long CLHEP::RandGaussZiggurat::ziggurat_SHR3 ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 113 of file RandGaussZiggurat.h.

113{return (unsigned int)(*anEngine);}

Referenced by ziggurat_nfix(), and ziggurat_RNOR().

◆ ziggurat_UNI()

static float CLHEP::RandGaussZiggurat::ziggurat_UNI ( HepRandomEngine anEngine)
inlinestaticprotected

Definition at line 114 of file RandGaussZiggurat.h.

114{return float(anEngine->flat());}

References CLHEP::HepRandomEngine::flat().

Referenced by ziggurat_nfix().

Field Documentation

◆ defaultMean

double CLHEP::RandGauss::defaultMean
protectedinherited

◆ defaultStdDev

double CLHEP::RandGauss::defaultStdDev
protectedinherited

◆ fe

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::fe
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

Referenced by ziggurat_init().

◆ fn

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::fn
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

Referenced by ziggurat_init(), and ziggurat_nfix().

◆ ke

CLHEP_THREAD_LOCAL unsigned long CLHEP::RandGaussZiggurat::ke
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

Referenced by ziggurat_init().

◆ kn

CLHEP_THREAD_LOCAL unsigned long CLHEP::RandGaussZiggurat::kn
staticprotected

Definition at line 108 of file RandGaussZiggurat.h.

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

◆ localEngine

std::shared_ptr<HepRandomEngine> CLHEP::RandGauss::localEngine
protectedinherited

◆ nextGauss

double CLHEP::RandGauss::nextGauss
privateinherited

◆ nextGauss_st

CLHEP_THREAD_LOCAL double CLHEP::RandGauss::nextGauss_st = 0.0
staticprivateinherited

◆ seedTable

const long CLHEP::HepRandom::seedTable
staticprotectedinherited

Definition at line 156 of file Random.h.

◆ set

bool CLHEP::RandGauss::set
privateinherited

◆ set_st

CLHEP_THREAD_LOCAL bool CLHEP::RandGauss::set_st = false
staticprivateinherited

Definition at line 162 of file RandGauss.h.

Referenced by CLHEP::RandGauss::getFlag(), and CLHEP::RandGauss::setFlag().

◆ we

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::we
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

Referenced by ziggurat_init().

◆ wn

CLHEP_THREAD_LOCAL float CLHEP::RandGaussZiggurat::wn
staticprotected

Definition at line 109 of file RandGaussZiggurat.h.

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

◆ ziggurat_is_init

CLHEP_THREAD_LOCAL bool CLHEP::RandGaussZiggurat::ziggurat_is_init = false
staticprotected

Definition at line 111 of file RandGaussZiggurat.h.

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


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