54 RooCategory samplingMode(
"samplingMode",
"Sampling Mode") ;
66 verbose.defineType(
"true",1) ;
67 verbose.defineType(
"false",0) ;
70 RooRealVar alpha(
"alpha",
"Grid structure constant",1.5) ;
71 RooRealVar nRefineIter(
"nRefineIter",
"Number of refining iterations",5) ;
72 RooRealVar nRefinePerDim(
"nRefinePerDim",
"Number of refining samples (per dimension)",1000) ;
73 RooRealVar nIntPerDim(
"nIntPerDim",
"Number of integration samples (per dimension)",5000) ;
77 return std::make_unique<RooMCIntegrator>(function,config);
81 std::string
name =
"RooMCIntegrator";
82 fact.
registerPlugin(
name, creator, {samplingMode,genType,verbose,alpha,nRefineIter,nRefinePerDim,nIntPerDim},
103 _alpha(1.5), _mode(
mode), _genType(genType),
104 _nRefineIter(5),_nRefinePerDim(1000),_nIntegratePerDim(5000)
187 UInt_t bins = RooGrid::maxBins;
195 boxes = (
UInt_t)floor(std::pow(calls/2.0,1.0/dim));
199 if (2*boxes >= RooGrid::maxBins) {
202 Int_t box_per_bin= (boxes > RooGrid::maxBins) ? boxes/RooGrid::maxBins : 1;
203 bins= boxes/box_per_bin;
204 if(bins > RooGrid::maxBins) bins= RooGrid::maxBins;
205 boxes = box_per_bin * bins;
206 oocxcoutD((
TObject*)
nullptr,Integration) <<
"RooMCIntegrator: using stratified sampling with " << bins <<
" bins and "
207 << box_per_bin <<
" boxes/bin" << endl;
210 oocxcoutD((
TObject*)
nullptr,Integration) <<
"RooMCIntegrator: using importance sampling with " << bins <<
" bins and "
211 << boxes <<
" boxes" << endl;
216 double tot_boxes = std::pow((
double)boxes,(
double)dim);
224 _jac =
_grid.getVolume()*std::pow((
double)bins,(
double)dim)/calls;
227 _grid.setNBoxes(boxes);
228 if(bins !=
_grid.getNBins())
_grid.resize(bins);
232 std::vector<UInt_t>
box(
_grid.getDimension());
233 std::vector<UInt_t> bin(
_grid.getDimension());
234 std::vector<double>
x(
_grid.getDimension());
242 for (
UInt_t it = 0; it < iterations; it++) {
264 double fval= jacbin*bin_vol*
integrand(
x.data());
268 q+=
d *
d * (k / (k + 1.0));
281 std::size_t
index = 0;
282 std::size_t sizeOfDim = 1;
284 for (
unsigned int i=0; i <
_grid.getDimension(); ++i) {
286 sizeOfDim *=
_grid.getNBoxes();
288 oocoutP(
nullptr, Integration) <<
"RooMCIntegrator: still working ... iteration "
289 << it <<
'/' << iterations <<
" box " <<
index <<
"/"<< std::pow(
_grid.getNBoxes(),
_grid.getDimension()) << endl;
310 intgrl_sq = intgrl * intgrl;
328 cum_int += (intgrl - cum_int) / (it + 1.0);
331 oocxcoutD((
TObject*)
nullptr,Integration) <<
"=== Iteration " <<
_it_num <<
" : I = " << intgrl <<
" +/- " << sqrt(sig) << endl
332 <<
" Cumulative : I = " << cum_int <<
" +/- " << cum_sig <<
"( chi2 = " <<
_chisq
336 if(it + 1 == iterations)
_grid.print(std::cout,
true);
341 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.
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.
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 ...
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
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.
Factory to instantiate numeric integrators from a given function binding and a given configuration.
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...
Variable that can be changed from the outside.
Mother of all ROOT objects.
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)