59 return fire( mean, stdDev );
79 v1 = 2.0 * anEngine->
flat() - 1.0;
80 v2 = 2.0 * anEngine->
flat() - 1.0;
84 fac = std::sqrt(-2.0*std::log(r)/r);
92 double mean,
double stdDev )
94 for(
double* v = vect; v != vect + size; ++v )
95 *v =
shoot(mean,stdDev);
109 double v1,v2,fac,val;
112 v1 = 2.0 * anEngine->
flat() - 1.0;
113 v2 = 2.0 * anEngine->
flat() - 1.0;
117 fac = std::sqrt( -2.0*std::log(r)/r);
125 const int size,
double* vect,
126 double mean,
double stdDev )
128 for(
double* v = vect; v != vect + size; ++v )
129 *v =
shoot(anEngine,mean,stdDev);
143 double v1,v2,fac,val;
151 fac = std::sqrt(-2.0*std::log(r)/r);
160 for(
double* v = vect; v != vect + size; ++v )
165 double mean,
double stdDev )
167 for(
double* v = vect; v != vect + size; ++v )
168 *v =
fire( mean, stdDev );
188 nextGauss_st = nextVal;
198 std::ofstream outfile ( filename, std::ios::app );
201 std::vector<unsigned long> t(2);
203 outfile <<
"RANDGAUSS CACHED_GAUSSIAN: Uvec "
204 <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
206 outfile <<
"RANDGAUSS NO_CACHED_GAUSSIAN: 0 \n" ;
218 std::ifstream infile ( filename, std::ios::in );
221 char inputword[] =
"NO_KEYWORD ";
225 if (strcmp(inputword,
"RANDGAUSS")==0)
break;
226 if (infile.eof())
break;
234 if (strcmp(inputword,
"RANDGAUSS")==0) {
238 if (strcmp(setword,
"CACHED_GAUSSIAN:") ==0) {
240 std::vector<unsigned long> t(2);
241 infile >> nextGauss_st >> t[0] >> t[1];
248 infile >> nextGauss_st;
259 os <<
name() <<
"\n";
260 long prec = os.precision(20);
261 std::vector<unsigned long> t(2);
264 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
269 os <<
"nextGauss " << nextGauss <<
" " << t[0] <<
" " << t[1] <<
"\n";
271 os <<
"no_cached_nextGauss \n";
280 if (inName !=
name()) {
281 is.clear(std::ios::badbit | is.rdstate());
282 std::cerr <<
"Mismatch when expecting to read state of a "
283 <<
name() <<
" distribution\n"
284 <<
"Name found was " << inName
285 <<
"\nistream is left in the badbit state\n";
291 std::vector<unsigned long> t(2);
297 if (ng ==
"nextGauss") {
305 if ( (!is) || (c1 !=
"Mean:") || (c2 !=
"Sigma:") ) {
306 std::cerr <<
"i/o problem while expecting to read state of a "
307 <<
name() <<
" distribution\n"
308 <<
"default mean and/or sigma could not be read\n";
311 is >> c1 >> c2 >> nextGauss;
312 if ( (!is) || (c1 !=
"RANDGAUSS") ) {
313 is.clear(std::ios::badbit | is.rdstate());
314 std::cerr <<
"Failure when reading caching state of RandGauss\n";
317 if (c2 ==
"CACHED_GAUSSIAN:") {
319 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
322 is.clear(std::ios::badbit | is.rdstate());
323 std::cerr <<
"Unexpected caching state keyword of RandGauss:" << c2
324 <<
"\nistream is left in the badbit state\n";
332 long prec = os.precision(20);
333 std::vector<unsigned long> t(2);
338 os <<
"nextGauss_st " <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
340 os <<
"no_cached_nextGauss_st \n";
350 is.clear(std::ios::badbit | is.rdstate());
351 std::cerr <<
"Mismatch when expecting to read static state of a "
353 <<
"Name found was " << inName
354 <<
"\nistream is left in the badbit state\n";
360 std::vector<unsigned long> t(2);
364 if (ng ==
"nextGauss_st") {
365 is >> nextGauss_st >> t[0] >> t[1];
372 is >> c2 >> nextGauss_st;
373 if ( (!is) || (c1 !=
"RANDGAUSS") ) {
374 is.clear(std::ios::badbit | is.rdstate());
375 std::cerr <<
"Failure when reading caching state of static RandGauss\n";
378 if (c2 ==
"CACHED_GAUSSIAN:") {
380 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
383 is.clear(std::ios::badbit | is.rdstate());
384 std::cerr <<
"Unexpected caching state keyword of static RandGauss:" << c2
385 <<
"\nistream is left in the badbit state\n";
static double longs2double(const std::vector< unsigned long > &v)
static std::vector< unsigned long > dto2longs(double d)
virtual void restoreStatus(const char filename[]="Config.conf")=0
virtual void saveStatus(const char filename[]="Config.conf") const =0
static HepRandomEngine * getTheEngine()
static std::ostream & saveFullState(std::ostream &os)
static std::istream & restoreFullState(std::istream &is)
static std::ostream & saveDistState(std::ostream &os)
static std::istream & restoreFullState(std::istream &is)
static void restoreEngineStatus(const char filename[]="Config.conf")
std::istream & get(std::istream &is)
std::ostream & put(std::ostream &os) const
void fireArray(const int size, double *vect)
static void shootArray(const int size, double *vect, double mean=0.0, double stdDev=1.0)
static void setVal(double nextVal)
HepRandomEngine & engine()
static std::ostream & saveFullState(std::ostream &os)
static void setFlag(bool val)
static std::string distributionName()
std::shared_ptr< HepRandomEngine > localEngine
static std::istream & restoreDistState(std::istream &is)
virtual double operator()()
static void saveEngineStatus(const char filename[]="Config.conf")
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
#define CLHEP_THREAD_LOCAL