77 setRange(boundaries[0], boundaries[nbins]);
86 _ownBoundLo(other._ownBoundLo), _ownBoundHi(other._ownBoundHi),
87 _nbins(other._nbins), _boundaries(other._boundaries),
105 std::vector<double>::iterator it =
134 std::vector<double>::iterator it = std::lower_bound(
_boundaries.begin(),
160 for (
Int_t i = 0; i <= nbins; ++i)
161 addBoundary((
double(nbins - i) /
double(nbins)) * xlo +
162 (
double(i) /
double(nbins)) * xhi);
167inline int rawBinNumberImpl(
double x, std::vector<double>
const& boundaries) {
168 auto it = std::lower_bound(boundaries.begin(), boundaries.end(),
x);
170 while (boundaries.begin() != it &&
171 (boundaries.end() == it || boundaries.end() == it + 1 ||
x < *it)) --it;
172 return it - boundaries.begin();
184 for(std::size_t i = 0; i <
n; ++i) {
196 return (std::abs(xl -
x) < std::abs(xh -
x)) ? xl : xh;
219 coutE(InputArguments) <<
"RooBinning::setRange: ERROR low bound > high bound" << endl;
243 std::vector<double>::const_iterator it = std::lower_bound(
256 if (0 > bin || bin >=
_nbins) {
257 coutE(InputArguments) <<
"RooBinning::binEdges ERROR: bin number must be in range (0," <<
_nbins <<
")" << endl;
270 if (
binEdges(bin, xlo, xhi))
return 0;
271 return 0.5 * (xlo + xhi);
280 if (
binEdges(bin, xlo, xhi))
return 0;
290 if (
binEdges(bin, xlo, xhi))
return 0;
300 if (
binEdges(bin, xlo, xhi))
return 0;
336 for(
auto * el : static_range_cast<RooDouble*>(tmp)) {
343 throw std::string(
"Unknown class version!");
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
int binNumber(double x) const
Returns the bin number corresponding to the value x.
void Streamer(TBuffer &) override
Custom streamer implementing schema evolution between V1 and V2 persistent binnings.
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
double binLow(Int_t bin) const override
Return the lower bound of the requested bin.
double * array() const override
Return array of boundary values.
void updateBinCount()
Update the internal bin counter.
TClass * IsA() const override
Int_t _blo
! bin number for _xlo
std::vector< double > _boundaries
Boundaries.
Int_t numBoundaries() const override
Return the number boundaries.
~RooBinning() override
Destructor.
bool addBoundary(double boundary)
Add bin boundary at given value.
void binNumbers(double const *x, int *bins, std::size_t n, int coef) const override
Return sequential bin number that contains value x where bin zero is the first bin with an upper boun...
RooBinning(double xlo=-RooNumber::infinity(), double xhi=RooNumber::infinity(), const char *name=nullptr)
Constructor for an initially empty binning defining the range [xlo,xhi].
void addUniform(Int_t nBins, double xlo, double xhi)
Add array of nbins uniformly sized bins in range [xlo,xhi].
double binCenter(Int_t bin) const override
Return the position of the center of bin 'bin'.
double binHigh(Int_t bin) const override
Return the upper bound of the requested bin.
void Streamer(TBuffer &) override
Custom streamer that provides backward compatibility to read v1 data.
bool _ownBoundHi
Does the upper bound coincide with a bin boundary.
double * _array
! Array of boundaries
double binWidth(Int_t bin) const override
Return the width of the requested bin.
Int_t _nbins
Number of bins.
void addBoundaryPair(double boundary, double mirrorPoint=0)
Add pair of boundaries: one at 'boundary' and one at 2*mirrorPoint-boundary.
bool _ownBoundLo
Does the lower bound coincide with a bin boundary.
bool removeBoundary(double boundary)
Remove boundary at given value.
virtual double nearestBoundary(double x) const
Return the value of the nearest boundary to x.
bool binEdges(Int_t bin, double &xlo, double &xhi) const
Return upper and lower bound of bin 'bin'.
void setRange(double xlo, double xhi) override
Change the defined range associated with this binning.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
void Streamer(TBuffer &) override
Stream all objects in the collection to or from the I/O buffer.