Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
CLHEP::RandGeneral Class Reference

#include <RandGeneral.h>

+ Inheritance diagram for CLHEP::RandGeneral:

Public Member Functions

 RandGeneral (const double *aProbFunc, int theProbSize, int IntType=0)
 
 RandGeneral (HepRandomEngine &anEngine, const double *aProbFunc, int theProbSize, int IntType=0)
 
 RandGeneral (HepRandomEngine *anEngine, const double *aProbFunc, int theProbSize, int IntType=0)
 
virtual ~RandGeneral ()
 
double shoot ()
 
void shootArray (const int size, double *vect)
 
double shoot (HepRandomEngine *anEngine)
 
void shootArray (HepRandomEngine *anEngine, const int size, double *vect)
 
double fire ()
 
void fireArray (const int size, double *vect)
 
double operator() ()
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
std::string name () const
 
HepRandomEngineengine ()
 
- 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)
 
virtual double operator() ()
 
virtual std::string name () const
 
virtual HepRandomEngineengine ()
 
virtual std::ostream & put (std::ostream &os) const
 
virtual std::istream & get (std::istream &is)
 

Static Public Member Functions

static std::string distributionName ()
 
- 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 ()
 

Additional Inherited Members

- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Author

Definition at line 38 of file RandGeneral.h.

Constructor & Destructor Documentation

◆ RandGeneral() [1/3]

CLHEP::RandGeneral::RandGeneral ( const double *  aProbFunc,
int  theProbSize,
int  IntType = 0 
)

Definition at line 66 of file RandGeneral.cc.

69 : HepRandom(),
70 localEngine(HepRandom::getTheEngine(), do_nothing_deleter()),
71 nBins(theProbSize),
72 InterpolationType(IntType)
73{
74 prepareTable(aProbFunc);
75}
static HepRandomEngine * getTheEngine()
Definition: Random.cc:268

◆ RandGeneral() [2/3]

CLHEP::RandGeneral::RandGeneral ( HepRandomEngine anEngine,
const double *  aProbFunc,
int  theProbSize,
int  IntType = 0 
)

Definition at line 77 of file RandGeneral.cc.

81: HepRandom(),
82 localEngine(&anEngine, do_nothing_deleter()),
83 nBins(theProbSize),
84 InterpolationType(IntType)
85{
86 prepareTable(aProbFunc);
87}

◆ RandGeneral() [3/3]

CLHEP::RandGeneral::RandGeneral ( HepRandomEngine anEngine,
const double *  aProbFunc,
int  theProbSize,
int  IntType = 0 
)

Definition at line 89 of file RandGeneral.cc.

93: HepRandom(),
94 localEngine(anEngine),
95 nBins(theProbSize),
96 InterpolationType(IntType)
97{
98 prepareTable(aProbFunc);
99}

◆ ~RandGeneral()

CLHEP::RandGeneral::~RandGeneral ( )
virtual

Definition at line 174 of file RandGeneral.cc.

174 {
175}

Member Function Documentation

◆ distributionName()

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

Definition at line 124 of file RandGeneral.h.

124{return "RandGeneral";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 59 of file RandGeneral.cc.

59{return *localEngine;}

◆ fire()

double CLHEP::RandGeneral::fire ( )

Referenced by fireArray().

◆ fireArray()

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

Definition at line 240 of file RandGeneral.cc.

241{
242 int i;
243
244 for (i=0; i<size; ++i) {
245 vect[i] = fire();
246 }
247}

◆ get()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 266 of file RandGeneral.cc.

266 {
267 std::string inName;
268 is >> inName;
269 if (inName != name()) {
270 is.clear(std::ios::badbit | is.rdstate());
271 std::cerr << "Mismatch when expecting to read state of a "
272 << name() << " distribution\n"
273 << "Name found was " << inName
274 << "\nistream is left in the badbit state\n";
275 return is;
276 }
277 if (possibleKeywordInput(is, "Uvec", nBins)) {
278 std::vector<unsigned long> t(2);
279 is >> nBins >> oneOverNbins >> InterpolationType;
280 is >> t[0] >> t[1]; oneOverNbins = DoubConv::longs2double(t);
281 theIntegralPdf.resize(nBins+1);
282 for (unsigned int i=0; i<theIntegralPdf.size(); ++i) {
283 is >> theIntegralPdf[i] >> t[0] >> t[1];
284 theIntegralPdf[i] = DoubConv::longs2double(t);
285 }
286 return is;
287 }
288 // is >> nBins encompassed by possibleKeywordInput
289 is >> oneOverNbins >> InterpolationType;
290 theIntegralPdf.resize(nBins+1);
291 for (unsigned int i=0; i<theIntegralPdf.size(); ++i) is >> theIntegralPdf[i];
292 return is;
293}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110
std::string name() const
Definition: RandGeneral.cc:58
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:166

◆ name()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 58 of file RandGeneral.cc.

58{return "RandGeneral";}

Referenced by get(), and put().

◆ operator()()

double CLHEP::RandGeneral::operator() ( )
virtual

Reimplemented from CLHEP::HepRandom.

◆ put()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 249 of file RandGeneral.cc.

249 {
250 int pr=os.precision(20);
251 std::vector<unsigned long> t(2);
252 os << " " << name() << "\n";
253 os << "Uvec" << "\n";
254 os << nBins << " " << oneOverNbins << " " << InterpolationType << "\n";
255 t = DoubConv::dto2longs(oneOverNbins);
256 os << t[0] << " " << t[1] << "\n";
257 assert (static_cast<int>(theIntegralPdf.size())==nBins+1);
258 for (unsigned int i=0; i<theIntegralPdf.size(); ++i) {
259 t = DoubConv::dto2longs(theIntegralPdf[i]);
260 os << theIntegralPdf[i] << " " << t[0] << " " << t[1] << "\n";
261 }
262 os.precision(pr);
263 return os;
264}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94

◆ shoot() [1/2]

double CLHEP::RandGeneral::shoot ( )
inline

◆ shoot() [2/2]

double CLHEP::RandGeneral::shoot ( HepRandomEngine anEngine)

◆ shootArray() [1/2]

void CLHEP::RandGeneral::shootArray ( const int  size,
double *  vect 
)
inline

◆ shootArray() [2/2]

void CLHEP::RandGeneral::shootArray ( HepRandomEngine anEngine,
const int  size,
double *  vect 
)

Definition at line 230 of file RandGeneral.cc.

232{
233 int i;
234
235 for (i=0; i<size; ++i) {
236 vect[i] = shoot(anEngine);
237 }
238}

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