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

#include <RandLandau.h>

Inheritance diagram for CLHEP::RandLandau:
CLHEP::HepRandom

Public Member Functions

HepRandomEngineengine ()
 
double fire ()
 
void fireArray (const int size, double *vect)
 
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)
 
std::string name () const
 
double operator() ()
 
std::ostream & put (std::ostream &os) const
 
 RandLandau (HepRandomEngine &anEngine)
 
 RandLandau (HepRandomEngine *anEngine)
 
virtual ~RandLandau ()
 

Static Public Member Functions

static int createInstance ()
 
static std::string distributionName ()
 
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 setTheEngine (HepRandomEngine *theNewEngine)
 
static void setTheSeed (long seed, int lxr=3)
 
static void setTheSeeds (const long *seeds, int aux=-1)
 
static double shoot ()
 
static double shoot (HepRandomEngine *anotherEngine)
 
static void shootArray (const int size, double *vect)
 
static void shootArray (HepRandomEngine *anotherEngine, const int size, double *vect)
 
static void showEngineStatus ()
 

Static Protected Member Functions

static double transform (double r)
 
static double transformSmall (double r)
 

Static Protected Attributes

static const long seedTable [215][2]
 

Private Attributes

std::shared_ptr< HepRandomEnginelocalEngine
 

Detailed Description

Author

Definition at line 41 of file RandLandau.h.

Constructor & Destructor Documentation

◆ RandLandau() [1/2]

CLHEP::RandLandau::RandLandau ( HepRandomEngine anEngine)
inline

◆ RandLandau() [2/2]

CLHEP::RandLandau::RandLandau ( HepRandomEngine anEngine)
inline

◆ ~RandLandau()

CLHEP::RandLandau::~RandLandau ( )
virtual

Definition at line 29 of file RandLandau.cc.

29 {
30}

Member Function Documentation

◆ createInstance()

int CLHEP::HepRandom::createInstance ( )
staticinherited

◆ distributionName()

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

Definition at line 98 of file RandLandau.h.

98{return "RandLandau";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 27 of file RandLandau.cc.

27{return *localEngine;}
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandLandau.h:109

References localEngine.

◆ fire()

double CLHEP::RandLandau::fire ( )
inline

Referenced by fireArray().

◆ fireArray()

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

Definition at line 46 of file RandLandau.cc.

47{
48 for( double* v = vect; v != vect + size; ++v )
49 *v = fire();
50}

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::RandLandau::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 370 of file RandLandau.cc.

370 {
371 std::string inName;
372 is >> inName;
373 if (inName != name()) {
374 is.clear(std::ios::badbit | is.rdstate());
375 std::cerr << "Mismatch when expecting to read state of a "
376 << name() << " distribution\n"
377 << "Name found was " << inName
378 << "\nistream is left in the badbit state\n";
379 return is;
380 }
381 return is;
382}
std::string name() const
Definition: RandLandau.cc:26

References name().

◆ 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().

◆ name()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 26 of file RandLandau.cc.

26{return "RandLandau";}

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

◆ operator()()

double CLHEP::RandLandau::operator() ( )
inlinevirtual

Reimplemented from CLHEP::HepRandom.

◆ put()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 363 of file RandLandau.cc.

363 {
364 int pr=os.precision(20);
365 os << " " << name() << "\n";
366 os.precision(pr);
367 return os;
368}

References name().

◆ restoreDistState()

static std::istream & CLHEP::HepRandom::restoreDistState ( std::istream &  is)
inlinestaticinherited

Definition at line 136 of file Random.h.

136{return is;}

◆ restoreEngineStatus()

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

Definition at line 283 of file Random.cc.

284{
285 theDefaults().theEngine->restoreStatus( filename );
286}

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

◆ restoreFullState()

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

Definition at line 293 of file Random.cc.

293 {
294 is >> *getTheEngine();
295 return is;
296}
static HepRandomEngine * getTheEngine()
Definition: Random.cc:268

Referenced by CLHEP::RandFlat::restoreFullState(), and CLHEP::RandGauss::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()

static std::ostream & CLHEP::HepRandom::saveDistState ( std::ostream &  os)
inlinestaticinherited

Definition at line 133 of file Random.h.

133{return os;}

◆ saveEngineStatus()

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

◆ saveFullState()

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

◆ 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().

◆ 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

◆ shoot() [1/2]

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

Referenced by shootArray().

◆ shoot() [2/2]

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

◆ shootArray() [1/2]

void CLHEP::RandLandau::shootArray ( const int  size,
double *  vect 
)
static

Definition at line 32 of file RandLandau.cc.

34{
35 for( double* v = vect; v != vect + size; ++v )
36 *v = shoot();
37}
static double shoot()

References shoot().

◆ shootArray() [2/2]

void CLHEP::RandLandau::shootArray ( HepRandomEngine anotherEngine,
const int  size,
double *  vect 
)
static

Definition at line 39 of file RandLandau.cc.

41{
42 for( double* v = vect; v != vect + size; ++v )
43 *v = shoot(anEngine);
44}

References shoot().

◆ showEngineStatus()

void CLHEP::HepRandom::showEngineStatus ( )
staticinherited

◆ transform()

double CLHEP::RandLandau::transform ( double  r)
staticprotected

Definition at line 285 of file RandLandau.cc.

285 {
286
287 double u = r * TABLE_MULTIPLIER;
288 int index = int(u);
289 double du = u - index;
290
291 // du is scaled such that the we dont have to multiply by TABLE_INTERVAL
292 // when interpolating.
293
294 // Five cases:
295 // A) Between .070 and .800 the function is so smooth, straight
296 // linear interpolation is adequate.
297 // B) Between .007 and .070, and between .800 and .980, quadratic
298 // interpolation is used. This requires the same 4 points as
299 // a cubic spline (thus we need .006 and .981 and .982) but
300 // the quadratic interpolation is accurate enough and quicker.
301 // C) Below .007 an asymptotic expansion for low negative lambda
302 // (involving two logs) is used; there is a pade-style correction
303 // factor.
304 // D) Above .980, a simple pade approximation is made (asymptotic to
305 // 1/(1-r)), but...
306 // E) the coefficients in that pade are different above r=.999.
307
308 if ( index >= 70 && index <= 800 ) { // (A)
309
310 double f0 = inverseLandau [index];
311 double f1 = inverseLandau [index+1];
312 return f0 + du * (f1 - f0);
313
314 } else if ( index >= 7 && index <= 980 ) { // (B)
315
316 double f_1 = inverseLandau [index-1];
317 double f0 = inverseLandau [index];
318 double f1 = inverseLandau [index+1];
319 double f2 = inverseLandau [index+2];
320
321 return f0 + du * (f1 - f0 - .25*(1-du)* (f2 -f1 - f0 + f_1) );
322
323 } else if ( index < 7 ) { // (C)
324
325 const double n0 = 0.99858950;
326 const double n1 = 34.5213058; const double d1 = 34.1760202;
327 const double n2 = 17.0854528; const double d2 = 4.01244582;
328
329 double logr = std::log(r);
330 double x = 1/logr;
331 double x2 = x*x;
332
333 double pade = (n0 + n1*x + n2*x2) / (1.0 + d1*x + d2*x2);
334
335 return ( - std::log ( -.91893853 - logr ) -1 ) * pade;
336
337 } else if ( index <= 999 ) { // (D)
338
339 const double n0 = 1.00060006;
340 const double n1 = 263.991156; const double d1 = 257.368075;
341 const double n2 = 4373.20068; const double d2 = 3414.48018;
342
343 double x = 1-r;
344 double x2 = x*x;
345
346 return (n0 + n1*x + n2*x2) / (x * (1.0 + d1*x + d2*x2));
347
348 } else { // (E)
349
350 const double n0 = 1.00001538;
351 const double n1 = 6075.14119; const double d1 = 6065.11919;
352 const double n2 = 734266.409; const double d2 = 694021.044;
353
354 double x = 1-r;
355 double x2 = x*x;
356
357 return (n0 + n1*x + n2*x2) / (x * (1.0 + d1*x + d2*x2));
358
359 }
360
361} // transform()
static const G4double d1
static const G4double d2
static const float inverseLandau[TABLE_END+1]
Definition: RandLandau.cc:73
static const float TABLE_MULTIPLIER
Definition: RandLandau.cc:61

References d1, d2, CLHEP::inverseLandau, and CLHEP::TABLE_MULTIPLIER.

◆ transformSmall()

static double CLHEP::RandLandau::transformSmall ( double  r)
staticprotected

Field Documentation

◆ localEngine

std::shared_ptr<HepRandomEngine> CLHEP::RandLandau::localEngine
private

Definition at line 109 of file RandLandau.h.

Referenced by engine().

◆ seedTable

const long CLHEP::HepRandom::seedTable
staticprotectedinherited

Definition at line 156 of file Random.h.


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