23 BinnerFloat( value_type low_, value_type high_,
unsigned int binc )
24 : _low(low_), _high(high_), _binc(binc),
25 _step( (_high-_low)/binc ) {
26 static_assert( std::is_floating_point<V>::value,
"Template argument for BinnerFloat must be floating point type." );
28 throw std::runtime_error(
"Bincount must be larger than one!" );
35 value_type low()
const {
return( _low ); }
36 value_type high()
const {
return( _high ); }
37 unsigned int binCount()
const {
return( _binc ); }
39 int operator()( value_type v )
const {
return( (v-_low)/_step ); }
41 bool isUnderflow( value_type v )
const {
return( v < _low ); }
42 bool isOverflow( value_type v )
const {
return( v >= _high ); }
44 value_type binWidth()
const {
return( _step ); }
45 value_type binLow(
unsigned int i )
const {
return( i * binWidth() ); }
46 value_type binHigh(
unsigned int i )
const {
return( (i+1)*binWidth() ); }
47 double binCenter(
unsigned int i )
const {
return( _low + i*_step + 0.5*_step ); }
65 BinnerInteger( value_type low, value_type high,
unsigned int binc )
66 : _low(low), _high(high), _binc(binc),
67 _step( (high-low)/binc )
69 static_assert( std::is_integral<V>::value,
"Template parameter for BinnerInteger must be integer type." );
70 assert( _step != 0 && _high == _low + binc*_step );
78 value_type low()
const {
return( _low ); }
79 value_type high()
const {
return( _high ); }
80 unsigned int binCount()
const {
return( _binc ); }
82 int operator()( value_type v )
const {
return( (v-_low)/_step ); }
84 bool isUnderflow( value_type v )
const {
return( v < _low ); }
85 bool isOverflow( value_type v )
const {
return( v >= _high ); }
87 value_type binWidth()
const {
return( _step ); }
88 value_type binLow(
unsigned int i )
const {
return( i * binWidth() ); }
89 value_type binHigh(
unsigned int i )
const {
return( (i+1)*binWidth() ); }
90 double binCenter(
unsigned int i )
const {
return( _low + i*_step + 0.5*_step ); }
106 typedef V value_type;
108 BinnerPow2( value_type high_bits, value_type bins_bits )
109 : _high_bits(high_bits),
110 _bins_bits(bins_bits),
111 _div_bits( _high_bits-bins_bits )
113 static_assert( std::is_integral<V>::value && std::is_unsigned<V>::value,
114 "Template parameter for BinnerPow2 must be unsigned integer type." );
115 assert( _high_bits >= 0 && _bins_bits >= 0 );
116 assert( _high_bits >= _bins_bits );
119 assert( _bins_bits < 32 );
127 value_type low()
const {
return( 0 ); }
128 value_type high()
const {
return( V(1) << _high_bits ); }
129 unsigned int binCount()
const {
return( V(1) << _bins_bits ); }
131 int operator()( value_type v )
const noexcept {
return( v >> _div_bits ); }
133 bool isUnderflow( value_type v )
const noexcept {
return( v < 0 ); }
134 bool isOverflow( value_type v )
const noexcept {
return( v >= ( V(1) << _high_bits ) ); }
136 value_type binWidth()
const {
return( V(1) << _div_bits ); }
137 value_type binLow(
unsigned int i )
const {
return( i * binWidth() ); }
138 value_type binHigh(
unsigned int i )
const {
return( (i+1)*binWidth() ); }
139 double binCenter(
unsigned int i )
const {
return( i*binWidth() + 0.5*binWidth() ); }
142 value_type _high_bits;
143 value_type _bins_bits;
144 value_type _div_bits;
Binner with float values.
Definition: binners.hpp:19
Binner with integer values.
Definition: binners.hpp:61
Binner for histograms with integer values and bin counts of powers of two.
Definition: binners.hpp:104
Definition: mainpage.dox:6