57 RooRealVar numBins(
"numBins",
"Number of bins in range",100) ;
96 const bool useBatchMode =
false;
99 _evalData = std::make_unique<RooBatchCompute::RunContext>();
100 _evalDataOrig = std::make_unique<RooBatchCompute::RunContext>();
110 oocoutW(
nullptr,Integration) <<
"RooBinIntegrator::RooBinIntegrator WARNING: integrand provide no binning definition observable #"
111 << i <<
" substituting default binning of " <<
_numBins <<
" bins" << endl ;
112 tmp.reset(
new list<double> );
117 _binb.emplace_back(tmp->begin(), tmp->end());
120 const std::vector<double>& binb =
_binb.back();
122 for (
unsigned int ibin = 0; ibin < binb.size() - 1; ++ibin) {
123 binCentres[ibin] = (binb[ibin + 1] + binb[ibin]) / 2.;
136 RooBinIntegrator(function, static_cast<
int>(config.getConfigSection(
"RooBinIntegrator").getRealValue(
"numBins")))
169 oocoutE(
nullptr,Integration) <<
"RooBinIntegrator::setLimits: cannot override integrand's limits" << endl;
195 oocoutE(
nullptr,Integration) <<
"RooBinIntegrator::checkLimits: bad range with min >= max (_xmin = " <<
_xmin[i] <<
" _xmax = " <<
_xmax[i] <<
")" << endl;
216 const std::vector<double>& binb =
_binb[0];
225 assert(results.size() == binb.size() - 1);
227 for (
unsigned int ibin = 0; ibin < binb.size() - 1; ++ibin) {
228 const double width = binb[ibin + 1] - binb[ibin];
233 for (
unsigned int ibin=0; ibin < binb.size() - 1; ++ibin) {
234 const double xhi = binb[ibin + 1];
235 const double xlo = binb[ibin];
236 const double xcenter = (xhi+xlo)/2.;
242 const std::vector<double>& binbx =
_binb[0];
243 const std::vector<double>& binby =
_binb[1];
245 for (
unsigned int ibin1=0; ibin1 < binbx.size() - 1; ++ibin1) {
246 const double x1hi = binbx[ibin1 + 1];
247 const double x1lo = binbx[ibin1];
248 double x1center = (x1hi+x1lo)/2 ;
250 for (
unsigned int ibin2=0; ibin2 < binby.size() - 1; ++ibin2) {
251 const double x2hi = binby[ibin2 + 1];
252 const double x2lo = binby[ibin2];
253 const double x2center = (x2hi+x2lo)/2.;
255 const double binInt =
integrand(
xvec(x1center,x2center))*(x1hi-x1lo)*(x2hi-x2lo) ;
260 const std::vector<double>& binbx =
_binb[0];
261 const std::vector<double>& binby =
_binb[1];
262 const std::vector<double>& binbz =
_binb[2];
264 for (
unsigned int ibin1=0; ibin1 < binbx.size() - 1; ++ibin1) {
265 const double x1hi = binbx[ibin1 + 1];
266 const double x1lo = binbx[ibin1];
267 double x1center = (x1hi+x1lo)/2 ;
269 for (
unsigned int ibin2=0; ibin2 < binby.size() - 1; ++ibin2) {
270 const double x2hi = binby[ibin2 + 1];
271 const double x2lo = binby[ibin2];
272 const double x2center = (x2hi+x2lo)/2.;
274 for (
unsigned int ibin3=0; ibin3 < binbz.size() - 1; ++ibin3) {
275 const double x3hi = binbz[ibin3 + 1];
276 const double x3lo = binbz[ibin3];
277 const double x3center = (x3hi+x3lo)/2.;
279 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
RooAbsIntegrator is the abstract interface for integrators of real-valued functions that implement th...
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.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooBinIntegrator computes the integral over a binned distribution by summing the bin contents of all ...
std::vector< double > _xmax
! Upper integration bound
RooAbsIntegrator * clone(const RooAbsFunc &function, const RooNumIntConfig &config) const override
Clone integrator with new function binding and configuration. Needed by RooNumIntFactory.
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
std::unique_ptr< RooBatchCompute::RunContext > _evalDataOrig
! Run context to save bin centres in between invocations.
std::vector< double > _x
! do not persist
bool _useIntegrandLimits
If true limits of function binding are ued.
RooBinIntegrator()
Default constructor.
bool checkLimits() const override
Check that our integration range is finite and otherwise return false.
std::unique_ptr< RooBatchCompute::RunContext > _evalData
! Run context for evaluating a function.
double integral(const double *yvec=nullptr) override
Calculate numeric integral at given set of function binding parameters.
~RooBinIntegrator() override
Destructor.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
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 storeProtoIntegrator(RooAbsIntegrator *proto, const RooArgSet &defConfig, 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.
Lightweight interface adaptor that binds a RooAbsReal object to a subset of its servers and present i...
RooSpan< const double > getValuesOfBoundFunction(RooBatchCompute::RunContext &evalData) const
Evaluate the bound object at all locations indicated by the data in evalData.
RooRealVar represents a variable that can be changed from the outside.
A simple container to hold a batch of data values.
static uint64_t sum(uint64_t i)