42 MATH_ERROR_MSG(
"DistSampler::SetRange",
"Need to set function before setting the range");
51 MATH_ERROR_MSG(
"DistSampler::SetRange",
"Need to set function before setting the range");
54 for (
unsigned int icoord = 0; icoord <
NDim(); ++icoord)
87 if (
NDim() == 0)
return false;
88 if (
fFunc == 0)
return false;
99 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
104 for (
unsigned int i = 0; i < nevt; ++i) {
117 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
123 for (
unsigned int j = 0; j <
NDim(); ++j) {
124 ntotbins *= nbins[j];
129 std::vector<double> dx(
NDim() );
130 std::vector<double>
x(
NDim() );
131 double binVolume = 1;
132 for (
unsigned int j = 0; j < dx.size(); ++j) {
133 double x1 = 0,
x2 = 0;
135 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not a range defined for all coordinates");
139 dx[j] = (
x2-
x1)/
double(nbins[j]);
140 assert(dx[j] > 0 && 1./dx[j] > 0 );
144 double nnorm = nevt * binVolume;
149 for (
int j =
NDim()-1; j >=0; --j) {
150 for (
int i = 0; i < nbins[j]; ++i) {
155 double nexp = yval * nnorm;
157 data.
Add(&
x.front(), val, eval);
161 MATH_WARN_MSG(
"DistSampler::Generate",
"error returned from SampleBin");
167 MATH_WARN_MSG(
"DistSampler::Generate",
"generation with fixed events not yet impelmented");
#define MATH_ERROR_MSG(loc, str)
#define MATH_WARN_MSG(loc, str)
static const double x2[5]
static const double x1[5]
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
void Append(unsigned int newPoints, unsigned int dim=1, ErrorType err=kValueError)
preallocate a data set with given size , dimension and error type (to get the full point size) If the...
void Add(double x, double y)
add one dim data with only coordinate and values
class describing the range in the coordinates it supports multiple range in a coordinate.
unsigned int NDim() const
get range dimension
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
void GetRange(unsigned int irange, unsigned int icoord, double &xmin, double &xmax) const
get the i-th range for given coordinate.
void SetRange(unsigned int icoord, double xmin, double xmax)
set a range [xmin,xmax] for the new coordinate icoord If more range exists for other coordinates,...
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
void Add(double x)
preallocate a data set given size and dimension of the coordinates if a vector already exists with co...
void Append(unsigned int newPoints, unsigned int dim=1, bool isWeighted=false)
DistSampler options class.
const std::string & Algorithm() const
type of algorithm
const double * Sample()
sample one event and rerturning array x with coordinates
virtual bool SampleBin(double prob, double &value, double *error=0)
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or ...
ROOT::Fit::DataRange * fRange
virtual void DoSetFunction(const ROOT::Math::IMultiGenFunction &func, bool copy)
const ROOT::Math::IMultiGenFunction & ParentPdf() const
get the parent distribution function (must be called after setting the function)
unsigned int NDim() const
return the dimension of the parent distribution (and the data)
virtual ~DistSampler()
virtual destructor
virtual bool Generate(unsigned int nevt, ROOT::Fit::UnBinData &data)
generate a un-binned data sets (fill the given data set) if dataset has already data append to it
const ROOT::Math::IMultiGenFunction * fFunc
void SetRange(double xmin, double xmax, int icoord=0)
set range in a given dimension
virtual bool Init(const char *="")
initialize the generators with the given algorithm Implemented by derived classes who needs it (like ...
std::vector< double > fData
Documentation for the abstract class IBaseFunctionMultiDim.
virtual IBaseFunctionMultiDimTempl< T > * Clone() const =0
Clone a function.
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...