#include <TUnuranSampler.h>
Inheritance diagram for TUnuranSampler:
Public Member Functions | |
TUnuranSampler () | |
default constructor | |
virtual | ~TUnuranSampler () |
virtual destructor | |
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 | |
bool | Init (const char *algo="") |
bool | Init (const ROOT::Math::DistSamplerOptions &opt) |
void | SetRandom (TRandom *r) |
void | SetSeed (unsigned int seed) |
void | SetPrintLevel (int level) |
void | SetMode (double mode) |
void | SetArea (double area) |
TRandom * | GetRandom () |
double | Sample1D () |
bool | Sample (double *x) |
bool | SampleBin (double prob, double &value, double *error=0) |
Protected Member Functions | |
bool | DoInit1D (const char *algo) |
bool | DoInitDiscrete1D (const char *algo) |
bool | DoInitND (const char *algo) |
Private Attributes | |
bool | fOneDim |
bool | fDiscrete |
bool | fHasMode |
bool | fHasArea |
int | fLevel |
double | fMode |
double | fArea |
const ROOT::Math::IGenFunction * | fFunc1D |
TUnuran * | fUnuran |
Definition at line 49 of file TUnuranSampler.h.
TUnuranSampler::TUnuranSampler | ( | ) |
default constructor
TUnuranSampler::~TUnuranSampler | ( | ) | [virtual] |
void TUnuranSampler::SetFunction | ( | const ROOT::Math::IGenFunction & | func | ) | [inline, virtual] |
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.
void TUnuranSampler::SetFunction | ( | TF1 * | ) |
set the Function using a TF1 pointer
Definition at line 186 of file TUnuranSampler.cxx.
References TFormula::GetNdim().
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.
References ROOT::Math::DistSamplerOptions::DefaultAlgorithm1D(), ROOT::Math::DistSamplerOptions::DefaultAlgorithmND(), ROOT::Math::DistSamplerOptions::DefaultPrintLevel(), DoInit1D(), DoInitDiscrete1D(), DoInitND(), Error, fLevel, fUnuran, Info, method, and ROOT::Math::DistSampler::NDim().
Referenced by Init().
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.
References ROOT::Math::DistSamplerOptions::Algorithm(), Init(), ROOT::Math::DistSamplerOptions::PrintLevel(), and SetPrintLevel().
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.
References fUnuran, and TUnuran::SetRandom().
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.
References fUnuran, and TUnuran::SetSeed().
void TUnuranSampler::SetPrintLevel | ( | int | level | ) | [inline] |
Set the print level (if level=-1 use default)
Definition at line 103 of file TUnuranSampler.h.
References fLevel.
Referenced by Init().
void TUnuranSampler::SetMode | ( | double | mode | ) | [inline, virtual] |
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.
void TUnuranSampler::SetArea | ( | double | area | ) | [inline, virtual] |
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.
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.
References fUnuran, and TUnuran::GetRandom().
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.
References double, fDiscrete, fUnuran, TUnuran::Sample(), and TUnuran::SampleDiscr().
Referenced by 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.
References fOneDim, fUnuran, Sample1D(), and TUnuran::SampleMulti().
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.
References fUnuran, TUnuran::GetRandom(), and sqrt().
bool TUnuranSampler::DoInit1D | ( | const char * | algo | ) | [protected] |
Definition at line 100 of file TUnuranSampler.cxx.
References ROOT::Math::gv_detail::dist(), fArea, fFunc1D, fHasArea, fHasMode, fMode, fOneDim, fUnuran, TUnuran::Init(), ROOT::Math::DistSampler::ParentPdf(), ROOT::Math::DistSampler::PdfRange(), xmax, and xmin.
Referenced by Init().
bool TUnuranSampler::DoInitDiscrete1D | ( | const char * | algo | ) | [protected] |
Definition at line 130 of file TUnuranSampler.cxx.
References ROOT::Math::gv_detail::dist(), fArea, fDiscrete, fFunc1D, fHasArea, fHasMode, fMode, fOneDim, fUnuran, TUnuran::Init(), ROOT::Math::DistSampler::ParentPdf(), ROOT::Math::DistSampler::PdfRange(), Warning(), xmax, and xmin.
Referenced by Init().
bool TUnuranSampler::DoInitND | ( | const char * | algo | ) | [protected] |
Definition at line 165 of file TUnuranSampler.cxx.
References ROOT::Math::gv_detail::dist(), fOneDim, fUnuran, TUnuran::Init(), ROOT::Math::DistSampler::ParentPdf(), ROOT::Math::DistSampler::PdfRange(), xmax, and xmin.
Referenced by Init().
bool TUnuranSampler::fOneDim [private] |
Definition at line 168 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), DoInitND(), and Sample().
bool TUnuranSampler::fDiscrete [private] |
bool TUnuranSampler::fHasMode [private] |
Definition at line 170 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), and SetMode().
bool TUnuranSampler::fHasArea [private] |
Definition at line 171 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), and SetArea().
int TUnuranSampler::fLevel [private] |
double TUnuranSampler::fMode [private] |
Definition at line 173 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), and SetMode().
double TUnuranSampler::fArea [private] |
Definition at line 174 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), and SetArea().
const ROOT::Math::IGenFunction* TUnuranSampler::fFunc1D [private] |
Definition at line 175 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), and SetFunction().
TUnuran* TUnuranSampler::fUnuran [private] |
Definition at line 176 of file TUnuranSampler.h.
Referenced by DoInit1D(), DoInitDiscrete1D(), DoInitND(), GetRandom(), Init(), Sample(), Sample1D(), SampleBin(), SetRandom(), SetSeed(), and ~TUnuranSampler().