Class for 1D histogram type representation of data. More...
#include <histogram.hpp>
Public Member Functions | |
Histogram1D (uint32_t n, const double range[2]) | |
Constructor for n bin histogram with ranges. More... | |
Histogram1D (uint32_t n, const std::vector< double > &xdata, histogram_accumulation_e type=HISTOGRAM_ACCUMULATION_CLOSEST) | |
Constructor for n bin histogram from scatter data with even weights. More... | |
Histogram1D (uint32_t n, const std::vector< double > &xdata, const std::vector< double > &wdata, histogram_accumulation_e type=HISTOGRAM_ACCUMULATION_CLOSEST) | |
Constructor for n bin histogram from scatter data with weights wrom wdata. More... | |
virtual | ~Histogram1D () |
Destructor. More... | |
uint32_t | n (void) const |
Return the number of bins. More... | |
double | step (void) const |
Return the step size. More... | |
double | coord (uint32_t i) const |
Return the coordinate on bin i. More... | |
void | accumulate (uint32_t i, double weight) |
Accumulate weight on bin i. More... | |
void | accumulate_closest (double x, double weight) |
Accumulate weight to closest bin to x. More... | |
void | accumulate_linear (double x, double weight) |
Accumulate weight on bins around x linearly. More... | |
void | convert_to_density (void) |
Convert histogram to density. More... | |
void | get_range (double range[2]) const |
Return data range. More... | |
void | get_bin_range (double &min, double &max) const |
Return bin range. More... | |
std::vector< double > & | get_data (void) |
Return a reference to the histogram data. More... | |
const std::vector< double > & | get_data (void) const |
Return a reference to the histogram data. More... | |
const double & | operator() (uint32_t i) const |
Return a const reference to the weight on bin i. More... | |
double & | operator() (uint32_t i) |
Return a reference to the weight on bin i. More... | |
const Histogram1D & | operator*= (double x) |
Scale histogram. More... | |
![]() | |
virtual | ~Histogram () |
Destructor. More... | |
Class for 1D histogram type representation of data.
Histogram1D::Histogram1D | ( | uint32_t | n, |
const double | range[2] | ||
) |
Constructor for n bin histogram with ranges.
Histogram1D::Histogram1D | ( | uint32_t | n, |
const std::vector< double > & | xdata, | ||
histogram_accumulation_e | type = HISTOGRAM_ACCUMULATION_CLOSEST |
||
) |
Constructor for n bin histogram from scatter data with even weights.
Selected accumulation operator type is used. Defaults to closest bin accumulation.
Histogram1D::Histogram1D | ( | uint32_t | n, |
const std::vector< double > & | xdata, | ||
const std::vector< double > & | wdata, | ||
histogram_accumulation_e | type = HISTOGRAM_ACCUMULATION_CLOSEST |
||
) |
Constructor for n bin histogram from scatter data with weights wrom wdata.
Selected accumulation operator type is used. Defaults to closest bin accumulation.
|
virtual |
Destructor.
|
inline |
Accumulate weight on bin i.
Not a safe function. Input not checked.
void Histogram1D::accumulate_closest | ( | double | x, |
double | weight | ||
) |
Accumulate weight to closest bin to x.
void Histogram1D::accumulate_linear | ( | double | x, |
double | weight | ||
) |
Accumulate weight on bins around x linearly.
Accumulation is done on two neighbouring bins around point x. The distribution of weight is done using inverse linear interpolation.
This is a safe function. Accumulation outside histogram range is discarded.
void Histogram1D::convert_to_density | ( | void | ) |
Convert histogram to density.
Assuming the histogram has been filled with "counts", this function scales the counts to count density.
double Histogram1D::coord | ( | uint32_t | i | ) | const |
Return the coordinate on bin i.
void Histogram1D::get_bin_range | ( | double & | min, |
double & | max | ||
) | const |
Return bin range.
Returns minimum and maximum values on any bin in histogram.
|
inline |
Return a reference to the histogram data.
|
inline |
Return a reference to the histogram data.
void Histogram1D::get_range | ( | double | range[2] | ) | const |
Return data range.
|
inline |
Return the number of bins.
|
inline |
Return a const reference to the weight on bin i.
|
inline |
Return a reference to the weight on bin i.
const Histogram1D& Histogram1D::operator*= | ( | double | x | ) |
Scale histogram.
|
inline |
Return the step size.