Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TFoamSampler Class Reference

class implementing the ROOT::Math::DistSampler interface using FOAM for sampling arbitrary distributions.

Definition at line 39 of file TFoamSampler.h.

Public Member Functions

 TFoamSampler ()
 default constructor
 
 ~TFoamSampler () override
 virtual destructor
 
TRandomGetRandom () override
 Get the random engine used by the sampler.
 
bool Init (const char *="") override
 initialize the generators with the default options
 
bool Init (const ROOT::Math::DistSamplerOptions &opt) override
 initialize the generators with the given options
 
bool Sample (double *x) override
 sample one event in multi-dimension by filling the given array return false if sampling failed
 
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 its integral in the bin divided by the bin width) By default do not do random sample, just return the function values
 
void SetFunction (const ROOT::Math::IGenFunction &func) override
 set the parent function distribution to use for random sampling (one dim case)
 
void SetFunction (TF1 *pdf)
 set the Function using a TF1 pointer
 
void SetRandom (TRandom *r) override
 Set the random engine to be used Needs to be called before Init to have effect.
 
void SetSeed (unsigned int seed) override
 Set the random seed for the TRandom instances used by the sampler classes Needs to be called before Init to have effect.
 
- Public Member Functions inherited from ROOT::Math::DistSampler
 DistSampler ()
 default constructor
 
virtual ~DistSampler ()
 virtual destructor
 
virtual bool Generate (unsigned int nevt, const int *nbins, ROOT::Fit::BinData &data, bool extend=true, bool expErr=true)
 Generate a binned data set.
 
virtual bool Generate (unsigned int nevt, double *data, bool eventRow=false)
 Generate a vector of events by filling the passed data vector.
 
bool Generate (unsigned int nevt, int nbins, double xmin, double xmax, ROOT::Fit::BinData &data, bool extend=true, bool expErr=true)
 Same as before but passing the range in case of 1 dim data.
 
virtual bool Generate (unsigned int nevt, ROOT::Fit::UnBinData &data)
 Generate a un-binned data set by filling the given data set object.
 
bool HasParentPdf () const
 Check if there is a parent distribution defined.
 
unsigned int NDim () const
 return the dimension of the parent distribution (and the data)
 
const ROOT::Math::IMultiGenFunctionParentPdf () const
 Get the parent distribution function (must be called after setting the function).
 
const doubleSample ()
 Sample one event and return an array x with sample coordinates values.
 
virtual double Sample1D ()
 Sample one event in one dimension.
 
virtual bool SampleBins (unsigned int n, const double *prob, double *values, double *errors=nullptr)
 Sample a set of bins given a vector of probabilities Typically multinomial statistics will be used and the sum of the probabilities will be equal to the total number of events to be generated For sampling the bins independently, SampleBin should be used.
 
virtual void SetArea (double)
 Set the normalization area of distribution.
 
virtual void SetCdf (const ROOT::Math::IGenFunction &)
 Set usage of Cumulative of PDF.
 
virtual void SetDPdf (const ROOT::Math::IGenFunction &)
 Set usage of Derivative of PDF.
 
virtual void SetFunction (const ROOT::Math::IMultiGenFunction &func)
 set the parent function distribution to use for random sampling (multi-dim case)
 
template<class Function >
void SetFunction (Function &func, unsigned int dim)
 set the parent function distribution to use for sampling (generic case)
 
virtual void SetMode (const std::vector< double > &)
 Set the mode of the distribution (Multi-dim case).
 
virtual void SetMode (double)
 Set the mode of the distribution (1D case).
 
void SetRange (const double *xmin, const double *xmax)
 Set the range for all dimensions.
 
void SetRange (const ROOT::Fit::DataRange &range)
 Set the range using the ROOT::Fit::DataRange class.
 
void SetRange (const std::vector< double > &xmin, const std::vector< double > &xmax)
 Set the range for all dimensions (use std::vector)
 
void SetRange (double xmin, double xmax, int icoord=0)
 Set the range in a given dimension.
 
virtual void SetUseLogPdf (bool=true)
 Use the log of the provided pdf.
 

Private Attributes

TFoamfFoam
 
TFoamIntegrandfFoamDist
 
const ROOT::Math::IGenFunctionfFunc1D
 

Additional Inherited Members

- Protected Member Functions inherited from ROOT::Math::DistSampler
virtual void DoSetDimension (unsigned int ndim)
 
virtual void DoSetFunction (const ROOT::Math::IMultiGenFunction &func, bool copy)
 
bool IsInitialized ()
 
const ROOT::Fit::DataRangePdfRange () const
 return the data range of the Pdf . Must be called after setting the function
 

#include <TFoamSampler.h>

Inheritance diagram for TFoamSampler:
[legend]

Constructor & Destructor Documentation

◆ TFoamSampler()

TFoamSampler::TFoamSampler ( )

default constructor

Definition at line 82 of file TFoamSampler.cxx.

◆ ~TFoamSampler()

TFoamSampler::~TFoamSampler ( )
override

virtual destructor

Definition at line 92 of file TFoamSampler.cxx.

Member Function Documentation

◆ GetRandom()

TRandom * TFoamSampler::GetRandom ( )
overridevirtual

Get the random engine used by the sampler.

Reimplemented from ROOT::Math::DistSampler.

Definition at line 172 of file TFoamSampler.cxx.

◆ Init() [1/2]

bool TFoamSampler::Init ( const char *  = "")
overridevirtual

initialize the generators with the default options

Reimplemented from ROOT::Math::DistSampler.

Definition at line 98 of file TFoamSampler.cxx.

◆ Init() [2/2]

bool TFoamSampler::Init ( const ROOT::Math::DistSamplerOptions opt)
overridevirtual

initialize the generators with the given options

Reimplemented from ROOT::Math::DistSampler.

Definition at line 107 of file TFoamSampler.cxx.

◆ Sample()

bool TFoamSampler::Sample ( double x)
overridevirtual

sample one event in multi-dimension by filling the given array return false if sampling failed

Implements ROOT::Math::DistSampler.

Definition at line 182 of file TFoamSampler.cxx.

◆ SampleBin()

bool TFoamSampler::SampleBin ( double  prob,
double value,
double error = nullptr 
)
overridevirtual

sample one bin given an estimated of the pdf in the bin (this can be function value at the center or its integral in the bin divided by the bin width) By default do not do random sample, just return the function values

Reimplemented from ROOT::Math::DistSampler.

Definition at line 195 of file TFoamSampler.cxx.

◆ SetFunction() [1/2]

void TFoamSampler::SetFunction ( const ROOT::Math::IGenFunction func)
inlineoverridevirtual

set the parent function distribution to use for random sampling (one dim case)

Reimplemented from ROOT::Math::DistSampler.

Definition at line 54 of file TFoamSampler.h.

◆ SetFunction() [2/2]

void TFoamSampler::SetFunction ( TF1 pdf)

set the Function using a TF1 pointer

Definition at line 156 of file TFoamSampler.cxx.

◆ SetRandom()

void TFoamSampler::SetRandom ( TRandom r)
overridevirtual

Set the random engine to be used Needs to be called before Init to have effect.

Reimplemented from ROOT::Math::DistSampler.

Definition at line 161 of file TFoamSampler.cxx.

◆ SetSeed()

void TFoamSampler::SetSeed ( unsigned int  seed)
overridevirtual

Set the random seed for the TRandom instances used by the sampler classes Needs to be called before Init to have effect.

Reimplemented from ROOT::Math::DistSampler.

Definition at line 166 of file TFoamSampler.cxx.

Member Data Documentation

◆ fFoam

TFoam* TFoamSampler::fFoam
private

Definition at line 120 of file TFoamSampler.h.

◆ fFoamDist

TFoamIntegrand* TFoamSampler::fFoamDist
private

Definition at line 121 of file TFoamSampler.h.

◆ fFunc1D

const ROOT::Math::IGenFunction* TFoamSampler::fFunc1D
private

Definition at line 119 of file TFoamSampler.h.

Libraries for TFoamSampler:

The documentation for this class was generated from the following files: