All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces
BinningSpecs.h File Reference

Simple utility for human-friendly binning. More...

#include <initializer_list>
#include <utility>

Go to the source code of this file.

Classes

class  icarus::ns::util::BinningSpecs
 Data structure holding binning information. More...
 

Namespaces

 icarus::ns::util
 

Algorithms for binning.

The BinningSpecs class collects the usual characteristics of a binning: full range boundaries, number of bins, bin width.

A few functions are provided that create a binning with "human-friendly" characteristics for pleasant plots: given a selection of bin width hints, the functions try to create a binning accommodating those hints.

These functions always require the full range of the binning to be specified, and can take either a desired number of bins, or their width.

constexpr
std::initializer_list< double > 
icarus::ns::util::DefaultBinningHints { 1.0, 0.8, 2.0, 0.5, 4.0, 5.0, 10.0, 20.0 }
 Set of bin sizes to be considered by the binning algorithms. More...
 
constexpr double icarus::ns::util::DefaultAllowedBinningStretch { 0.5 }
 Stretch factor on the requested binning range an algorithm is allowed. More...
 
BinningSpecs icarus::ns::util::makeBinningFromBinWidth (double lower, double upper, double width, std::initializer_list< double > hints=DefaultBinningHints, double allowedStretch=DefaultAllowedBinningStretch)
 Returns the "optimal" binning for the requested parameters. More...
 
BinningSpecs icarus::ns::util::makeBinningFromNBins (double lower, double upper, unsigned long nBins, std::initializer_list< double > hints=DefaultBinningHints, double allowedStretch=DefaultAllowedBinningStretch)
 Returns the "optimal" binning for the requested parameters. More...
 
BinningSpecs icarus::ns::util::alignBinningTo (BinningSpecs const &binning, double boundary, bool extendCoverage=true)
 Returns a binning shifted to align with the specified boundary. More...
 
double icarus::ns::util::chooseBinningWidth (double lower, double upper, double width, unsigned long nBins, std::initializer_list< double > hints=DefaultBinningHints, double allowedStretch=DefaultAllowedBinningStretch)
 Returns the "optimal" bin width for the requested parameters. More...
 

Detailed Description

Simple utility for human-friendly binning.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
Date
September 21, 2021

Definition in file BinningSpecs.h.