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

TUnuranSampler class class implementing the ROOT::Math::DistSampler interface using the UNU.RAN package for sampling distributions.

Definition at line 49 of file TUnuranSampler.h.

Public Member Functions

 TUnuranSampler ()
 default constructor
 
virtual ~TUnuranSampler ()
 virtual destructor
 
TRandomGetRandom ()
 Get the random engine used by the sampler.
 
bool Init (const char *algo="")
 initialize the generators with the given algorithm If no algorithm is passed used the default one for the type of distribution
 
bool Init (const ROOT::Math::DistSamplerOptions &opt)
 initialize the generators with the given algorithm If no algorithm is passed used the default one for the type of distribution
 
bool Sample (double *x)
 sample one event in multi-dimension by filling the given array return false if sampling failed
 
double Sample1D ()
 sample one event in one dimension better implementation could be provided by the derived classes
 
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 its integral in the bin divided by the bin width) By default do not do random sample, just return the function values
 
void SetArea (double area)
 set the normalization area of distribution implemented by derived classes if needed
 
void SetFunction (const ROOT::Math::IGenFunction &func)
 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 SetMode (double mode)
 set the mode of the distribution (could be useful to some methods) implemented by derived classes if needed
 
void SetPrintLevel (int level)
 Set the print level (if level=-1 use default)
 
void SetRandom (TRandom *r)
 Set the random engine to be used Needs to be called before Init to have effect.
 
void SetSeed (unsigned int seed)
 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)
 generate a bin data set .
 
bool Generate (unsigned int nevt, int nbins, double xmin, double xmax, ROOT::Fit::BinData &data, bool extend=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 sets (fill the given data set) if dataset has already data append to it
 
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 rerturning array x with coordinates
 
virtual bool SampleBins (unsigned int n, const double *prob, double *values, double *errors=0)
 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 indipendently, SampleBin should be used
 
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)
 
void SetRange (const double *xmin, const double *xmax)
 set range for all dimensions
 
void SetRange (const ROOT::Fit::DataRange &range)
 set range using DataRange class
 
void SetRange (double xmin, double xmax, int icoord=0)
 set range in a given dimension
 

Protected Member Functions

bool DoInit1D (const char *algo)
 
bool DoInitDiscrete1D (const char *algo)
 
bool DoInitND (const char *algo)
 
- Protected Member Functions inherited from ROOT::Math::DistSampler
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
 

Private Attributes

double fArea
 
bool fDiscrete
 
const ROOT::Math::IGenFunctionfFunc1D
 
bool fHasArea
 
bool fHasMode
 
int fLevel
 
double fMode
 
bool fOneDim
 
TUnuranfUnuran
 

#include <TUnuranSampler.h>

Inheritance diagram for TUnuranSampler:
[legend]

Constructor & Destructor Documentation

◆ TUnuranSampler()

TUnuranSampler::TUnuranSampler ( )

default constructor

Definition at line 32 of file TUnuranSampler.cxx.

◆ ~TUnuranSampler()

TUnuranSampler::~TUnuranSampler ( )
virtual

virtual destructor

Definition at line 43 of file TUnuranSampler.cxx.

Member Function Documentation

◆ DoInit1D()

bool TUnuranSampler::DoInit1D ( const char *  algo)
protected

Definition at line 100 of file TUnuranSampler.cxx.

◆ DoInitDiscrete1D()

bool TUnuranSampler::DoInitDiscrete1D ( const char *  algo)
protected

Definition at line 130 of file TUnuranSampler.cxx.

◆ DoInitND()

bool TUnuranSampler::DoInitND ( const char *  algo)
protected

Definition at line 165 of file TUnuranSampler.cxx.

◆ GetRandom()

TRandom * TUnuranSampler::GetRandom ( )
virtual

Get the random engine used by the sampler.

Reimplemented from ROOT::Math::DistSampler.

Definition at line 201 of file TUnuranSampler.cxx.

◆ Init() [1/2]

bool TUnuranSampler::Init ( const char *  algo = "")
virtual

initialize the generators with the given algorithm If no algorithm is passed used the default one for the type of distribution

Reimplemented from ROOT::Math::DistSampler.

Definition at line 48 of file TUnuranSampler.cxx.

◆ Init() [2/2]

bool TUnuranSampler::Init ( const ROOT::Math::DistSamplerOptions opt)
virtual

initialize the generators with the given algorithm If no algorithm is passed used the default one for the type of distribution

Reimplemented from ROOT::Math::DistSampler.

Definition at line 93 of file TUnuranSampler.cxx.

◆ Sample()

bool TUnuranSampler::Sample ( double x)
virtual

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

Implements ROOT::Math::DistSampler.

Definition at line 211 of file TUnuranSampler.cxx.

◆ Sample1D()

double TUnuranSampler::Sample1D ( )
virtual

sample one event in one dimension better implementation could be provided by the derived classes

Reimplemented from ROOT::Math::DistSampler.

Definition at line 206 of file TUnuranSampler.cxx.

◆ SampleBin()

bool TUnuranSampler::SampleBin ( double  prob,
double value,
double error = 0 
)
virtual

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 219 of file TUnuranSampler.cxx.

◆ SetArea()

void TUnuranSampler::SetArea ( double  )
inlinevirtual

set the normalization area of distribution implemented by derived classes if needed

Reimplemented from ROOT::Math::DistSampler.

Definition at line 116 of file TUnuranSampler.h.

◆ SetFunction() [1/2]

void TUnuranSampler::SetFunction ( const ROOT::Math::IGenFunction func)
inlinevirtual

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

Reimplemented from ROOT::Math::DistSampler.

Definition at line 64 of file TUnuranSampler.h.

◆ SetFunction() [2/2]

void TUnuranSampler::SetFunction ( TF1 pdf)

set the Function using a TF1 pointer

Definition at line 186 of file TUnuranSampler.cxx.

◆ SetMode()

void TUnuranSampler::SetMode ( double  )
inlinevirtual

set the mode of the distribution (could be useful to some methods) implemented by derived classes if needed

Reimplemented from ROOT::Math::DistSampler.

Definition at line 108 of file TUnuranSampler.h.

◆ SetPrintLevel()

void TUnuranSampler::SetPrintLevel ( int  level)
inline

Set the print level (if level=-1 use default)

Definition at line 103 of file TUnuranSampler.h.

◆ SetRandom()

void TUnuranSampler::SetRandom ( TRandom r)
virtual

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

Reimplemented from ROOT::Math::DistSampler.

Definition at line 191 of file TUnuranSampler.cxx.

◆ SetSeed()

void TUnuranSampler::SetSeed ( unsigned int  seed)
virtual

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 196 of file TUnuranSampler.cxx.

Member Data Documentation

◆ fArea

double TUnuranSampler::fArea
private

Definition at line 174 of file TUnuranSampler.h.

◆ fDiscrete

bool TUnuranSampler::fDiscrete
private

Definition at line 169 of file TUnuranSampler.h.

◆ fFunc1D

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

Definition at line 175 of file TUnuranSampler.h.

◆ fHasArea

bool TUnuranSampler::fHasArea
private

Definition at line 171 of file TUnuranSampler.h.

◆ fHasMode

bool TUnuranSampler::fHasMode
private

Definition at line 170 of file TUnuranSampler.h.

◆ fLevel

int TUnuranSampler::fLevel
private

Definition at line 172 of file TUnuranSampler.h.

◆ fMode

double TUnuranSampler::fMode
private

Definition at line 173 of file TUnuranSampler.h.

◆ fOneDim

bool TUnuranSampler::fOneDim
private

Definition at line 168 of file TUnuranSampler.h.

◆ fUnuran

TUnuran* TUnuranSampler::fUnuran
private

Definition at line 176 of file TUnuranSampler.h.

Libraries for TUnuranSampler:

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