CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
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 lxr=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 40 of file RandGeneral.h.

Constructor & Destructor Documentation

◆ RandGeneral() [1/3]

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

Definition at line 68 of file RandGeneral.cc.

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

◆ RandGeneral() [2/3]

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

Definition at line 79 of file RandGeneral.cc.

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

◆ RandGeneral() [3/3]

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

Definition at line 91 of file RandGeneral.cc.

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

◆ ~RandGeneral()

CLHEP::RandGeneral::~RandGeneral ( )
virtual

Definition at line 176 of file RandGeneral.cc.

176 {
177}

Member Function Documentation

◆ distributionName()

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

Definition at line 126 of file RandGeneral.h.

126{return "RandGeneral";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 61 of file RandGeneral.cc.

61{return *localEngine;}

Referenced by checkRandGeneralDistribution().

◆ fire()

double CLHEP::RandGeneral::fire ( )

Referenced by fireArray(), and testRandGeneral().

◆ fireArray()

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

Definition at line 242 of file RandGeneral.cc.

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

◆ get()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 278 of file RandGeneral.cc.

278 {
279 std::string inName;
280 is >> inName;
281 if (inName != name()) {
282 is.clear(std::ios::badbit | is.rdstate());
283 std::cerr << "Mismatch when expecting to read state of a "
284 << name() << " distribution\n"
285 << "Name found was " << inName
286 << "\nistream is left in the badbit state\n";
287 return is;
288 }
289 if (possibleKeywordInput(is, "Uvec", nBins)) {
290 std::vector<unsigned long> t(2);
291 is >> nBins >> oneOverNbins >> InterpolationType;
292 is >> t[0] >> t[1]; oneOverNbins = DoubConv::longs2double(t);
293 theIntegralPdf.resize(nBins+1);
294 for (unsigned int i=0; i<theIntegralPdf.size(); ++i) {
295 is >> theIntegralPdf[i] >> t[0] >> t[1];
296 theIntegralPdf[i] = DoubConv::longs2double(t);
297 }
298 return is;
299 }
300 // is >> nBins encompassed by possibleKeywordInput
301 is >> oneOverNbins >> InterpolationType;
302 theIntegralPdf.resize(nBins+1);
303 for (unsigned int i=0; i<theIntegralPdf.size(); ++i) is >> theIntegralPdf[i];
304 return is;
305}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110
std::string name() const
Definition: RandGeneral.cc:60
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:168

◆ name()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 60 of file RandGeneral.cc.

60{return "RandGeneral";}

Referenced by checkRandGeneralDistribution(), 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 251 of file RandGeneral.cc.

251 {
252 long pr=os.precision(20);
253 std::vector<unsigned long> t(2);
254 os << " " << name() << "\n";
255 os << "Uvec" << "\n";
256 os << nBins << " " << oneOverNbins << " " << InterpolationType << "\n";
257 t = DoubConv::dto2longs(oneOverNbins);
258 os << t[0] << " " << t[1] << "\n";
259 assert (static_cast<int>(theIntegralPdf.size())==nBins+1);
260 for (unsigned int i=0; i<theIntegralPdf.size(); ++i) {
261 t = DoubConv::dto2longs(theIntegralPdf[i]);
262 os << theIntegralPdf[i] << " " << t[0] << " " << t[1] << "\n";
263 }
264 os.precision(pr);
265 return os;
266#ifdef REMOVED
267 long pr=os.precision(20);
268 os << " " << name() << "\n";
269 os << nBins << " " << oneOverNbins << " " << InterpolationType << "\n";
270 assert (static_cast<int>(theIntegralPdf.size())==nBins+1);
271 for (unsigned int i=0; i<theIntegralPdf.size(); ++i)
272 os << theIntegralPdf[i] << "\n";
273 os.precision(pr);
274 return os;
275#endif
276}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94

◆ shoot() [1/2]

double CLHEP::RandGeneral::shoot ( )
inline

Referenced by shootArray().

◆ 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 232 of file RandGeneral.cc.

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

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