43 std::vector<G4double>& values)
50 if (x.size() != (values.size() + 1))
51 {
G4cout <<
" Inconsistent parameters in G4DistributionGenerator "
54 assert (x.size() == (values.size() + 1));
58 for (i=0; i<values.size(); i++) { tot += values[i]; }
61 _cumProb.push_back(0.);
64 for (i=0; i<values.size(); i++)
67 _cumProb.push_back(sum / tot); }
97 for (i=1; i<_cumProb.size(); i++)
99 if (ranflat >= _cumProb[i-1] && ranflat < _cumProb[i])
105 if (bin >= 0 && bin < static_cast<G4int>(_cumProb.size()-1) && bin < static_cast<G4int>(_x.size()-1))
107 G4double coeff = (ranflat - _cumProb[
bin]) * (_x[bin+1] - _x[bin]) /
108 (_cumProb[bin+1] - _cumProb[
bin]);
109 xRandom = _x[
bin] + coeff;