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)
80 fData = std::vector<double>(ndim);
92 if (
NDim() == 0)
return false;
103 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
108 for (
unsigned int i = 0; i < nevt; ++i) {
117 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
120 unsigned int ndim =
NDim();
121 for (
unsigned int i = 0; i < nevt; ++i) {
123 assert(
x !=
nullptr);
125 std::copy(
x,
x+ndim,
data+i*ndim);
127 for (
unsigned int j = 0; j < ndim; ++j) {
128 data[j*nevt+i] =
x[j];
139 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not been initialized correctly");
144 for (
unsigned int j = 0; j <
NDim(); ++j) {
145 ntotbins *= nbins[j];
150 std::vector<double> dx(
NDim() );
151 std::vector<double>
x(
NDim() );
152 double binVolume = 1;
153 for (
unsigned int j = 0; j < dx.size(); ++j) {
154 double x1 = 0,
x2 = 0;
156 MATH_WARN_MSG(
"DistSampler::Generate",
"sampler has not a range defined for all coordinates");
160 dx[j] = (
x2-
x1)/
double(nbins[j]);
161 assert(dx[j] > 0 && 1./dx[j] > 0 );
165 double nnorm = nevt * binVolume;
170 for (
int j =
NDim()-1; j >=0; --j) {
171 for (
int i = 0; i < nbins[j]; ++i) {
175 double nexp = yval * nnorm;
177 double eval = (expErr) ? std::sqrt(nexp) : std::sqrt(val);
178 data.Add(&
x.front(), val, eval);
182 MATH_WARN_MSG(
"DistSampler::Generate",
"error returned from SampleBin");
188 MATH_WARN_MSG(
"DistSampler::Generate",
"generation with fixed events not yet impelmented");
#define MATH_ERROR_MSG(loc, str)
#define MATH_WARN_MSG(loc, str)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
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 un-binned data sets (just x coordinates values) of any dimensions.
DistSampler options class.
const std::string & Algorithm() const
type of algorithm (method)
const double * Sample()
Sample one event and return an array x with sample coordinates values.
ROOT::Fit::DataRange * fRange
data range
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 set by filling the given data set object.
const ROOT::Math::IMultiGenFunction * fFunc
internal function (ND)
void SetRange(double xmin, double xmax, int icoord=0)
Set the range in a given dimension.
virtual bool SampleBin(double prob, double &value, double *error=nullptr)
Sample one bin given an estimate of the pdf in the bin.
virtual void DoSetDimension(unsigned int ndim)
virtual bool Init(const char *="")
Initialize the sampling generator with the given algorithm.
std::vector< double > fData
! internal array used to cached the sample data
bool fOwnFunc
flag to indicate if the function is owned
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...