19 if(origdata ==
nullptr)
20 throw GeneralError(
"Can't run on a PDF with no DataSet to fill!");
27 std::random_device rd;
30 std::mt19937 gen(seed);
33 std::poisson_distribution<> d(nTotal);
34 size_t num_events = d(gen);
37 std::uniform_real_distribution<> unihalf(-.5, .5);
38 std::uniform_real_distribution<> uniwhole(0.0, 1.0);
41 std::vector<double> integral(pdfValues.size());
42 std::partial_sum(pdfValues.begin(), pdfValues.end(), integral.begin());
45 std::for_each(integral.begin(), integral.end(), [&integral](
double &val) { val /= integral.back(); });
47 for(
size_t i = 0; i < num_events; i++) {
48 double r = uniwhole(gen);
51 size_t j = std::lower_bound(integral.begin(), integral.end(), r) - integral.begin();
Thrown when a general error is encountered.
fptype getBinSize() const
Get the bin size, (upper-lower) / bins.
__host__ DataSet * getData()
void fillWithGrid()
Replace the current dataset with a grid.
__host__ std::vector< std::vector< fptype > > getCompProbsAtDataPoints()
Produce a list of probabilies at points.
void setValue(fptype val)
Set the value.
Special class for observables. Used in DataSets.
fptype getValue(const Observable &var, size_t idx) const
Get the value at a specific variable and event number.
__host__ void setData(DataSet *data)
void fillDataSetMC1D(GooPdf &pdf, Observable var, size_t nTotal, unsigned int seed=0)