72 InterpolationType(IntType)
78 const double* aProbFunc,
84 InterpolationType(IntType)
90 const double* aProbFunc,
94 localEngine(anEngine),
96 InterpolationType(IntType)
107 "RandGeneral constructed with no bins - will use flat distribution\n";
117 for ( ptn = 0; ptn<
nBins; ++ptn ) {
118 weight = aProbFunc[ptn];
123 "RandGeneral constructed with negative-weight bin " << ptn <<
124 " = " << weight <<
" \n -- will substitute 0 weight \n";
133 "RandGeneral constructed nothing in bins - will use flat distribution\n";
138 for ( ptn = 0; ptn <
nBins+1; ++ptn ) {
151 <<
"\n Will use type 0 (continuous linear interpolation \n";
192 while (nabove > nbelow+1) {
193 middle = (nabove + nbelow+1)>>1;
200 assert ( nabove == nbelow+1 );
216 if ( binMeasure == 0 ) {
223 double binFraction = (rand -
theIntegralPdf[nbelow]) / binMeasure;
231 const int size,
double* vect )
235 for (i=0; i<size; ++i) {
236 vect[i] =
shoot(anEngine);
244 for (i=0; i<size; ++i) {
250 int pr=os.precision(20);
251 std::vector<unsigned long> t(2);
252 os <<
" " <<
name() <<
"\n";
253 os <<
"Uvec" <<
"\n";
256 os << t[0] <<
" " << t[1] <<
"\n";
269 if (inName !=
name()) {
270 is.clear(std::ios::badbit | is.rdstate());
271 std::cerr <<
"Mismatch when expecting to read state of a "
272 <<
name() <<
" distribution\n"
273 <<
"Name found was " << inName
274 <<
"\nistream is left in the badbit state\n";
278 std::vector<unsigned long> t(2);
static double longs2double(const std::vector< unsigned long > &v)
static std::vector< unsigned long > dto2longs(double d)
void prepareTable(const double *aProbFunc)
void useFlatDistribution()
RandGeneral(const double *aProbFunc, int theProbSize, int IntType=0)
std::istream & get(std::istream &is)
std::ostream & put(std::ostream &os) const
void fireArray(const int size, double *vect)
HepRandomEngine & engine()
void shootArray(const int size, double *vect)
std::vector< double > theIntegralPdf
double mapRandom(double rand) const
std::shared_ptr< HepRandomEngine > localEngine
bool possibleKeywordInput(IS &is, const std::string &key, T &t)