50 oocoutE(
nullptr,InputArguments) <<
"RooGrid: cannot initialize using an invalid function" << std::endl;
59 _d.resize(_dim*maxBins);
60 _xi.resize(_dim*(maxBins+1));
61 _xin.resize(maxBins+1);
62 _weight.resize(maxBins);
74bool RooGrid::initialize(
const RooAbsFunc &function)
81 oocoutE(
nullptr,Integration) <<
"RooGrid: lower limit of dimension " <<
index <<
" is infinite" << std::endl;
86 oocoutE(
nullptr,Integration) <<
"RooGrid: upper limit of dimension " <<
index <<
" is infinite" << std::endl;
91 oocoutE(
nullptr,Integration) <<
"RooGrid: bad range for dimension " <<
index <<
": [" << _xl[
index]
92 <<
"," << _xu[
index] <<
"]" << std::endl;
110void RooGrid::resize(
UInt_t bins)
113 if(bins == _bins)
return;
116 double pts_per_bin = (
double) _bins / (
double) bins;
119 for (
UInt_t j = 0; j < _dim; j++) {
127 for(k = 1; k <= _bins; k++) {
131 while(dw > pts_per_bin) {
133 newCoord(i++)= xnew - (xnew - xold) * dw;
137 for(k = 1 ; k < bins; k++) {
138 coord(k, j) = newCoord(k);
149void RooGrid::resetValues()
151 for(
UInt_t i = 0; i < _bins; i++) {
152 for (
UInt_t j = 0; j < _dim; j++) {
166void RooGrid::generatePoint(
const UInt_t box[],
double x[],
UInt_t bin[],
double &vol,
167 bool useQuasiRandom)
const
180 for(
UInt_t j= 0; j < _dim; ++j) {
184 double z= ((
box[j] +
x[j])/_boxes)*_bins;
194 bin_width= coord(1,j);
198 bin_width= coord(k+1,j) - coord(k,j);
199 y= coord(k,j) + (z-k)*bin_width;
202 x[j] = _xl[j] +
y*_delx[j];
215void RooGrid::firstBox(
UInt_t box[])
const
217 for(
UInt_t i= 0; i < _dim; i++)
box[i]= 0;
233 box[j]= (
box[j] + 1) % _boxes;
234 if (0 !=
box[j])
return true;
246void RooGrid::print(std::ostream& os,
bool verbose, std::string
const&
indent)
const
248 os <<
"RooGrid: volume = " << getVolume() << std::endl;
249 os <<
indent <<
" Has " << getDimension() <<
" dimension(s) each subdivided into "
250 << getNBins() <<
" bin(s) and sampled with " << _boxes <<
" box(es)" << std::endl;
253 << std::setw(10) << _xl[
index] <<
"," << std::setw(10) << _xu[
index] <<
"]" << std::endl;
254 if(!verbose)
continue;
255 for(std::size_t bin= 0; bin < _bins; bin++) {
256 os <<
indent <<
" bin-" << bin <<
" : x = " << coord(bin,
index) <<
" , y = "
267void RooGrid::accumulate(
const UInt_t bin[],
double amount)
269 for(
UInt_t j = 0; j < _dim; j++)
value(bin[j],j) += amount;
279void RooGrid::refine(
double alpha)
281 for (
UInt_t j = 0; j < _dim; j++) {
285 double oldg =
value(0,j);
286 double newg =
value(1,j);
287 value(0,j)= (oldg + newg)/2;
288 double grid_tot_j =
value(0,j);
292 for (i = 1; i < _bins - 1; i++) {
293 double rc = oldg + newg;
296 value(i,j)= (rc + newg)/3;
297 grid_tot_j+=
value(i,j);
299 value(_bins-1,j)= (newg + oldg)/2;
300 grid_tot_j+=
value(_bins-1,j);
304 double tot_weight(0);
305 for (i = 0; i < _bins; i++) {
307 if (
value(i,j) > 0) {
308 oldg = grid_tot_j/
value(i,j);
310 _weight[i] = std::pow(((oldg-1.0)/oldg/
log(oldg)), alpha);
312 tot_weight += _weight[i];
315 double pts_per_bin = tot_weight / _bins;
322 for (
UInt_t k = 0; k < _bins; k++) {
327 while(dw > pts_per_bin) {
329 newCoord(i++) = xnew - (xnew - xold) * dw / _weight[k];
333 for (
UInt_t k = 1 ; k < _bins ; k++) {
334 coord( k, j) = newCoord(k);
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...
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)
RVec< PromoteType< T > > log(const RVec< T > &v)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
void initialize(typename Architecture_t::Matrix_t &A, EInitialization m)