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

#include <RandStudentT.h>

Inheritance diagram for CLHEP::RandStudentT:
CLHEP::HepRandom

Public Member Functions

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

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 (double a)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, double a)
 
static void shootArray (const int size, double *vect, double a=1.0)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double a=1.0)
 
static void showEngineStatus ()
 

Static Protected Attributes

static const long seedTable [215][2]
 

Private Attributes

double defaultA
 
std::shared_ptr< HepRandomEnginelocalEngine
 

Detailed Description

Author

Definition at line 41 of file RandStudentT.h.

Constructor & Destructor Documentation

◆ RandStudentT() [1/2]

CLHEP::RandStudentT::RandStudentT ( HepRandomEngine anEngine,
double  a = 1.0 
)
inline

◆ RandStudentT() [2/2]

CLHEP::RandStudentT::RandStudentT ( HepRandomEngine anEngine,
double  a = 1.0 
)
inline

◆ ~RandStudentT()

CLHEP::RandStudentT::~RandStudentT ( )
virtual

Definition at line 33 of file RandStudentT.cc.

34{
35}

Member Function Documentation

◆ createInstance()

int CLHEP::HepRandom::createInstance ( )
staticinherited

◆ distributionName()

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

Definition at line 99 of file RandStudentT.h.

99{return "RandStudentT";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 31 of file RandStudentT.cc.

31{return *localEngine;}
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandStudentT.h:105

References localEngine.

◆ fire() [1/2]

double CLHEP::RandStudentT::fire ( )
inline

Referenced by fireArray(), and operator()().

◆ fire() [2/2]

double CLHEP::RandStudentT::fire ( double  a)

Definition at line 101 of file RandStudentT.cc.

101 {
102
103 double u,v,w;
104
105 do
106 {
107 u = 2.0 * localEngine->flat() - 1.0;
108 v = 2.0 * localEngine->flat() - 1.0;
109 }
110 while ((w = u * u + v * v) > 1.0);
111
112 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
113}

References localEngine.

◆ fireArray() [1/2]

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

Definition at line 115 of file RandStudentT.cc.

116{
117 for( double* v = vect; v != vect + size; ++v )
118 *v = fire(defaultA);
119}

References defaultA, and fire().

◆ fireArray() [2/2]

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

Definition at line 121 of file RandStudentT.cc.

123{
124 for( double* v = vect; v != vect + size; ++v )
125 *v = fire(a);
126}

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

Reimplemented from CLHEP::HepRandom.

Definition at line 153 of file RandStudentT.cc.

153 {
154 std::string inName;
155 is >> inName;
156 if (inName != name()) {
157 is.clear(std::ios::badbit | is.rdstate());
158 std::cerr << "Mismatch when expecting to read state of a "
159 << name() << " distribution\n"
160 << "Name found was " << inName
161 << "\nistream is left in the badbit state\n";
162 return is;
163 }
164 if (possibleKeywordInput(is, "Uvec", defaultA)) {
165 std::vector<unsigned long> t(2);
166 is >> defaultA >> t[0] >> t[1]; defaultA = DoubConv::longs2double(t);
167 return is;
168 }
169 // is >> defaultA encompassed by possibleKeywordInput
170 return is;
171}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110
std::string name() const
Definition: RandStudentT.cc:30
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:166

References defaultA, CLHEP::DoubConv::longs2double(), name(), and CLHEP::possibleKeywordInput().

◆ 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::RandStudentT::name ( ) const
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 30 of file RandStudentT.cc.

30{return "RandStudentT";}

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

◆ operator()() [1/2]

double CLHEP::RandStudentT::operator() ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 37 of file RandStudentT.cc.

37 {
38 return fire( defaultA );
39}

References defaultA, and fire().

◆ operator()() [2/2]

double CLHEP::RandStudentT::operator() ( double  a)

Definition at line 41 of file RandStudentT.cc.

41 {
42 return fire( a );
43}

References fire().

◆ put()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 142 of file RandStudentT.cc.

142 {
143 int pr=os.precision(20);
144 std::vector<unsigned long> t(2);
145 os << " " << name() << "\n";
146 os << "Uvec" << "\n";
148 os << defaultA << " " << t[0] << " " << t[1] << "\n";
149 os.precision(pr);
150 return os;
151}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94

References defaultA, CLHEP::DoubConv::dto2longs(), and 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/4]

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

Referenced by shootArray().

◆ shoot() [2/4]

double CLHEP::RandStudentT::shoot ( double  a)
static

Definition at line 45 of file RandStudentT.cc.

45 {
46/******************************************************************
47 * *
48 * Student-t Distribution - Polar Method *
49 * *
50 ******************************************************************
51 * *
52 * The polar method of Box/Muller for generating Normal variates *
53 * is adapted to the Student-t distribution. The two generated *
54 * variates are not independent and the expected no. of uniforms *
55 * per variate is 2.5464. *
56 * *
57 ******************************************************************
58 * *
59 * FUNCTION : - tpol samples a random number from the *
60 * Student-t distribution with parameter a > 0. *
61 * REFERENCE : - R.W. Bailey (1994): Polar generation of random *
62 * variates with the t-distribution, Mathematics *
63 * of Computation 62, 779-781. *
64 * SUBPROGRAM : - ... (0,1)-Uniform generator *
65 * *
66 * *
67 * Implemented by F. Niederl, 1994 *
68 ******************************************************************/
69
70 double u,v,w;
71
72// Check for valid input value
73
74 if( a < 0.0) return (DBL_MAX);
75
76 do
77 {
78 u = 2.0 * HepRandom::getTheEngine()->flat() - 1.0;
79 v = 2.0 * HepRandom::getTheEngine()->flat() - 1.0;
80 }
81 while ((w = u * u + v * v) > 1.0);
82
83 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
84}
virtual double flat()=0
#define DBL_MAX
Definition: templates.hh:62

References DBL_MAX, CLHEP::HepRandomEngine::flat(), and CLHEP::HepRandom::getTheEngine().

◆ shoot() [3/4]

static double CLHEP::RandStudentT::shoot ( HepRandomEngine anEngine)
inlinestatic

◆ shoot() [4/4]

double CLHEP::RandStudentT::shoot ( HepRandomEngine anEngine,
double  a 
)
static

Definition at line 128 of file RandStudentT.cc.

128 {
129
130 double u,v,w;
131
132 do
133 {
134 u = 2.0 * anEngine->flat() - 1.0;
135 v = 2.0 * anEngine->flat() - 1.0;
136 }
137 while ((w = u * u + v * v) > 1.0);
138
139 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
140}

References CLHEP::HepRandomEngine::flat().

◆ shootArray() [1/2]

void CLHEP::RandStudentT::shootArray ( const int  size,
double *  vect,
double  a = 1.0 
)
static

Definition at line 86 of file RandStudentT.cc.

88{
89 for( double* v = vect; v != vect + size; ++v )
90 *v = shoot(a);
91}
static double shoot()

References shoot().

◆ shootArray() [2/2]

void CLHEP::RandStudentT::shootArray ( HepRandomEngine anEngine,
const int  size,
double *  vect,
double  a = 1.0 
)
static

Definition at line 93 of file RandStudentT.cc.

96{
97 for( double* v = vect; v != vect + size; ++v )
98 *v = shoot(anEngine,a);
99}

References shoot().

◆ showEngineStatus()

void CLHEP::HepRandom::showEngineStatus ( )
staticinherited

Field Documentation

◆ defaultA

double CLHEP::RandStudentT::defaultA
private

Definition at line 106 of file RandStudentT.h.

Referenced by fireArray(), get(), operator()(), and put().

◆ localEngine

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

Definition at line 105 of file RandStudentT.h.

Referenced by engine(), and fire().

◆ 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: