46 bool RandGauss::set_st =
false;
47 double RandGauss::nextGauss_st = 0.0;
57 return fire( mean, stdDev );
77 v1 = 2.0 * anEngine->
flat() - 1.0;
78 v2 = 2.0 * anEngine->
flat() - 1.0;
82 fac = std::sqrt(-2.0*std::log(r)/r);
90 double mean,
double stdDev )
92 for(
double*
v = vect;
v != vect + size; ++
v )
107 double v1,v2,fac,val;
110 v1 = 2.0 * anEngine->
flat() - 1.0;
111 v2 = 2.0 * anEngine->
flat() - 1.0;
115 fac = std::sqrt( -2.0*std::log(r)/r);
123 const int size,
double* vect,
124 double mean,
double stdDev )
126 for(
double*
v = vect;
v != vect + size; ++
v )
127 *
v =
shoot(anEngine,mean,stdDev);
141 double v1,v2,fac,val;
149 fac = std::sqrt(-2.0*std::log(r)/r);
158 for(
double*
v = vect;
v != vect + size; ++
v )
163 double mean,
double stdDev )
165 for(
double*
v = vect;
v != vect + size; ++
v )
166 *
v =
fire( mean, stdDev );
179 std::vector<unsigned long> t(2);
181 outfile <<
"RANDGAUSS CACHED_GAUSSIAN: Uvec "
182 <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
184 outfile <<
"RANDGAUSS NO_CACHED_GAUSSIAN: 0 \n" ;
196 std::ifstream infile ( filename, std::ios::in );
199 char inputword[] =
"NO_KEYWORD ";
203 if (strcmp(inputword,
"RANDGAUSS")==0)
break;
204 if (infile.eof())
break;
212 if (strcmp(inputword,
"RANDGAUSS")==0) {
216 if (strcmp(setword,
"CACHED_GAUSSIAN:") ==0) {
218 std::vector<unsigned long> t(2);
219 infile >> nextGauss_st >> t[0] >> t[1];
226 infile >> nextGauss_st;
237 os <<
name() <<
"\n";
238 int prec = os.precision(20);
239 std::vector<unsigned long> t(2);
242 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
247 os <<
"nextGauss " << nextGauss <<
" " << t[0] <<
" " << t[1] <<
"\n";
249 os <<
"no_cached_nextGauss \n";
258 if (inName !=
name()) {
259 is.clear(std::ios::badbit | is.rdstate());
260 std::cerr <<
"Mismatch when expecting to read state of a "
261 <<
name() <<
" distribution\n"
262 <<
"Name found was " << inName
263 <<
"\nistream is left in the badbit state\n";
269 std::vector<unsigned long> t(2);
275 if (ng ==
"nextGauss") {
283 if ( (!is) || (c1 !=
"Mean:") || (c2 !=
"Sigma:") ) {
284 std::cerr <<
"i/o problem while expecting to read state of a "
285 <<
name() <<
" distribution\n"
286 <<
"default mean and/or sigma could not be read\n";
289 is >> c1 >> c2 >> nextGauss;
290 if ( (!is) || (c1 !=
"RANDGAUSS") ) {
291 is.clear(std::ios::badbit | is.rdstate());
292 std::cerr <<
"Failure when reading caching state of RandGauss\n";
295 if (c2 ==
"CACHED_GAUSSIAN:") {
297 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
300 is.clear(std::ios::badbit | is.rdstate());
301 std::cerr <<
"Unexpected caching state keyword of RandGauss:" << c2
302 <<
"\nistream is left in the badbit state\n";
310 int prec = os.precision(20);
311 std::vector<unsigned long> t(2);
316 os <<
"nextGauss_st " <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
318 os <<
"no_cached_nextGauss_st \n";
328 is.clear(std::ios::badbit | is.rdstate());
329 std::cerr <<
"Mismatch when expecting to read static state of a "
331 <<
"Name found was " << inName
332 <<
"\nistream is left in the badbit state\n";
338 std::vector<unsigned long> t(2);
342 if (ng ==
"nextGauss_st") {
343 is >> nextGauss_st >> t[0] >> t[1];
350 is >> c2 >> nextGauss_st;
351 if ( (!is) || (c1 !=
"RANDGAUSS") ) {
352 is.clear(std::ios::badbit | is.rdstate());
353 std::cerr <<
"Failure when reading caching state of static RandGauss\n";
356 if (c2 ==
"CACHED_GAUSSIAN:") {
358 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
361 is.clear(std::ios::badbit | is.rdstate());
362 std::cerr <<
"Unexpected caching state keyword of static RandGauss:" << c2
363 <<
"\nistream is left in the badbit state\n";
static std::istream & restoreFullState(std::istream &is)
static void saveEngineStatus(const char filename[]="Config.conf")
static std::istream & restoreDistState(std::istream &is)
HepRandomEngine & engine()
static std::ostream & saveDistState(std::ostream &os)
void fireArray(const int size, double *vect)
static HepRandomEngine * getTheEngine()
shared_ptr< HepRandomEngine > localEngine
std::istream & get(std::istream &is)
static void shootArray(const int size, double *vect, double mean=0.0, double stdDev=1.0)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
virtual void restoreStatus(const char filename[]="Config.conf")=0
static std::string distributionName()
virtual double operator()()
static std::vector< unsigned long > dto2longs(double d)
static void setFlag(bool val)
static void restoreEngineStatus(const char filename[]="Config.conf")
static void setVal(double nextVal)
static std::ostream & saveFullState(std::ostream &os)
virtual void saveStatus(const char filename[]="Config.conf") const =0
static std::ostream & saveFullState(std::ostream &os)
std::ostream & put(std::ostream &os) const
static std::istream & restoreFullState(std::istream &is)
static double longs2double(const std::vector< unsigned long > &v)