TUnuranSampler class class implementing the ROOT::Math::DistSampler interface using the UNU.RAN package for sampling distributions.
Definition at line 51 of file TUnuranSampler.h.
Public Member Functions | |
| TUnuranSampler () | |
| default constructor | |
| ~TUnuranSampler () override | |
| 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. | |
| TRandom * | GetRandom () override |
| Get the random engine used by the sampler. | |
| bool | HasParentPdf () const |
| Check if there is a parent distribution defined. | |
| bool | Init (const char *algo="") override |
| 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) override |
| initialize the generators with the given algorithm If no algorithm is passed used the default one for the type of distribution | |
| virtual TClass * | IsA () const |
| unsigned int | NDim () const |
| return the dimension of the parent distribution (and the data) | |
| const ROOT::Math::IMultiGenFunction & | ParentPdf () const |
| Get the parent distribution function (must be called after setting the function). | |
| const double * | Sample () |
| Sample one event and return an array x with sample coordinates values. | |
| bool | Sample (double *x) override |
| sample one event in multi-dimension by filling the given array return false if sampling failed | |
| double | Sample1D () override |
| sample one event in one dimension better implementation could be provided by the derived classes | |
| 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 | |
| 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. | |
| void | SetArea (double area) override |
| Set the normalization area of distribution. | |
| void | SetCdf (const ROOT::Math::IGenFunction &cdf) override |
| set the cumulative distribution function of the PDF used for random sampling (one dim case) | |
| void | SetDPdf (const ROOT::Math::IGenFunction &dpdf) override |
| set the Derivative of the PDF used for random sampling (one dim continuous case) | |
| 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 | 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 | SetMode (const std::vector< double > &modes) override |
| Set the mode of the distribution (Multi-dim case). | |
| void | SetMode (double mode) override |
| Set the mode of the distribution (1D case). | |
| void | SetPrintLevel (int level) |
| Set the print level (if level=-1 use default). | |
| void | SetRandom (TRandom *r) override |
| Set the random engine to be used Needs to be called before Init to have effect. | |
| 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. | |
| 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. | |
| void | SetUseLogPdf (bool on=true) override |
| Set using of logarithm of PDF (only for 1D continuous case). | |
| virtual void | Streamer (TBuffer &) |
| void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Static Public Member Functions | |
| static TClass * | Class () |
| static const char * | Class_Name () |
| static constexpr Version_t | Class_Version () |
| static const char * | DeclFileName () |
Protected Member Functions | |
| bool | DoInit1D (const char *algo) |
| Initialization for 1D distributions. | |
| bool | DoInitDiscrete1D (const char *algo) |
| Initialization for 1D discrete distributions. | |
| bool | DoInitND (const char *algo) |
| Initialization for multi-dim distributions. | |
| virtual void | DoSetDimension (unsigned int ndim) |
| virtual void | DoSetFunction (const ROOT::Math::IMultiGenFunction &func, bool copy) |
| bool | IsInitialized () |
| const ROOT::Fit::DataRange & | PdfRange () const |
| return the data range of the Pdf . Must be called after setting the function | |
Private Attributes | |
| double | fArea |
| area of dist | |
| const ROOT::Math::IGenFunction * | fCDF = nullptr |
| CDF function pointer. | |
| std::vector< double > | fData |
| ! internal array used to cached the sample data | |
| bool | fDiscrete = false |
| flag to indicate if the function is discrete | |
| const ROOT::Math::IGenFunction * | fDPDF = nullptr |
| 1D Derivative function pointer | |
| const ROOT::Math::IMultiGenFunction * | fFunc |
| internal function (ND) | |
| const ROOT::Math::IGenFunction * | fFunc1D = nullptr |
| 1D function pointer (pdf) | |
| bool | fHasArea = false |
| flag to indicate if a area is set | |
| bool | fHasMode = false |
| flag to indicate if a mode is set | |
| int | fLevel |
| debug level | |
| double | fMode |
| mode of dist (1D) | |
| std::vector< double > | fNDMode |
| mode of the multi-dim distribution | |
| bool | fOneDim = false |
| flag to indicate if the function is 1 dimension | |
| bool | fOwnFunc |
| flag to indicate if the function is owned | |
| ROOT::Fit::DataRange * | fRange |
| data range | |
| TUnuran * | fUnuran = nullptr |
| unuran engine class | |
| bool | fUseLogPdf = false |
| flag to indicate if we use the log of the PDF | |
#include <TUnuranSampler.h>
| TUnuranSampler::TUnuranSampler | ( | ) |
default constructor
Definition at line 32 of file TUnuranSampler.cxx.
|
override |
virtual destructor
Definition at line 42 of file TUnuranSampler.cxx.
|
static |
|
static |
|
inlinestaticconstexpr |
Definition at line 198 of file TUnuranSampler.h.
|
inlinestatic |
Definition at line 198 of file TUnuranSampler.h.
|
protected |
Initialization for 1D distributions.
Definition at line 142 of file TUnuranSampler.cxx.
|
protected |
Initialization for 1D discrete distributions.
Definition at line 182 of file TUnuranSampler.cxx.
|
protected |
Initialization for multi-dim distributions.
Definition at line 223 of file TUnuranSampler.cxx.
|
protectedvirtualinherited |
Definition at line 78 of file DistSampler.cxx.
|
protectedvirtualinherited |
Definition at line 63 of file DistSampler.cxx.
|
virtualinherited |
Generate a binned data set.
A range must have been set before (otherwise inf is returned) and the bins are equidistant in the previously defined range bin center values must be present in given data set If the sampler is implemented by a random one, the entries will be binned according to the Poisson distribution It is assumed the distribution is normalized, otherwise the nevt must be scaled accordingly. The expected value/bin nexp = f(x_i) * binArea/ nevt Extend control if use a fixed (i.e. multinomial statistics) or floating total number of events
Definition at line 135 of file DistSampler.cxx.
|
virtualinherited |
Generate a vector of events by filling the passed data vector.
The flag eventRow indicates how the events are arranged in the multi-dim case. The can be arranged in rows or in columns. With eventRow=false events are the columns in data: {x1,x2,.....,xn},{y1,....yn} With eventRow=true events are rows in data: {x1,y1},{x2,y2},.....{xn,yn}
Definition at line 115 of file DistSampler.cxx.
|
inlineinherited |
Same as before but passing the range in case of 1 dim data.
Definition at line 261 of file DistSampler.h.
|
virtualinherited |
Generate a un-binned data set by filling the given data set object.
If the data set object is not empty, the new generated data will be appended to the existing one.
Definition at line 99 of file DistSampler.cxx.
|
overridevirtual |
Get the random engine used by the sampler.
Reimplemented from ROOT::Math::DistSampler.
Definition at line 261 of file TUnuranSampler.cxx.
|
inlineinherited |
Check if there is a parent distribution defined.
Definition at line 179 of file DistSampler.h.
|
overridevirtual |
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 47 of file TUnuranSampler.cxx.
|
overridevirtual |
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 105 of file TUnuranSampler.cxx.
|
inlinevirtual |
Definition at line 198 of file TUnuranSampler.h.
|
protectedinherited |
Definition at line 89 of file DistSampler.cxx.
|
inlineinherited |
return the dimension of the parent distribution (and the data)
Definition at line 92 of file DistSampler.h.
|
inlineinherited |
Get the parent distribution function (must be called after setting the function).
Definition at line 174 of file DistSampler.h.
|
inlineprotectedinherited |
return the data range of the Pdf . Must be called after setting the function
Definition at line 277 of file DistSampler.h.
|
inlineinherited |
Sample one event and return an array x with sample coordinates values.
Definition at line 194 of file DistSampler.h.
sample one event in multi-dimension by filling the given array return false if sampling failed
Implements ROOT::Math::DistSampler.
Definition at line 271 of file TUnuranSampler.cxx.
|
overridevirtual |
sample one event in one dimension better implementation could be provided by the derived classes
Reimplemented from ROOT::Math::DistSampler.
Definition at line 266 of file TUnuranSampler.cxx.
|
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 279 of file TUnuranSampler.cxx.
|
inlinevirtualinherited |
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.
Definition at line 224 of file DistSampler.h.
|
inlineoverridevirtual |
Set the normalization area of distribution.
Implemented by derived classes if needed
Reimplemented from ROOT::Math::DistSampler.
Definition at line 129 of file TUnuranSampler.h.
|
overridevirtual |
set the cumulative distribution function of the PDF used for random sampling (one dim case)
Reimplemented from ROOT::Math::DistSampler.
Definition at line 306 of file TUnuranSampler.cxx.
|
overridevirtual |
set the Derivative of the PDF used for random sampling (one dim continuous case)
Reimplemented from ROOT::Math::DistSampler.
Definition at line 312 of file TUnuranSampler.cxx.
|
inlinevirtualinherited |
set the parent function distribution to use for random sampling (multi-dim case)
Definition at line 87 of file DistSampler.h.
|
inlineinherited |
set the parent function distribution to use for sampling (generic case)
Definition at line 73 of file DistSampler.h.
|
inlineoverridevirtual |
Set the parent function distribution to use for random sampling (one dim case).
Reimplemented from ROOT::Math::DistSampler.
Definition at line 66 of file TUnuranSampler.h.
| void TUnuranSampler::SetFunction | ( | TF1 * | ) |
Set the Function using a TF1 pointer.
Definition at line 246 of file TUnuranSampler.cxx.
|
overridevirtual |
Set the mode of the distribution (Multi-dim case).
Reimplemented from ROOT::Math::DistSampler.
Definition at line 288 of file TUnuranSampler.cxx.
|
inlineoverridevirtual |
Set the mode of the distribution (1D case).
It could be useful or needed by some sampling methods. It is implemented by derived classes if needed (e.g. TUnuranSampler)
Reimplemented from ROOT::Math::DistSampler.
Definition at line 115 of file TUnuranSampler.h.
|
inline |
Set the print level (if level=-1 use default).
Definition at line 110 of file TUnuranSampler.h.
|
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 251 of file TUnuranSampler.cxx.
Set the range for all dimensions.
Definition at line 48 of file DistSampler.cxx.
|
inherited |
Set the range using the ROOT::Fit::DataRange class.
Definition at line 58 of file DistSampler.cxx.
|
inlineinherited |
Set the range for all dimensions (use std::vector).
Definition at line 141 of file DistSampler.h.
Set the range in a given dimension.
Definition at line 40 of file DistSampler.cxx.
|
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 256 of file TUnuranSampler.cxx.
|
inlineoverridevirtual |
Set using of logarithm of PDF (only for 1D continuous case).
Reimplemented from ROOT::Math::DistSampler.
Definition at line 135 of file TUnuranSampler.h.
|
virtual |
|
inline |
Definition at line 198 of file TUnuranSampler.h.
|
private |
area of dist
Definition at line 191 of file TUnuranSampler.h.
|
private |
CDF function pointer.
Definition at line 194 of file TUnuranSampler.h.
|
mutableprivateinherited |
! internal array used to cached the sample data
Definition at line 287 of file DistSampler.h.
|
private |
flag to indicate if the function is discrete
Definition at line 185 of file TUnuranSampler.h.
|
private |
1D Derivative function pointer
Definition at line 195 of file TUnuranSampler.h.
|
privateinherited |
internal function (ND)
Definition at line 289 of file DistSampler.h.
|
private |
1D function pointer (pdf)
Definition at line 193 of file TUnuranSampler.h.
|
private |
flag to indicate if a area is set
Definition at line 187 of file TUnuranSampler.h.
|
private |
flag to indicate if a mode is set
Definition at line 186 of file TUnuranSampler.h.
|
private |
debug level
Definition at line 189 of file TUnuranSampler.h.
|
private |
mode of dist (1D)
Definition at line 190 of file TUnuranSampler.h.
|
private |
mode of the multi-dim distribution
Definition at line 192 of file TUnuranSampler.h.
|
private |
flag to indicate if the function is 1 dimension
Definition at line 184 of file TUnuranSampler.h.
|
privateinherited |
flag to indicate if the function is owned
Definition at line 286 of file DistSampler.h.
|
privateinherited |
data range
Definition at line 288 of file DistSampler.h.
|
private |
unuran engine class
Definition at line 196 of file TUnuranSampler.h.
|
private |
flag to indicate if we use the log of the PDF
Definition at line 188 of file TUnuranSampler.h.