44 #define HISTOGRAM_HPP 1
80 std::vector<double> _data;
92 Histogram1D( uint32_t n,
const std::vector<double> &xdata,
99 Histogram1D( uint32_t n,
const std::vector<double> &xdata,
const std::vector<double> &wdata,
108 uint32_t
n(
void )
const {
return( _n ); }
112 double step(
void )
const {
return( _step ); }
116 double coord( uint32_t i )
const;
160 std::vector<double> &
get_data(
void ) {
return( _data ); }
164 const std::vector<double> &
get_data(
void )
const {
return( _data ); }
193 std::vector<double> _data;
199 Histogram2D( uint32_t
n, uint32_t
m,
const double range[4] );
206 const std::vector<double> &xdata,
207 const std::vector<double> &ydata,
215 const std::vector<double> &xdata,
216 const std::vector<double> &ydata,
217 const std::vector<double> &wdata,
226 uint32_t
n(
void )
const {
return( _n ); }
230 uint32_t
m(
void )
const {
return( _m ); }
234 double nstep(
void )
const {
return( _nstep ); }
238 double mstep(
void )
const {
return( _mstep ); }
242 double icoord( uint32_t i )
const;
246 double jcoord( uint32_t j )
const;
253 _data[i+j*_n] += weight;
292 std::vector<double> &
get_data(
void ) {
return( _data ); }
298 const std::vector<double> &
get_data(
void )
const {
return( _data ); }
303 return( _data[i+j*_n] );
309 return( _data[i+j*_n] );
const Histogram1D & operator*=(double x)
Scale histogram.
void get_range(double range[2]) const
Return data range.
uint32_t n(void) const
Return the number of bins along the first axis.
Definition: histogram.hpp:226
const double & operator()(uint32_t i, uint32_t j) const
Return a const reference to the weight on bin (i,j).
Definition: histogram.hpp:302
void get_bin_range(double &min, double &max) const
Return bin range.
Histogram1D(uint32_t n, const double range[2])
Constructor for n bin histogram with ranges.
virtual ~Histogram1D()
Destructor.
const std::vector< double > & get_data(void) const
Return a reference to the histogram data.
Definition: histogram.hpp:298
void convert_to_density(void)
Convert histogram to density.
Histogram2D(uint32_t n, uint32_t m, const double range[4])
Constructor for n x m histogram with ranges.
Class for 1D histogram type representation of data.
Definition: histogram.hpp:75
void accumulate_closest(double x, double weight)
Accumulate weight to closest bin to x.
void accumulate_linear(double x, double y, double weight)
Accumulate weight on bins around (x,y) linearly.
double icoord(uint32_t i) const
Return the coordinate along the first axis on bin i.
uint32_t m(void) const
Return the number of bins along the second axis.
Definition: histogram.hpp:230
Linear accumulation around point.
Definition: histogram.hpp:55
double jcoord(uint32_t j) const
Return the coordinate along the second axis on bin j.
double step(void) const
Return the step size.
Definition: histogram.hpp:112
void accumulate_closest(double x, double y, double weight)
Accumulate weight to closest bin to (x,y).
uint32_t n(void) const
Return the number of bins.
Definition: histogram.hpp:108
double coord(uint32_t i) const
Return the coordinate on bin i.
double & operator()(uint32_t i, uint32_t j)
Return a reference to the weight on bin (i,j).
Definition: histogram.hpp:308
std::vector< double > & get_data(void)
Return a reference to the histogram data.
Definition: histogram.hpp:292
double & operator()(uint32_t i)
Return a reference to the weight on bin i.
Definition: histogram.hpp:174
const std::vector< double > & get_data(void) const
Return a reference to the histogram data.
Definition: histogram.hpp:164
double mstep(void) const
Return the step size along along the second axis.
Definition: histogram.hpp:238
void get_range(double range[4]) const
Return data range.
void get_bin_range(double &min, double &max) const
Return bin range.
histogram_accumulation_e
Histogram accumulation type.
Definition: histogram.hpp:53
Class for 2d histogram type representation of data.
Definition: histogram.hpp:186
Base histogram class.
Definition: histogram.hpp:61
virtual ~Histogram2D()
Destructor.
double nstep(void) const
Return the step size along along the first axis.
Definition: histogram.hpp:234
Closest bin to point.
Definition: histogram.hpp:54
const double & operator()(uint32_t i) const
Return a const reference to the weight on bin i.
Definition: histogram.hpp:168
void accumulate_linear(double x, double weight)
Accumulate weight on bins around x linearly.
virtual ~Histogram()
Destructor.
Definition: histogram.hpp:68
const Histogram2D & operator*=(double x)
Scale histogram.
void convert_to_density(void)
Convert histogram to density.
void accumulate(uint32_t i, double weight)
Accumulate weight on bin i.
Definition: histogram.hpp:122
std::vector< double > & get_data(void)
Return a reference to the histogram data.
Definition: histogram.hpp:160
void accumulate(uint32_t i, uint32_t j, double weight)
Accumulate weight on bin (i,j).
Definition: histogram.hpp:252