39 assert(
f.NDim() == range.
NDim() );
40 std::vector<double>
xmax(
f.NDim() );
41 for (
unsigned int i = 0; i < range.
NDim(); ++i) {
42 if (range.
Size(i) == 0)
43 Error(
"FoamDistribution",
"Range is not set for coordinate dim %d",i);
44 else if (range.
Size(i)>1)
45 Warning(
"FoamDistribution",
"Using only first range in coordinate dim %d",i);
47 std::pair<double,double>
r = range(i);
54 double Density(
int ndim,
double *
x)
override {
55 assert(ndim == (
int)
fFunc.NDim() );
56 for (
int i = 0; i < ndim; ++i)
68 std::vector<double>
fX;
92 assert(
fFoam !=
nullptr);
108 assert (
fFoam !=
nullptr );
110 Error(
"TFoamSampler::Init",
"Distribution function has not been set ! Need to call SetFunction first.");
168 if (
r)
r->SetSeed(seed);
173 return fFoam->GetPseRan();
187 for (
unsigned int i = 0; i <
NDim(); ++i)
198 if (!
r)
return false;
199 value =
r->Poisson(prob);
200 if (error) *error = std::sqrt(value);
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
std::vector< double > fMinX
double Density(int ndim, double *x) override
std::vector< double > fDeltaX
FoamDistribution(const ROOT::Math::IMultiGenFunction &f, const ROOT::Fit::DataRange &range)
const ROOT::Math::IMultiGenFunction & fFunc
double MinX(unsigned int i)
double DeltaX(unsigned int i)
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 [-...
DistSampler options class.
int PrintLevel() const
non-static methods for retrieving options
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
static ROOT::Math::IOptions * FindDefault(const char *name)
const double * Sample()
Sample one event and return an array x with sample coordinates values.
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)
const ROOT::Fit::DataRange & PdfRange() const
return the data range of the Pdf . Must be called after setting the function
Generic interface for defining configuration options of a numerical algorithm.
virtual bool GetIntValue(const char *, int &) const
virtual bool GetRealValue(const char *, double &) const
virtual Int_t GetNdim() const
void SetFunction(const ROOT::Math::IGenFunction &func) override
set the parent function distribution to use for random sampling (one dim case)
const ROOT::Math::IGenFunction * fFunc1D
bool Init(const char *="") override
initialize the generators with the default options
void SetSeed(unsigned int seed) override
Set the random seed for the TRandom instances used by the sampler classes Needs to be called before I...
TFoamSampler()
default constructor
bool SampleBin(double prob, double &value, double *error=nullptr) override
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or ...
TFoamIntegrand * fFoamDist
TRandom * GetRandom() override
Get the random engine used by the sampler.
~TFoamSampler() override
virtual destructor
void SetRandom(TRandom *r) override
Set the random engine to be used Needs to be called before Init to have effect.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
This is the base class for the ROOT Random number generators.
IMultiGenFunctionTempl< double > IMultiGenFunction