Public Member Functions | List of all members
Histogram1D Class Reference

Class for 1D histogram type representation of data. More...

#include <histogram.hpp>

Inheritance diagram for Histogram1D:
Histogram

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 Histogram1Doperator*= (double x)
 Scale histogram. More...
 
- Public Member Functions inherited from Histogram
virtual ~Histogram ()
 Destructor. More...
 

Detailed Description

Class for 1D histogram type representation of data.

Constructor & Destructor Documentation

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 Histogram1D::~Histogram1D ( )
virtual

Destructor.

Member Function Documentation

void Histogram1D::accumulate ( uint32_t  i,
double  weight 
)
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.

std::vector<double>& Histogram1D::get_data ( void  )
inline

Return a reference to the histogram data.

const std::vector<double>& Histogram1D::get_data ( void  ) const
inline

Return a reference to the histogram data.

void Histogram1D::get_range ( double  range[2]) const

Return data range.

uint32_t Histogram1D::n ( void  ) const
inline

Return the number of bins.

const double& Histogram1D::operator() ( uint32_t  i) const
inline

Return a const reference to the weight on bin i.

double& Histogram1D::operator() ( uint32_t  i)
inline

Return a reference to the weight on bin i.

const Histogram1D& Histogram1D::operator*= ( double  x)

Scale histogram.

double Histogram1D::step ( void  ) const
inline

Return the step size.


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