43using std::endl, std::string;
52 RooRealVar maxEval2D(
"maxEval2D",
"Max number of function evaluations for 2-dim integrals",100000) ;
53 RooRealVar maxEval3D(
"maxEval3D",
"Max number of function evaluations for 3-dim integrals",1000000) ;
54 RooRealVar maxEvalND(
"maxEvalND",
"Max number of function evaluations for >3-dim integrals",10000000) ;
55 RooRealVar maxWarn(
"maxWarn",
"Max number of warnings on precision not reached that is printed",5) ;
58 return std::make_unique<RooAdaptiveIntegratorND>(function, config);
61 fact.
registerPlugin(
"RooAdaptiveIntegratorND", creator, {maxEval2D,maxEval3D,maxEvalND,maxWarn},
77 _nWarn(static_cast<
Int_t>(config.getConfigSection(
"RooAdaptiveIntegratorND").getRealValue(
"maxWarn")))
80 _rooFunctor = std::make_unique<RooFunctor>(function);
81 _func = std::make_unique<ROOT::Math::Functor>(*_rooFunctor,
static_cast<unsigned int>(_rooFunctor->nObs()));
83 switch (_func->NDim()) {
84 case 1:
throw string(
Form(
"RooAdaptiveIntegratorND::ctor ERROR dimension of function must be at least 2")) ;
93 _integrator->SetFunction(*_func) ;
94 _useIntegrandLimits=true ;
106RooAdaptiveIntegratorND::~RooAdaptiveIntegratorND()
109 if (_nError>_nWarn) {
110 oocoutW(
nullptr, NumericIntegration) <<
"RooAdaptiveIntegratorND::dtor(" << _intName
111 <<
") WARNING: Number of suppressed warningings about integral evaluations where target precision was not reached is " << _nError-_nWarn << std::endl;
122bool RooAdaptiveIntegratorND::checkLimits()
const
125 _xmin.resize(_func->NDim());
126 _xmax.resize(_func->NDim());
129 if (_useIntegrandLimits) {
130 for (
UInt_t i=0 ; i<_func->NDim() ; i++) {
131 _xmin[i]= integrand()->getMinLimit(i);
132 _xmax[i]= integrand()->getMaxLimit(i);
145bool RooAdaptiveIntegratorND::setLimits(
double *
xmin,
double *
xmax)
147 if(_useIntegrandLimits) {
148 oocoutE(
nullptr,Integration) <<
"RooAdaptiveIntegratorND::setLimits: cannot override integrand's limits" << std::endl;
151 for (
UInt_t i=0 ; i<_func->NDim() ; i++) {
156 return checkLimits();
165double RooAdaptiveIntegratorND::integral(
const double* )
167 double ret = _integrator->Integral(_xmin.data(),_xmax.data());
168 if (_integrator->Status()==1) {
170 if (_nError<=_nWarn) {
171 oocoutW(
nullptr, NumericIntegration) <<
"RooAdaptiveIntegratorND::integral(" << integrand()->getName() <<
") WARNING: target rel. precision not reached due to nEval limit of "
172 << _nmax <<
", estimated rel. precision is " <<
Form(
"%3.1e",_integrator->RelError()) << std::endl ;
174 if (_nError==_nWarn) {
175 oocoutW(
nullptr, NumericIntegration) <<
"RooAdaptiveIntegratorND::integral(" << integrand()->getName()
176 <<
") Further warnings on target precision are suppressed conform specification in integrator specification" << std::endl ;
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Class for adaptive quadrature integration in multi-dimensions using rectangular regions.
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.
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.
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.
void function(const Char_t *name_, T fun, const Char_t *docstring=0)