38const int RandFlat::MSBBits= 15;
39const unsigned long RandFlat::MSB= 1ul<<RandFlat::MSBBits;
50 return fire( defaultA, defaultB );
70 double lx,
double dx )
74 for (i=0; i<size; ++i)
75 vect[i] =
shoot(lx,dx);
79 const int size,
double* vect,
80 double lx,
double dx )
84 for (i=0; i<size; ++i)
85 vect[i] =
shoot(anEngine,lx,dx);
92 for (i=0; i<size; ++i)
93 vect[i] =
fire( defaultA, defaultB );
97 double lx,
double dx )
101 for (i=0; i<size; ++i)
102 vect[i] =
fire( lx, dx );
112 std::ofstream outfile ( filename, std::ios::app );
114 outfile <<
"RANDFLAT staticRandomInt: " << staticRandomInt
115 <<
" staticFirstUnusedBit: " << staticFirstUnusedBit <<
"\n";
127 std::ifstream infile ( filename, std::ios::in );
129 char inputword[] =
"NO_KEYWORD ";
133 if (strcmp(inputword,
"RANDFLAT")==0)
break;
134 if (infile.eof())
break;
143 if (strcmp(inputword,
"RANDFLAT")==0) {
148 infile >> staticRandomInt;
152 infile >> staticFirstUnusedBit;
158 int pr=os.precision(20);
159 std::vector<unsigned long> t(2);
160 os <<
" " <<
name() <<
"\n";
161 os <<
"Uvec" <<
"\n";
162 os << randomInt <<
" " << firstUnusedBit <<
"\n";
164 os << defaultWidth <<
" " << t[0] <<
" " << t[1] <<
"\n";
166 os << defaultA <<
" " << t[0] <<
" " << t[1] <<
"\n";
168 os << defaultB <<
" " << t[0] <<
" " << t[1] <<
"\n";
176 if (inName !=
name()) {
177 is.clear(std::ios::badbit | is.rdstate());
178 std::cerr <<
"Mismatch when expecting to read state of a "
179 <<
name() <<
" distribution\n"
180 <<
"Name found was " << inName
181 <<
"\nistream is left in the badbit state\n";
185 std::vector<unsigned long> t(2);
186 is >> randomInt >> firstUnusedBit;
191 is.clear(std::ios::badbit | is.rdstate());
192 std::cerr <<
"\nRandFlat input failed"
193 <<
"\nInput stream is probably mispositioned now." << std::endl;
199 is >> firstUnusedBit;
200 is >> defaultWidth >> defaultA >> defaultB;
206 int prec = os.precision(20);
207 os <<
"RANDFLAT staticRandomInt: " << staticRandomInt
208 <<
" staticFirstUnusedBit: " << staticFirstUnusedBit <<
"\n";
217 is.clear(std::ios::badbit | is.rdstate());
218 std::cerr <<
"Mismatch when expecting to read static state of a "
220 <<
"Name found was " << inName
221 <<
"\nistream is left in the badbit state\n";
228 if (keyword!=
"RANDFLAT") {
229 is.clear(std::ios::badbit | is.rdstate());
230 std::cerr <<
"Mismatch when expecting to read RANDFLAT bit cache info: "
234 is >> c1 >> staticRandomInt >> c2 >> staticFirstUnusedBit;
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
virtual void flatArray(const int size, double *vect)=0
static HepRandomEngine * getTheEngine()
static std::ostream & saveFullState(std::ostream &os)
static std::istream & restoreFullState(std::istream &is)
static std::ostream & saveFullState(std::ostream &os)
std::ostream & put(std::ostream &os) const
static void restoreEngineStatus(const char filename[]="Config.conf")
void fireArray(const int size, double *vect)
static std::string distributionName()
static void saveEngineStatus(const char filename[]="Config.conf")
static std::ostream & saveDistState(std::ostream &os)
static std::istream & restoreDistState(std::istream &is)
static void shootArray(const int size, double *vect)
static std::istream & restoreFullState(std::istream &is)
std::istream & get(std::istream &is)
HepRandomEngine & engine()
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
#define CLHEP_THREAD_LOCAL