57 RooCategory samplingMode(
"samplingMode",
"Sampling Mode") ;
69 verbose.defineType(
"true",1) ;
70 verbose.defineType(
"false",0) ;
73 RooRealVar alpha(
"alpha",
"Grid structure constant",1.5) ;
74 RooRealVar nRefineIter(
"nRefineIter",
"Number of refining iterations",5) ;
75 RooRealVar nRefinePerDim(
"nRefinePerDim",
"Number of refining samples (per dimension)",1000) ;
76 RooRealVar nIntPerDim(
"nIntPerDim",
"Number of integration samples (per dimension)",5000) ;
80 return std::make_unique<RooMCIntegrator>(function,config);
84 std::string
name =
"RooMCIntegrator";
85 fact.
registerPlugin(
name, creator, {samplingMode,genType,verbose,alpha,nRefineIter,nRefinePerDim,nIntPerDim},
106 _alpha(1.5), _mode(
mode), _genType(genType),
107 _nRefineIter(5),_nRefinePerDim(1000),_nIntegratePerDim(5000)
216 bins= boxes/box_per_bin;
218 boxes = box_per_bin * bins;
219 oocxcoutD((
TObject*)
nullptr,Integration) <<
"RooMCIntegrator: using stratified sampling with " << bins <<
" bins and "
220 << box_per_bin <<
" boxes/bin" << endl;
223 oocxcoutD((
TObject*)
nullptr,Integration) <<
"RooMCIntegrator: using importance sampling with " << bins <<
" bins and "
224 << boxes <<
" boxes" << endl;
229 double tot_boxes =
TMath::Power((
double)boxes,(
double)dim);
251 double cum_int(0),cum_sig(0);
254 for (
UInt_t it = 0; it < iterations; it++) {
255 double intgrl(0),intgrl_sq(0),sig(0),jacbin(
_jac);
272 double fval= jacbin*bin_vol*
integrand(
x.data());
276 q+=
d *
d * (k / (k + 1.0));
289 std::size_t
index = 0;
290 std::size_t sizeOfDim = 1;
296 coutP(Integration) <<
"RooMCIntegrator: still working ... iteration "
318 intgrl_sq = intgrl * intgrl;
336 cum_int += (intgrl - cum_int) / (it + 1.0);
339 oocxcoutD((
TObject*)
nullptr,Integration) <<
"=== Iteration " <<
_it_num <<
" : I = " << intgrl <<
" +/- " << sqrt(sig) << endl
340 <<
" Cumulative : I = " << cum_int <<
" +/- " << cum_sig <<
"( chi2 = " <<
_chisq
344 if(it + 1 == iterations)
_grid.
print(std::cout,
true);
349 if(absError) *absError = cum_sig;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char mode
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
Int_t getCatIndex(const char *name, Int_t defVal=0, bool verbose=false) const
Get index value of a RooAbsCategory stored in set with given name.
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Abstract interface for integrators of real-valued functions that implement the RooAbsFunc interface.
const RooAbsFunc * _function
Pointer to function binding of integrand.
const RooAbsFunc * integrand() const
Return integrand function binding.
bool _valid
Is integrator in valid state?
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
bool defineType(const std::string &label)
Define a state with given name.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
UInt_t getDimension() const
bool initialize(const RooAbsFunc &function)
Calculate and store the grid dimensions and volume using the specified function, and initialize the g...
void generatePoint(const UInt_t box[], double x[], UInt_t bin[], double &vol, bool useQuasiRandom=true) const
Generate a random vector in the specified box and store its coordinates in the x[] array provided,...
void resetValues()
Reset the values associated with each grid cell.
void accumulate(const UInt_t bin[], double amount)
Add the specified amount to bin[j] of the 1D histograms associated with each axis j.
bool nextBox(UInt_t box[]) const
Update the specified array of box indices to refer to the next box in the standard traversal order an...
void resize(UInt_t bins)
Adjust the subdivision of each axis to give the specified number of bins, using an algorithm that pre...
void setNBoxes(UInt_t boxes)
void refine(double alpha=1.5)
Refine the grid using the values that have been accumulated so far.
void firstBox(UInt_t box[]) const
Reset the specified array of box indices to refer to the first box in the standard traversal order.
void print(std::ostream &os, bool verbose=false, std::string const &indent="") const
Print info about this object to the specified stream.
RooMCIntegrator implements an adaptive multi-dimensional Monte Carlo numerical integration,...
GeneratorType _genType
Generator type.
static void registerIntegrator(RooNumIntFactory &fact)
This function registers class RooMCIntegrator, its configuration options and its capabilities with Ro...
Int_t _nIntegratePerDim
Number of integration samplings (per dim)
RooMCIntegrator(const RooAbsFunc &function, SamplingMode mode=Importance, GeneratorType genType=QuasiRandom, bool verbose=false)
Construct an integrator over 'function' with given sampling mode and generator type.
~RooMCIntegrator() override
Destructor.
bool checkLimits() const override
Check if we can integrate over the current domain.
double _sigma
Scratch variables preserved between calls to vegas1/2/2.
double vegas(Stage stage, UInt_t calls, UInt_t iterations, double *absError=nullptr)
Perform one step of Monte Carlo integration using the specified number of iterations with (approximat...
bool _verbose
Verbosity control.
Int_t _mode
Sampling mode.
Int_t _nRefinePerDim
Number of refinement samplings (per dim)
double _alpha
Grid stiffness parameter.
UInt_t _calls_per_box
Scratch variables preserved between calls to vegas1/2/2.
Int_t _nRefineIter
Number of refinement iterations.
double integral(const double *yvec=nullptr) override
Evaluate the integral using a fixed number of calls to evaluate the integrand equal to about 10k per ...
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
static RooNumIntConfig & defaultConfig()
Return reference to instance of default numeric integrator configuration object.
RooNumIntFactory is a factory to instantiate numeric integrators from a given function binding and a ...
bool registerPlugin(std::string const &name, Creator const &creator, const RooArgSet &defConfig, bool canIntegrate1D, bool canIntegrate2D, bool canIntegrateND, bool canIntegrateOpenEnded, const char *depName="")
Method accepting registration of a prototype numeric integrator along with a RooArgSet of its default...
RooRealVar represents a variable that can be changed from the outside.
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.