41 MATH_ERROR_MSG(
"DistSampler::SetRange",
"Need to set function before setting the range");
50 MATH_ERROR_MSG(
"DistSampler::SetRange",
"Need to set function before setting the range");
53 for (
unsigned int icoord = 0; icoord <
NDim(); ++icoord)
86 if (
NDim() == 0)
return false;
87 if (
fFunc == 0)
return false;
100 MATH_ERROR_MSG(
"DistSampler::Generate",
"unbin data not consistent with distribution");
105 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
110 for (
unsigned int i = 0; i < nevt; ++i) {
123 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
129 for (
unsigned int j = 0; j <
NDim(); ++j) {
130 ntotbins *= nbins[j];
135 std::vector<double> dx(
NDim() );
136 std::vector<double>
x(
NDim() );
137 double binVolume = 1;
138 for (
unsigned int j = 0; j < dx.size(); ++j) {
139 double x1 = 0,
x2 = 0;
141 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not a range defined for all coordinates");
145 dx[j] = (
x2-
x1)/
double(nbins[j]);
146 assert(dx[j] > 0 && 1./dx[j] > 0 );
150 double nnorm = nevt * binVolume;
155 for (
int j =
NDim()-1; j >=0; --j) {
156 for (
int i = 0; i < nbins[j]; ++i) {
161 double nexp = yval * nnorm;
163 data.
Add(&x.front(), val, eval);
167 MATH_WARN_MSG(
"DistSampler::Generate",
"error returned from SampleBin");
173 MATH_WARN_MSG(
"DistSampler::Generate",
"generation with fixed events not yet impelmented");
void Initialize(unsigned int maxpoints, 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...
std::vector< double > fData
Namespace for new ROOT classes and functions.
const std::string & Algorithm() const
type of algorithm
const double * Sample()
sample one event and rerturning array x with coordinates
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
#define MATH_WARN_MSG(loc, str)
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 ...
static const double x2[5]
unsigned int DataSize() const
return size of internal data vector (is 0 for external data)
virtual ~DistSampler()
virtual destructor
#define MATH_ERROR_MSG(loc, str)
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...
DistSampler options class.
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
ROOT::Fit::DataRange * fRange
unsigned int NDim() const
return the dimension of the parent distribution (and the data)
const ROOT::Math::IMultiGenFunction * fFunc
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
void SetRange(double xmin, double xmax, int icoord=0)
set range in a given dimension
static const double x1[5]
class describing the range in the coordinates it supports multiple range in a coordinate.
void Add(double x, double y)
add one dim data with only coordinate and values
void Add(double x)
add one dim coordinate data (unweighted)
double func(double *x, double *p)
void GetRange(unsigned int icoord, double &xmin, double &xmax) const
get the first range for given coordinate.
Namespace for new Math classes and functions.
virtual bool Init(const char *="")
initialize the generators with the given algorithm Implemented by derived classes who needs it (like ...
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 ...
unsigned int NDim() const
get range dimension
virtual void DoSetFunction(const ROOT::Math::IMultiGenFunction &func, bool copy)
unsigned int PointSize() const
return point size.
Documentation for the abstract class IBaseFunctionMultiDim.
const ROOT::Math::IMultiGenFunction & ParentPdf() const
get the parent distribution function (must be called after setting the function)
virtual IBaseFunctionMultiDim * Clone() const =0
Clone a function.
void Initialize(unsigned int maxpoints, unsigned int dim=1, bool isWeighted=false)
preallocate a data set given size and dimension of the coordinates if a vector already exists with co...