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 )
93 *v =
shoot(mean,stdDev);
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 );
196 std::ofstream outfile ( filename, std::ios::app );
199 std::vector<unsigned long> t(2);
201 outfile <<
"RANDGAUSS CACHED_GAUSSIAN: Uvec "
202 <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
204 outfile <<
"RANDGAUSS NO_CACHED_GAUSSIAN: 0 \n" ;
219 char inputword[] =
"NO_KEYWORD ";
223 if (strcmp(inputword,
"RANDGAUSS")==0)
break;
224 if (infile.eof())
break;
232 if (strcmp(inputword,
"RANDGAUSS")==0) {
236 if (strcmp(setword,
"CACHED_GAUSSIAN:") ==0) {
238 std::vector<unsigned long> t(2);
257 os <<
name() <<
"\n";
258 int prec = os.precision(20);
259 std::vector<unsigned long> t(2);
262 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
267 os <<
"nextGauss " <<
nextGauss <<
" " << t[0] <<
" " << t[1] <<
"\n";
269 os <<
"no_cached_nextGauss \n";
278 if (inName !=
name()) {
279 is.clear(std::ios::badbit | is.rdstate());
280 std::cerr <<
"Mismatch when expecting to read state of a "
281 <<
name() <<
" distribution\n"
282 <<
"Name found was " << inName
283 <<
"\nistream is left in the badbit state\n";
289 std::vector<unsigned long> t(2);
295 if (ng ==
"nextGauss") {
303 if ( (!is) || (c1 !=
"Mean:") || (c2 !=
"Sigma:") ) {
304 std::cerr <<
"i/o problem while expecting to read state of a "
305 <<
name() <<
" distribution\n"
306 <<
"default mean and/or sigma could not be read\n";
310 if ( (!is) || (c1 !=
"RANDGAUSS") ) {
311 is.clear(std::ios::badbit | is.rdstate());
312 std::cerr <<
"Failure when reading caching state of RandGauss\n";
315 if (c2 ==
"CACHED_GAUSSIAN:") {
317 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
320 is.clear(std::ios::badbit | is.rdstate());
321 std::cerr <<
"Unexpected caching state keyword of RandGauss:" << c2
322 <<
"\nistream is left in the badbit state\n";
330 int prec = os.precision(20);
331 std::vector<unsigned long> t(2);
336 os <<
"nextGauss_st " <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
338 os <<
"no_cached_nextGauss_st \n";
348 is.clear(std::ios::badbit | is.rdstate());
349 std::cerr <<
"Mismatch when expecting to read static state of a "
351 <<
"Name found was " << inName
352 <<
"\nistream is left in the badbit state\n";
358 std::vector<unsigned long> t(2);
362 if (ng ==
"nextGauss_st") {
371 if ( (!is) || (c1 !=
"RANDGAUSS") ) {
372 is.clear(std::ios::badbit | is.rdstate());
373 std::cerr <<
"Failure when reading caching state of static RandGauss\n";
376 if (c2 ==
"CACHED_GAUSSIAN:") {
378 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
381 is.clear(std::ios::badbit | is.rdstate());
382 std::cerr <<
"Unexpected caching state keyword of static RandGauss:" << c2
383 <<
"\nistream is left in the badbit state\n";
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
static std::ostream & saveFullState(std::ostream &os)
static HepRandomEngine * getTheEngine()
void fireArray(const int size, double *vect)
static void setFlag(bool val)
std::istream & get(std::istream &is)
std::shared_ptr< HepRandomEngine > localEngine
static std::istream & restoreFullState(std::istream &is)
std::ostream & put(std::ostream &os) const
static double longs2double(const std::vector< unsigned long > &v)
virtual double operator()()
virtual void saveStatus(const char filename[]="Config.conf") const =0
static std::ostream & saveDistState(std::ostream &os)
static std::string distributionName()
static void saveEngineStatus(const char filename[]="Config.conf")
static std::vector< unsigned long > dto2longs(double d)
#define CLHEP_THREAD_LOCAL
static CLHEP_THREAD_LOCAL double nextGauss_st
static std::istream & restoreDistState(std::istream &is)
static void shootArray(const int size, double *vect, double mean=0.0, double stdDev=1.0)
static void restoreEngineStatus(const char filename[]="Config.conf")
static std::istream & restoreFullState(std::istream &is)
static const G4double fac
static std::ostream & saveFullState(std::ostream &os)
virtual void restoreStatus(const char filename[]="Config.conf")=0
static CLHEP_THREAD_LOCAL bool set_st
static void setVal(double nextVal)
HepRandomEngine & engine()