35 fX(std::vector<double>(
f.NDim() ) ),
36 fMinX(std::vector<double>(
f.NDim() ) ),
37 fDeltaX(std::vector<double>(
f.NDim() ) )
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);
49 fDeltaX[i] =
r.second -
r.first;
54 virtual double Density(
int ndim,
double *
x) {
55 assert(ndim == (
int) fFunc.NDim() );
56 for (
int i = 0; i < ndim; ++i)
57 fX[i] = fMinX[i] +
x[i] * fDeltaX[i];
59 return (fFunc)(&fX[0]);
62 double MinX(
unsigned int i) {
return fMinX[i]; }
63 double DeltaX(
unsigned int i) {
return fDeltaX[i]; }
68 std::vector<double> fX;
69 std::vector<double> fMinX;
70 std::vector<double> fDeltaX;
94 fFoam(new
TFoam(
"FOAM") ),
115 assert (
fFoam != 0 );
117 Error(
"TFoamSampler::Init",
"Distribution function has not been set ! Need to call SetFunction first.");
164 SetFunction<TF1>(*pdf, pdf->
GetNdim());
175 if (
r)
r->SetSeed(seed);
194 for (
unsigned int i = 0; i <
NDim(); ++i)
195 x[i] = ( (FoamDistribution*)
fFoamDist)->MinX(i) + ( ( (FoamDistribution*)
fFoamDist)->DeltaX(i))*
x[i];
205 if (!
r)
return false;
206 value =
r->Poisson(prob);
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TRandom * gRandom
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 retrivieng 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 rerturning array x with coordinates
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.
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
virtual Double_t Density(Int_t ndim, Double_t *)=0
TFoamSampler class class implementing the ROOT::Math::DistSampler interface using FOAM for sampling a...
void SetSeed(unsigned int seed)
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=0)
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or ...
void SetRandom(TRandom *r)
Set the random engine to be used Needs to be called before Init to have effect.
TFoamIntegrand * fFoamDist
bool Init(const char *="")
initialize the generators with the default options
virtual ~TFoamSampler()
virtual destructor
void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
TRandom * GetRandom()
Get the random engine used by the sampler.
virtual void GetMCvect(Double_t *)
User may get generated MC point/vector with help of this method.
virtual void MakeEvent()
User subprogram.
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.
Namespace for new ROOT classes and functions.