35 fX(std::vector<
double>(f.NDim() ) ),
36 fMinX(std::vector<
double>(f.NDim() ) ),
37 fDeltaX(std::vector<
double>(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") ),
117 Error(
"TFoamSampler::Init",
"Distribution function has not been set ! Need to call SetFunction first.");
164 SetFunction<TF1>(*pdf, pdf->
GetNdim());
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;
static ROOT::Math::IOptions * FindDefault(const char *name)
unsigned int NDim() const
return the dimension of the parent distribution (and the data)
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 ...
const double * Sample()
sample one event and rerturning array x with coordinates
void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
virtual ~TFoamSampler()
virtual destructor
virtual void MakeEvent()
User subprogram.
TFoamIntegrand * fFoamDist
virtual void SetChat(Int_t Chat)
const ROOT::Math::IMultiGenFunction & ParentPdf() const
get the parent distribution function (must be called after setting the function)
virtual bool GetIntValue(const char *, int &) const
const ROOT::Fit::DataRange & PdfRange() const
return the data range of the Pdf . Must be called after setting the function
virtual void SetSeed(UInt_t seed=0)
Set the random generator seed.
virtual TRandom * GetPseRan() const
TRandom * GetRandom()
Get the random engine used by the sampler.
This is the base class for the ROOT Random number generators.
virtual bool GetRealValue(const char *, double &) const
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
virtual void SetOptRej(Int_t OptRej)
virtual void SetnBin(Int_t nBin)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void Error(const char *location, const char *msgfmt,...)
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
virtual void GetMCvect(Double_t *)
User may get generated MC point/vector with help of this method.
virtual Double_t Density(Int_t ndim, Double_t *)=0
DistSampler options class.
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
virtual Int_t GetNdim() const
virtual void Initialize()
Basic initialization of FOAM invoked by the user.
bool Init(const char *="")
initialize the generators with the default options
virtual void SetnSampl(Long_t nSampl)
R__EXTERN TRandom * gRandom
ClassImp(TFoamSampler) TFoamSampler
TFoamSampler class class implementing the ROOT::Math::DistSampler interface using FOAM for sampling a...
unsigned int NDim() const
get range dimension
IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
virtual void SetnCells(Long_t nCells)
class describing the range in the coordinates it supports multiple range in a coordinate.
virtual void SetPseRan(TRandom *PseRan)
virtual void SetMaxWtRej(Double_t MaxWtRej)
Generic interface for defining configuration options of a numerical algorithm.
virtual void SetOptDrive(Int_t OptDrive)
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
void SetRandom(TRandom *r)
Set the random engine to be used Needs to be called before Init to have effect.
Documentation for the abstract class IBaseFunctionMultiDim.
virtual void SetRho(TFoamIntegrand *Rho)
User may use this method to set the distribution object.
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 class class implementing the ROOT::Math::DistSampler interface using FOAM for sampling a...
int PrintLevel() const
non-static methods for retrivieng options
virtual void SetkDim(Int_t kDim)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.