42using std::endl, std::list;
52 RooRealVar numBins(
"numBins",
"Number of bins in range",100) ;
54 std::string
name =
"RooBinIntegrator";
57 return std::make_unique<RooBinIntegrator>(
function, config);
92 oocoutW(
nullptr,Integration) <<
"RooBinIntegrator::RooBinIntegrator WARNING: integrand provide no binning definition observable #"
93 << i <<
" substituting default binning of " <<
_numBins <<
" bins" << endl ;
94 tmp = std::make_unique<list<double>>( );
99 _binb.emplace_back(tmp->begin(), tmp->end());
124 oocoutE(
nullptr,Integration) <<
"RooBinIntegrator::setLimits: cannot override integrand's limits" << endl;
150 oocoutE(
nullptr,Integration) <<
"RooBinIntegrator::checkLimits: bad range with min >= max (_xmin = " <<
_xmin[i] <<
" _xmax = " <<
_xmax[i] <<
")" << endl;
171 const std::vector<double>& binb =
_binb[0];
173 for (
unsigned int ibin=0; ibin < binb.size() - 1; ++ibin) {
174 const double xhi = binb[ibin + 1];
175 const double xlo = binb[ibin];
176 const double xcenter = (xhi+xlo)/2.;
181 const std::vector<double>& binbx =
_binb[0];
182 const std::vector<double>& binby =
_binb[1];
184 for (
unsigned int ibin1=0; ibin1 < binbx.size() - 1; ++ibin1) {
185 const double x1hi = binbx[ibin1 + 1];
186 const double x1lo = binbx[ibin1];
187 double x1center = (x1hi+x1lo)/2 ;
189 for (
unsigned int ibin2=0; ibin2 < binby.size() - 1; ++ibin2) {
190 const double x2hi = binby[ibin2 + 1];
191 const double x2lo = binby[ibin2];
192 const double x2center = (x2hi+x2lo)/2.;
194 const double binInt =
integrand(
xvec(x1center,x2center))*(x1hi-x1lo)*(x2hi-x2lo) ;
199 const std::vector<double>& binbx =
_binb[0];
200 const std::vector<double>& binby =
_binb[1];
201 const std::vector<double>& binbz =
_binb[2];
203 for (
unsigned int ibin1=0; ibin1 < binbx.size() - 1; ++ibin1) {
204 const double x1hi = binbx[ibin1 + 1];
205 const double x1lo = binbx[ibin1];
206 double x1center = (x1hi+x1lo)/2 ;
208 for (
unsigned int ibin2=0; ibin2 < binby.size() - 1; ++ibin2) {
209 const double x2hi = binby[ibin2 + 1];
210 const double x2lo = binby[ibin2];
211 const double x2center = (x2hi+x2lo)/2.;
213 for (
unsigned int ibin3=0; ibin3 < binbz.size() - 1; ++ibin3) {
214 const double x3hi = binbz[ibin3 + 1];
215 const double x3lo = binbz[ibin3];
216 const double x3center = (x3hi+x3lo)/2.;
218 const double binInt =
integrand(
xvec(x1center,x2center,x3center))*(x1hi-x1lo)*(x2hi-x2lo)*(x3hi-x3lo);
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
virtual double getMaxLimit(UInt_t dimension) const =0
virtual double getMinLimit(UInt_t dimension) const =0
UInt_t getDimension() const
virtual std::list< double > * binBoundaries(Int_t) const
Abstract interface for integrators of real-valued functions that implement the RooAbsFunc interface.
bool isValid() const
Is integrator in valid state.
const RooAbsFunc * _function
Pointer to function binding of integrand.
const RooAbsFunc * integrand() const
Return integrand function binding.
Computes the integral over a binned distribution by summing the bin contents of all bins.
std::vector< double > _xmax
! Upper integration bound
static void registerIntegrator(RooNumIntFactory &fact)
Register RooBinIntegrator, is parameters and capabilities with RooNumIntFactory.
Int_t _numBins
! Size of integration range
bool setLimits(double *xmin, double *xmax) override
Change our integration limits.
std::vector< std::vector< double > > _binb
! list of bin boundaries
std::vector< double > _xmin
! Lower integration bound
RooBinIntegrator(const RooAbsFunc &function, int numBins=100)
Construct integrator on given function binding binding.
std::vector< double > _x
! do not persist
bool _useIntegrandLimits
If true limits of function binding are ued.
bool checkLimits() const override
Check that our integration range is finite and otherwise return false.
double integral(const double *yvec=nullptr) override
Calculate numeric integral at given set of function binding parameters.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
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...
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
Variable that can be changed from the outside.
static uint64_t sum(uint64_t i)