All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
icarus::ns::util::BinningSpecs Class Reference

Data structure holding binning information. More...

#include <BinningSpecs.h>

Public Member Functions

 BinningSpecs (double lower, double upper, double width)
 Constructor: all fields specified, no adjustment performed. More...
 
Access to binning specifications
double lower () const
 Returns the value of the lower end of the first bin. More...
 
double upper () const
 Returns the value of the upper end of the last bin. More...
 
double range () const
 Returns the full range covered by the binning. More...
 
unsigned long nBins () const
 Returns the number of bins. More...
 
double binWidth () const
 Returns the width of the bins (all bins have the same width). More...
 
Access to bins
int binWith (double value) const
 
std::pair< double, double > binBorders (int iBin) const
 Returns the lower and upper borders of the bin with the specified index. More...
 

Static Public Member Functions

static unsigned long NBinsFor (double lower, double upper, double width)
 Returns a number of bins large enough to cover the specified range. More...
 

Private Attributes

double fLower { 0.0 }
 Lower range limit. More...
 
double fWidth { 0.0 }
 Width of all bins. More...
 
unsigned long fNBins { 0UL }
 Number of bins. More...
 
double fUpper { 0.0 }
 Upper range limit. More...
 

Detailed Description

Data structure holding binning information.

The binning is at fixed bin size.

Nothing fancy so far.

Functions like icarus::ns::util::makeBinningFromBinWidth() and icarus::ns::util::makeBinningFromNBins() are the recommended way to create a BinningSpecs object.

Definition at line 170 of file BinningSpecs.h.

Constructor & Destructor Documentation

icarus::ns::util::BinningSpecs::BinningSpecs ( double  lower,
double  upper,
double  width 
)

Constructor: all fields specified, no adjustment performed.

Definition at line 44 of file BinningSpecs.cxx.

45  : fLower{ lower }
46  , fWidth{ width }
48  , fUpper{ fLower + fNBins * fWidth }
49 {
50  assert(lower <= upper);
51  assert(width >= 0.0);
52  assert(fLower <= lower);
53  assert(fUpper >= upper);
54 }
unsigned long fNBins
Number of bins.
Definition: BinningSpecs.h:174
double lower() const
Returns the value of the lower end of the first bin.
Definition: BinningSpecs.h:187
double fUpper
Upper range limit.
Definition: BinningSpecs.h:175
double fLower
Lower range limit.
Definition: BinningSpecs.h:172
double fWidth
Width of all bins.
Definition: BinningSpecs.h:173
double upper() const
Returns the value of the upper end of the last bin.
Definition: BinningSpecs.h:190
static unsigned long NBinsFor(double lower, double upper, double width)
Returns a number of bins large enough to cover the specified range.

Member Function Documentation

std::pair< double, double > icarus::ns::util::BinningSpecs::binBorders ( int  iBin) const

Returns the lower and upper borders of the bin with the specified index.

Definition at line 64 of file BinningSpecs.cxx.

65 {
66  double const low = lower() + binWidth() * iBin;
67  return { low, low + binWidth() };
68 } // icarus::ns::util::BinningSpecs::binBorders()
double lower() const
Returns the value of the lower end of the first bin.
Definition: BinningSpecs.h:187
standard_dbscan3dalg useful for diagnostics hits not in a line will not be clustered on on only for track like only for track like on on the smaller the less shower like tracks low
double binWidth() const
Returns the width of the bins (all bins have the same width).
Definition: BinningSpecs.h:199
double icarus::ns::util::BinningSpecs::binWidth ( ) const
inline

Returns the width of the bins (all bins have the same width).

Definition at line 199 of file BinningSpecs.h.

199 { return fWidth; }
double fWidth
Width of all bins.
Definition: BinningSpecs.h:173
int icarus::ns::util::BinningSpecs::binWith ( double  value) const

Returns the index of the bin with the specified value (bin of lower() is 0, bin of upper() is nBins()).

Definition at line 58 of file BinningSpecs.cxx.

59  { return static_cast<int>(std::floor((value - lower()) / binWidth())); }
double lower() const
Returns the value of the lower end of the first bin.
Definition: BinningSpecs.h:187
double binWidth() const
Returns the width of the bins (all bins have the same width).
Definition: BinningSpecs.h:199
temporary value
double icarus::ns::util::BinningSpecs::lower ( ) const
inline

Returns the value of the lower end of the first bin.

Definition at line 187 of file BinningSpecs.h.

187 { return fLower; }
double fLower
Lower range limit.
Definition: BinningSpecs.h:172
unsigned long icarus::ns::util::BinningSpecs::nBins ( ) const
inline

Returns the number of bins.

Definition at line 196 of file BinningSpecs.h.

196 { return fNBins; }
unsigned long fNBins
Number of bins.
Definition: BinningSpecs.h:174
unsigned long icarus::ns::util::BinningSpecs::NBinsFor ( double  lower,
double  upper,
double  width 
)
static

Returns a number of bins large enough to cover the specified range.

Definition at line 73 of file BinningSpecs.cxx.

74  { return static_cast<unsigned long>(std::ceil((upper - lower) / width)); }
double lower() const
Returns the value of the lower end of the first bin.
Definition: BinningSpecs.h:187
double upper() const
Returns the value of the upper end of the last bin.
Definition: BinningSpecs.h:190
double icarus::ns::util::BinningSpecs::range ( ) const
inline

Returns the full range covered by the binning.

Definition at line 193 of file BinningSpecs.h.

193 { return upper() - lower(); }
double lower() const
Returns the value of the lower end of the first bin.
Definition: BinningSpecs.h:187
double upper() const
Returns the value of the upper end of the last bin.
Definition: BinningSpecs.h:190
double icarus::ns::util::BinningSpecs::upper ( ) const
inline

Returns the value of the upper end of the last bin.

Definition at line 190 of file BinningSpecs.h.

190 { return fUpper; }
double fUpper
Upper range limit.
Definition: BinningSpecs.h:175

Member Data Documentation

double icarus::ns::util::BinningSpecs::fLower { 0.0 }
private

Lower range limit.

Definition at line 172 of file BinningSpecs.h.

unsigned long icarus::ns::util::BinningSpecs::fNBins { 0UL }
private

Number of bins.

Definition at line 174 of file BinningSpecs.h.

double icarus::ns::util::BinningSpecs::fUpper { 0.0 }
private

Upper range limit.

Definition at line 175 of file BinningSpecs.h.

double icarus::ns::util::BinningSpecs::fWidth { 0.0 }
private

Width of all bins.

Definition at line 173 of file BinningSpecs.h.


The documentation for this class was generated from the following files: