Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCL::Random Class Reference

#include <G4INCLRandom.hh>

Static Public Member Functions

static void setGenerator (G4INCL::IRandomGenerator *aGenerator)
 
static void setSeeds (const SeedVector &sv)
 
static SeedVector getSeeds ()
 
static G4double shoot ()
 
static G4double shoot0 ()
 
static G4double shoot1 ()
 
static G4double gauss (G4double sigma=1.)
 
static ThreeVector normVector (G4double norm=1.)
 
static ThreeVector sphereVector (G4double rmax=1.)
 
static ThreeVector gaussVector (G4double sigma=1.)
 Generate Gaussianly-distributed ThreeVectors.
 
static void deleteGenerator ()
 
static G4bool isInitialized ()
 

Detailed Description

Definition at line 58 of file G4INCLRandom.hh.

Member Function Documentation

◆ deleteGenerator()

static void G4INCL::Random::deleteGenerator ( )
inlinestatic

Delete the generator

Definition at line 152 of file G4INCLRandom.hh.

152 {
153 delete theGenerator;
154 theGenerator = 0;
155 }

Referenced by G4INCL::INCL::~INCL().

◆ gauss()

G4double G4INCL::Random::gauss ( G4double  sigma = 1.)
static

Generate random numbers using gaussian distribution.

Definition at line 53 of file G4INCLRandom.cc.

53 {
54 // generate a Gaussian random number with standard deviation sigma
55 // uses the flat() and flat0() methods
56 static G4bool generated = false;
57 static G4double u, v;
58
59 if( !generated )
60 {
61 u = shoot0();
62 v = Math::twoPi*shoot();
63 generated = true;
64 return sigma*std::sqrt(-2*std::log(u))*std::cos(v);
65 }
66 else
67 {
68 generated = false;
69 return sigma*std::sqrt(-2*std::log(u))*std::sin(v);
70 }
71 }
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
static G4double shoot()
Definition: G4INCLRandom.hh:99
static G4double shoot0()
const G4double twoPi

Referenced by gaussVector().

◆ gaussVector()

static ThreeVector G4INCL::Random::gaussVector ( G4double  sigma = 1.)
inlinestatic

Generate Gaussianly-distributed ThreeVectors.

Generate ThreeVectors that are distributed as a three-dimensional Gaussian of the given sigma.

Definition at line 144 of file G4INCLRandom.hh.

144 {
145 const G4double sigmax = sigma * Math::oneOverSqrtThree;
146 return ThreeVector(gauss(sigmax), gauss(sigmax), gauss(sigmax));
147 }
static G4double gauss(G4double sigma=1.)
Definition: G4INCLRandom.cc:53
const G4double oneOverSqrtThree

Referenced by G4INCL::DeJongSpin::shoot().

◆ getSeeds()

static SeedVector G4INCL::Random::getSeeds ( )
inlinestatic

Get the seeds of the current generator.

Definition at line 92 of file G4INCLRandom.hh.

92 {
93 return theGenerator->getSeeds();
94 };
virtual SeedVector getSeeds() const =0

◆ isInitialized()

static G4bool G4INCL::Random::isInitialized ( )
inlinestatic

Check if the generator is initialized.

Definition at line 160 of file G4INCLRandom.hh.

160 {
161 if(theGenerator == 0) return false;
162 return true;
163 };

Referenced by setGenerator().

◆ normVector()

ThreeVector G4INCL::Random::normVector ( G4double  norm = 1.)
static

Generate isotropically-distributed ThreeVectors of given norm.

Definition at line 73 of file G4INCLRandom.cc.

73 {
74
75 const G4double ctheta = (1.-2.*shoot());
76 const G4double stheta = std::sqrt(1.-ctheta*ctheta);
77 const G4double phi = Math::twoPi*shoot();
78 return ThreeVector(
79 norm * stheta * std::cos(phi),
80 norm * stheta * std::sin(phi),
81 norm * ctheta);
82
83 }

Referenced by G4INCL::RecombinationChannel::getFinalState(), and sphereVector().

◆ setGenerator()

static void G4INCL::Random::setGenerator ( G4INCL::IRandomGenerator aGenerator)
inlinestatic

Set the random number generator implementation to be used globally by INCL.

See also
G4INCL::IRandomGenerator

Definition at line 72 of file G4INCLRandom.hh.

72 {
73 if(isInitialized()) {
74 ERROR("INCL random number generator already initialized." << std::endl);
75 } else {
76 theGenerator = aGenerator;
77 }
78 };
#define ERROR(x)
static G4bool isInitialized()

Referenced by G4INCL::INCL::INCL().

◆ setSeeds()

static void G4INCL::Random::setSeeds ( const SeedVector sv)
inlinestatic

Set the seeds of the current generator.

Definition at line 84 of file G4INCLRandom.hh.

84 {
85 theGenerator->setSeeds(sv);
86 };
virtual void setSeeds(const SeedVector &)=0

◆ shoot()

◆ shoot0()

static G4double G4INCL::Random::shoot0 ( )
inlinestatic

Return a random number in the ]0,1] interval

Definition at line 104 of file G4INCLRandom.hh.

104 {
105 G4double r;
106 while( (r=shoot()) <= 0. )
107 ;
108 return r;
109 }

Referenced by gauss(), and sphereVector().

◆ shoot1()

static G4double G4INCL::Random::shoot1 ( )
inlinestatic

Return a random number in the [0,1[ interval

Definition at line 114 of file G4INCLRandom.hh.

114 {
115 G4double r;
116 while( (r=shoot()) >= 1. )
117 ;
118 return r;
119 }

Referenced by G4INCL::shuffleComponentsHelper().

◆ sphereVector()

static ThreeVector G4INCL::Random::sphereVector ( G4double  rmax = 1.)
inlinestatic

Generate ThreeVectors that are uniformly distributed in a sphere of radius rmax.

Definition at line 135 of file G4INCLRandom.hh.

135 {
136 return normVector( rmax*Math::pow13(shoot0()) );
137 }
static ThreeVector normVector(G4double norm=1.)
Definition: G4INCLRandom.cc:73
G4double pow13(G4double x)

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