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 {
56 for (
int i = 0; i < ndim; ++i)
68 std::vector<double>
fX;
88 fFoam(new
TFoam(
"FOAM") ),
93 assert(
fFoam !=
nullptr);
109 assert (
fFoam !=
nullptr );
111 Error(
"TFoamSampler::Init",
"Distribution function has not been set ! Need to call SetFunction first.");
158 SetFunction<TF1>(*pdf, pdf->
GetNdim());
169 if (
r)
r->SetSeed(seed);
188 for (
unsigned int i = 0; i <
NDim(); ++i)
199 if (!
r)
return false;
201 if (error) *error = std::sqrt(
value);
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
R__EXTERN TRandom * gRandom
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
Documentation for the abstract class IBaseFunctionMultiDim.
virtual unsigned int NDim() const =0
Retrieve the dimension of 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
Abstract class representing n-dimensional real positive integrand function.
class implementing the ROOT::Math::DistSampler interface using FOAM for sampling arbitrary distributi...
void SetFunction(const ROOT::Math::IGenFunction &func) override
set the parent function distribution to use for random sampling (one dim case)
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.
TFoam is the main class of the multi-dimensional general purpose Monte Carlo event generator (integra...
virtual void GetMCvect(Double_t *)
User may get generated MC point/vector with help of this method.
virtual void MakeEvent()
User method.
virtual void Initialize()
Basic initialization of FOAM invoked by the user.
virtual void SetnSampl(Long_t nSampl)
virtual void SetMaxWtRej(Double_t MaxWtRej)
virtual TRandom * GetPseRan() const
virtual void SetChat(Int_t Chat)
virtual void SetOptDrive(Int_t OptDrive)
virtual void SetnCells(Long_t nCells)
virtual void SetRho(TFoamIntegrand *Rho)
User may use this method to set the distribution object.
virtual void SetOptRej(Int_t OptRej)
virtual void SetPseRan(TRandom *PseRan)
virtual void SetnBin(Int_t nBin)
virtual void SetkDim(Int_t kDim)
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.
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...