Go to the documentation of this file.
35 #include "CLHEP/Random/defs.h"
36 #include "CLHEP/Random/RandGauss.h"
37 #include "CLHEP/Random/DoubConv.hh"
47 bool RandGauss::set_st =
false;
48 double RandGauss::nextGauss_st = 0.0;
58 return fire( mean, stdDev );
78 v1 = 2.0 * anEngine->
flat() - 1.0;
79 v2 = 2.0 * anEngine->
flat() - 1.0;
83 fac = std::sqrt(-2.0*std::log(r)/r);
91 double mean,
double stdDev )
93 for(
double*
v = vect;
v != vect +
size; ++
v )
108 double v1,v2,fac,val;
111 v1 = 2.0 * anEngine->
flat() - 1.0;
112 v2 = 2.0 * anEngine->
flat() - 1.0;
116 fac = std::sqrt( -2.0*std::log(r)/r);
124 const int size,
double* vect,
125 double mean,
double stdDev )
127 for(
double*
v = vect;
v != vect +
size; ++
v )
128 *
v =
shoot(anEngine,mean,stdDev);
142 double v1,v2,fac,val;
150 fac = std::sqrt(-2.0*std::log(r)/r);
159 for(
double*
v = vect;
v != vect +
size; ++
v )
164 double mean,
double stdDev )
166 for(
double*
v = vect;
v != vect +
size; ++
v )
167 *
v =
fire( mean, stdDev );
177 std::ofstream outfile ( filename, std::ios::app );
180 std::vector<unsigned long> t(2);
182 outfile <<
"RANDGAUSS CACHED_GAUSSIAN: Uvec "
183 <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
185 outfile <<
"RANDGAUSS NO_CACHED_GAUSSIAN: 0 \n" ;
200 char inputword[] =
"NO_KEYWORD ";
204 if (strcmp(inputword,
"RANDGAUSS")==0)
break;
205 if (infile.eof())
break;
213 if (strcmp(inputword,
"RANDGAUSS")==0) {
217 if (strcmp(setword,
"CACHED_GAUSSIAN:") ==0) {
219 std::vector<unsigned long> t(2);
220 infile >> nextGauss_st >> t[0] >> t[1];
227 infile >> nextGauss_st;
238 os <<
name() <<
"\n";
239 int prec = os.precision(20);
240 std::vector<unsigned long> t(2);
243 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
248 os <<
"nextGauss " << nextGauss <<
" " << t[0] <<
" " << t[1] <<
"\n";
250 std::cout <<
"put(): nextGauss = " << nextGauss <<
"\n";
254 std::cout <<
"put(): No nextGauss \n";
256 os <<
"no_cached_nextGauss \n";
265 if (inName !=
name()) {
266 is.clear(std::ios::badbit |
is.rdstate());
267 std::cerr <<
"Mismatch when expecting to read state of a "
268 <<
name() <<
" distribution\n"
269 <<
"Name found was " << inName
270 <<
"\nistream is left in the badbit state\n";
276 std::vector<unsigned long> t(2);
283 if (ng !=
"nextGauss")
284 std::cout <<
"get(): ng = " << ng <<
"\n";
286 if (ng ==
"nextGauss") {
289 std::cout <<
"get(): nextGauss read back as " << nextGauss <<
"\n";
297 if ( (!
is) || (c1 !=
"Mean:") || (c2 !=
"Sigma:") ) {
298 std::cerr <<
"i/o problem while expecting to read state of a "
299 <<
name() <<
" distribution\n"
300 <<
"default mean and/or sigma could not be read\n";
303 is >> c1 >> c2 >> nextGauss;
304 if ( (!
is) || (c1 !=
"RANDGAUSS") ) {
305 is.clear(std::ios::badbit |
is.rdstate());
306 std::cerr <<
"Failure when reading caching state of RandGauss\n";
309 if (c2 ==
"CACHED_GAUSSIAN:") {
311 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
314 is.clear(std::ios::badbit |
is.rdstate());
315 std::cerr <<
"Unexpected caching state keyword of RandGauss:" << c2
316 <<
"\nistream is left in the badbit state\n";
324 int prec = os.precision(20);
325 std::vector<unsigned long> t(2);
330 os <<
"nextGauss_st " <<
getVal() <<
" " << t[0] <<
" " << t[1] <<
"\n";
332 os <<
"no_cached_nextGauss_st \n";
342 is.clear(std::ios::badbit |
is.rdstate());
343 std::cerr <<
"Mismatch when expecting to read static state of a "
345 <<
"Name found was " << inName
346 <<
"\nistream is left in the badbit state\n";
352 std::vector<unsigned long> t(2);
356 if (ng ==
"nextGauss_st") {
357 is >> nextGauss_st >> t[0] >> t[1];
364 is >> c2 >> nextGauss_st;
365 if ( (!
is) || (c1 !=
"RANDGAUSS") ) {
366 is.clear(std::ios::badbit |
is.rdstate());
367 std::cerr <<
"Failure when reading caching state of static RandGauss\n";
370 if (c2 ==
"CACHED_GAUSSIAN:") {
372 }
else if (c2 ==
"NO_CACHED_GAUSSIAN:") {
375 is.clear(std::ios::badbit |
is.rdstate());
376 std::cerr <<
"Unexpected caching state keyword of static RandGauss:" << c2
377 <<
"\nistream is left in the badbit state\n";
static std::ostream & saveFullState(std::ostream &os)
HepRandomEngine & engine()
static std::istream & restoreDistState(std::istream &is)
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
static std::istream & restoreFullState(std::istream &is)
static std::istream & restoreFullState(std::istream &is)
static double longs2double(const std::vector< unsigned long > &v)
virtual double operator()()
static void setFlag(bool val)
std::istream & get(std::istream &is)
user code seldom needs to call this function directly ZMerrno whether or not they are still recorded ZMerrno size() Return the(integer) number of ZMthrow 'n exceptions currently recorded. 5) ZMerrno.clear() Set an internal counter to zero. This counter is available(see next function) to user code to track ZMthrow 'n exceptions that have occurred during any arbitrary time interval. 6) ZMerrno.countSinceCleared() Return the(integer) number of ZMthrow 'n exceptions that have been recorded via ZMerrno.write()
static std::ostream & saveDistState(std::ostream &os)
void fireArray(const int size, double *vect)
static void restoreEngineStatus(const char filename[]="Config.conf")
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
virtual void saveStatus(const char filename[]="Config.conf") const =0
static std::string distributionName()
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
virtual void restoreStatus(const char filename[]="Config.conf")=0
static void saveEngineStatus(const char filename[]="Config.conf")
std::ostream & put(std::ostream &os) const
static std::vector< unsigned long > dto2longs(double d)
static std::ostream & saveFullState(std::ostream &os)
shared_ptr< HepRandomEngine > localEngine
it has advantages For I leave the ZMthrows in
static HepRandomEngine * getTheEngine()
any side effects of that construction would occur twice The semantics of throw x
static void shootArray(const int size, double *vect, double mean=0.0, double stdDev=1.0)
static void setVal(double nextVal)