70 InterpolationType(IntType)
76 const double* aProbFunc,
82 InterpolationType(IntType)
88 const double* aProbFunc,
92 localEngine(anEngine),
94 InterpolationType(IntType)
105 "RandGeneral constructed with no bins - will use flat distribution\n";
115 for ( ptn = 0; ptn<
nBins; ++ptn ) {
116 weight = aProbFunc[ptn];
121 "RandGeneral constructed with negative-weight bin " << ptn <<
122 " = " << weight <<
" \n -- will substitute 0 weight \n";
131 "RandGeneral constructed nothing in bins - will use flat distribution\n";
136 for ( ptn = 0; ptn < nBins+1; ++ptn ) {
149 <<
"\n Will use type 0 (continuous linear interpolation \n";
150 InterpolationType = 0;
190 while (nabove > nbelow+1) {
191 middle = (nabove + nbelow+1)>>1;
198 assert ( nabove == nbelow+1 );
214 if ( binMeasure == 0 ) {
221 double binFraction = (rand - theIntegralPdf[nbelow]) / binMeasure;
229 const int size,
double* vect )
233 for (i=0; i<size; ++i) {
234 vect[i] =
shoot(anEngine);
242 for (i=0; i<size; ++i) {
248 int pr=os.precision(20);
249 std::vector<unsigned long> t(2);
250 os <<
" " <<
name() <<
"\n";
251 os <<
"Uvec" <<
"\n";
254 os << t[0] <<
" " << t[1] <<
"\n";
267 if (inName !=
name()) {
268 is.clear(std::ios::badbit | is.rdstate());
269 std::cerr <<
"Mismatch when expecting to read state of a "
270 <<
name() <<
" distribution\n"
271 <<
"Name found was " << inName
272 <<
"\nistream is left in the badbit state\n";
276 std::vector<unsigned long> t(2);
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
void useFlatDistribution()
std::vector< double > theIntegralPdf
void prepareTable(const double *aProbFunc)
static double longs2double(const std::vector< unsigned long > &v)
std::istream & get(std::istream &is)
static std::vector< unsigned long > dto2longs(double d)
RandGeneral(const double *aProbFunc, int theProbSize, int IntType=0)
double mapRandom(double rand) const
HepRandomEngine & engine()
void shootArray(const int size, double *vect)
std::shared_ptr< HepRandomEngine > localEngine
std::ostream & put(std::ostream &os) const
void fireArray(const int size, double *vect)