|
| Binner (Data_t lower, Data_t upper, Step_t step) |
| Constructor: covers the range from lower to upper or above. More...
|
|
|
Returns the lower limit of the range.
|
Data_t | lower () const |
|
Data_t | upper () const |
| Returns the upper limit of the range. More...
|
|
Step_t | step () const |
| Returns the step size. More...
|
|
unsigned int | nBins () const |
| Returns the number of bins in the range. More...
|
|
|
Type of supported queries:
- whether a value is within the range:
contains()
- bin "index" for a value:
- fractional value (
relative() ): a value in the middle of the bin will have a index with fractional part 0.5 ;
- integral value, with different treatment for overflows:
bin() (also operator() ): no range check at all, index can be any integral value
cappedBin() : if the bin index is smaller, or larger, than the specified minimum and maximum bin numbers, the returned value is clamped to those minimum and maximum bin numbers;
cappedBin() : the bin index is between 0 and nBins() - 1 , where bin 0 also includes all values smaller than lower() and bin nBins() - 1 includes all values larger or equal to upper()
cappedBinWithOverflows() : the bin index is between -1 and nBins() , where bin -1 includes all values smaller than lower() and bin nBins() includes all values larger or equal to upper()
|
double | relative (Data_t value) const |
| Returns value relative to the range (lower = 0, upper = 1). More...
|
|
|
int | bin (Data_t value) const |
| Returns bin number for value (unbound). More...
|
|
int | operator() (Data_t value) const |
|
|
int | cappedBin (Data_t value, int min, int max) const |
| Returns a bin number for value clamped between min and max included. More...
|
|
|
int | cappedBin (Data_t value) const |
| Returns a valid bin index, capping if value is out of range. More...
|
|
|
int | cappedBinWithOverflows (Data_t value) const |
| Returns a valid bin index or -1 for underflow or nBins() for overflow. More...
|
|
|
bool | contains (Data_t value) const |
| Returns if value is in the range. More...
|
|
Data_t | lowerEdge (int iBin) const |
| Returns the lower edge of the bin with the specified index iBin . More...
|
|
Data_t | upperEdge (int iBin) const |
| Returns the upper edge of the bin with the specified index iBin . More...
|
|
Data_t | binCenter (int iBin) const |
| Returns the center of the bin with the specified index iBin . More...
|
|
template<typename T>
class util::Binner< T >
Helper class binning values in a range.
- Template Parameters
-
T | type of data on the axis |
This object provides binning and indexing of a range of values from lower()
to upper()
. The range is divided in nBins()
bins all of the same size step()
.
The type of the values is T
; the type of step()
may be T
or something else, automatically detected.
Example of usage:
std::cout <<
"Binning: " << bins << std::endl;
std::cout <<
"\nBin indices (no range constraint):";
for (
float const value: { -1.5f, -1.0f, -0.5f, 0.0f, +0.5f, +1.0f, +1.5f })
std::cout <<
"\nBin relative indices (no range constraint):";
for (
float const value: { -1.5f, -1.0f, -0.5f, 0.0f, +0.5f, +1.0f, +1.5f })
for (
float const value: { -1.5f, -1.0f, -0.5f, 0.0f, +0.5f, +1.0f, +1.5f }) {
Note that the upper bound of each bin does not belong to that bin, but rather to the next one (and, differently from ROOT, this also holds for the last bin, i.e. the upper()
value).
Definition at line 24 of file Binner.h.