51 return std::make_unique<RooImproperIntegrator1D>(function, config);
67RooImproperIntegrator1D::RooImproperIntegrator1D(
const RooAbsFunc& function) :
69 _useIntegrandLimits(true),
83 _useIntegrandLimits(true),
99 _useIntegrandLimits(false),
111void RooImproperIntegrator1D::initialize(
const RooAbsFunc* function)
114 oocoutE(
nullptr,Integration) <<
"RooImproperIntegrator: cannot integrate invalid function" << std::endl;
119 _function= std::make_unique<RooInvTransform>(*function);
122 _integrator1.reset();
123 _integrator2.reset();
124 _integrator3.reset();
129 auto makeIntegrator1D = [&](
RooAbsFunc const& func,
131 RooRombergIntegrator::SummationRule rule) {
134 return std::make_unique<RooRombergIntegrator>(func,
xmin,
xmax, newConfig);
139 switch(_case= limitsCase()) {
142 _integrator1 = std::make_unique<RooRombergIntegrator>(*function,_xmin,_xmax,_config);
147 _integrator1 = makeIntegrator1D(*function,-1,+1,RooRombergIntegrator::Trapezoid);
149 _integrator2 = makeIntegrator1D(*_function,-1,0,RooRombergIntegrator::Midpoint);
150 _integrator3 = makeIntegrator1D(*_function,0,+1,RooRombergIntegrator::Midpoint);
152 case OpenBelowSpansZero:
154 _integrator1 = makeIntegrator1D(*_function,-1,0,RooRombergIntegrator::Midpoint);
155 _integrator2 = makeIntegrator1D(*function,-1,_xmax,RooRombergIntegrator::Trapezoid);
159 _integrator1 = makeIntegrator1D(*_function,1/_xmax,0,RooRombergIntegrator::Midpoint);
161 case OpenAboveSpansZero:
163 _integrator1 = makeIntegrator1D(*_function,0,+1,RooRombergIntegrator::Midpoint);
164 _integrator2 = makeIntegrator1D(*function,_xmin,+1,RooRombergIntegrator::Trapezoid);
168 _integrator1 = makeIntegrator1D(*_function,0,1/_xmin,RooRombergIntegrator::Midpoint);
182bool RooImproperIntegrator1D::setLimits(
double *
xmin,
double *
xmax)
184 if(_useIntegrandLimits) {
185 oocoutE(
nullptr,Integration) <<
"RooImproperIntegrator1D::setLimits: cannot override integrand's limits" << std::endl;
191 return checkLimits();
201bool RooImproperIntegrator1D::checkLimits()
const
204 if (_useIntegrandLimits) {
205 if(_xmin == integrand()->getMinLimit(0) &&
206 _xmax == integrand()->getMaxLimit(0))
return true;
210 if(limitsCase() != _case) {
212 const_cast<RooImproperIntegrator1D*
>(
this)->
initialize() ;
219 _integrator1->setLimits(_xmin,_xmax);
224 case OpenBelowSpansZero:
225 _integrator2->setLimits(-1,_xmax);
228 _integrator1->setLimits(1/_xmax,0);
230 case OpenAboveSpansZero:
231 _integrator2->setLimits(_xmin,+1);
234 _integrator1->setLimits(0,1/_xmin);
247RooImproperIntegrator1D::LimitsCase RooImproperIntegrator1D::limitsCase()
const
250 if(
nullptr == integrand() || !integrand()->isValid())
return Invalid;
252 if (_useIntegrandLimits) {
253 _xmin= integrand()->getMinLimit(0);
254 _xmax= integrand()->getMaxLimit(0);
261 return ClosedBothEnds;
263 else if(inf1 && inf2) {
269 return OpenBelowSpansZero;
277 return OpenAboveSpansZero;
290double RooImproperIntegrator1D::integral(
const double* yvec)
293 if(_integrator1) result+= _integrator1->integral(yvec);
294 if(_integrator2) result+= _integrator2->integral(yvec);
295 if(_integrator3) result+= _integrator3->integral(yvec);
bool setCatIndex(const char *name, Int_t newVal=0, bool verbose=false)
Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
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...
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
void function(const Char_t *name_, T fun, const Char_t *docstring=0)