47 if(!(
_valid= function.isValid())) {
48 oocoutE(
nullptr,InputArguments) <<
"RooGrid: cannot initialize using an invalid function" << std::endl;
53 _dim= function.getDimension();
79 oocoutE(
nullptr,Integration) <<
"RooGrid: lower limit of dimension " <<
index <<
" is infinite" << std::endl;
84 oocoutE(
nullptr,Integration) <<
"RooGrid: upper limit of dimension " <<
index <<
" is infinite" << std::endl;
89 oocoutE(
nullptr,Integration) <<
"RooGrid: bad range for dimension " <<
index <<
": [" <<
_xl[
index]
90 <<
"," <<
_xu[
index] <<
"]" << std::endl;
111 if(bins ==
_bins)
return;
114 double pts_per_bin = (
double)
_bins / (
double) bins;
118 double xold,xnew(0),dw(0);
123 for(k = 1; k <=
_bins; k++) {
127 while(dw > pts_per_bin) {
129 newCoord(i++)= xnew - (xnew - xold) * dw;
133 for(k = 1 ; k < bins; k++) {
163 bool useQuasiRandom)
const
189 bin_width=
coord(1,j);
194 y=
coord(k,j) + (z-k)*bin_width;
229 if (0 !=
box[j])
return true;
243 os <<
"RooGrid: volume = " <<
getVolume() << std::endl;
245 <<
getNBins() <<
" bin(s) and sampled with " <<
_boxes <<
" box(es)" << std::endl;
248 << std::setw(10) <<
_xl[
index] <<
"," << std::setw(10) <<
_xu[
index] <<
"]" << std::endl;
249 if(!verbose)
continue;
250 for(std::size_t bin= 0; bin <
_bins; bin++) {
251 os <<
indent <<
" bin-" << bin <<
" : x = " <<
coord(bin,
index) <<
" , y = "
280 double oldg =
value(0,j);
281 double newg =
value(1,j);
282 value(0,j)= (oldg + newg)/2;
283 double grid_tot_j =
value(0,j);
287 for (i = 1; i <
_bins - 1; i++) {
288 double rc = oldg + newg;
291 value(i,j)= (rc + newg)/3;
292 grid_tot_j+=
value(i,j);
299 double tot_weight(0);
300 for (i = 0; i <
_bins; i++) {
302 if (
value(i,j) > 0) {
303 oldg = grid_tot_j/
value(i,j);
310 double pts_per_bin = tot_weight /
_bins;
322 while(dw > pts_per_bin) {
static void indent(ostringstream &buf, int indent_level)
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
UInt_t getDimension() const
std::vector< double > _xl
! Internal workspace
bool initialize(const RooAbsFunc &function)
Calculate and store the grid dimensions and volume using the specified function, and initialize the g...
void generatePoint(const UInt_t box[], double x[], UInt_t bin[], double &vol, bool useQuasiRandom=true) const
Generate a random vector in the specified box and store its coordinates in the x[] array provided,...
std::vector< double > _weight
! Internal workspace
std::vector< double > _xu
! Internal workspace
UInt_t _dim
Number of dimensions, bins and boxes.
UInt_t _bins
Number of bins.
bool _valid
Is configuration valid.
void resetValues()
Reset the values associated with each grid cell.
UInt_t _boxes
Numbser of boxes.
std::vector< double > _xi
! Internal workspace
void accumulate(const UInt_t bin[], double amount)
Add the specified amount to bin[j] of the 1D histograms associated with each axis j.
std::vector< double > _d
! Internal workspace
double coord(Int_t i, Int_t j) const
bool nextBox(UInt_t box[]) const
Update the specified array of box indices to refer to the next box in the standard traversal order an...
std::vector< double > _delx
! Internal workspace
void resize(UInt_t bins)
Adjust the subdivision of each axis to give the specified number of bins, using an algorithm that pre...
void refine(double alpha=1.5)
Refine the grid using the values that have been accumulated so far.
void firstBox(UInt_t box[]) const
Reset the specified array of box indices to refer to the first box in the standard traversal order.
std::vector< double > _xin
! Internal workspace
double & newCoord(Int_t i)
void print(std::ostream &os, bool verbose=false, std::string const &indent="") const
Print info about this object to the specified stream.
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
static bool quasi(UInt_t dimension, double vector[], RooQuasiRandomGenerator *generator=quasiGenerator())
Return a quasi-random number in the range (0,1) using the Niederreiter base 2 generator described in ...
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.