Public Member Functions | List of all members
Histogram2D Class Reference

Class for 2d histogram type representation of data. More...

#include <histogram.hpp>

Inheritance diagram for Histogram2D:
Histogram

Public Member Functions

 Histogram2D (uint32_t n, uint32_t m, const double range[4])
 Constructor for n x m histogram with ranges.
 Histogram2D (uint32_t n, uint32_t m, const std::vector< double > &xdata, const std::vector< double > &ydata, histogram_accumulation_e type=HISTOGRAM_ACCUMULATION_CLOSEST)
 Constructor for n x m histogram from scatter xy-data with even weights.
 Histogram2D (uint32_t n, uint32_t m, const std::vector< double > &xdata, const std::vector< double > &ydata, const std::vector< double > &wdata, histogram_accumulation_e type=HISTOGRAM_ACCUMULATION_CLOSEST)
 Constructor for n x m histogram from scatter xy-data with weights from wdata.
virtual ~Histogram2D ()
 Destructor.
uint32_t n (void) const
 Return the number of bins along the first axis.
uint32_t m (void) const
 Return the number of bins along the second axis.
double nstep (void) const
 Return the step size along along the first axis.
double mstep (void) const
 Return the step size along along the second axis.
double icoord (uint32_t i) const
 Return the coordinate along the first axis on bin i.
double jcoord (uint32_t j) const
 Return the coordinate along the second axis on bin j.
void accumulate (uint32_t i, uint32_t j, double weight)
 Accumulate weight on bin (i,j).
void accumulate_closest (double x, double y, double weight)
 Accumulate weight to closest bin to (x,y).
void accumulate_linear (double x, double y, double weight)
 Accumulate weight on bins around (x,y) linearly.
void convert_to_density (void)
 Convert histogram to density.
void get_range (double range[4]) const
 Return data range.
void get_bin_range (double &min, double &max) const
 Return bin range.
std::vector< double > & get_data (void)
 Return a reference to the histogram data.
const std::vector< double > & get_data (void) const
 Return a reference to the histogram data.
const double & operator() (uint32_t i, uint32_t j) const
 Return a const reference to the weight on bin (i,j).
double & operator() (uint32_t i, uint32_t j)
 Return a reference to the weight on bin (i,j).
const Histogram2Doperator*= (double x)
 Scale histogram.
- Public Member Functions inherited from Histogram
virtual ~Histogram ()
 Destructor.

Detailed Description

Class for 2d histogram type representation of data.

Constructor & Destructor Documentation

Histogram2D::Histogram2D ( uint32_t  n,
uint32_t  m,
const double  range[4] 
)

Constructor for n x m histogram with ranges.

Histogram2D::Histogram2D ( uint32_t  n,
uint32_t  m,
const std::vector< double > &  xdata,
const std::vector< double > &  ydata,
histogram_accumulation_e  type = HISTOGRAM_ACCUMULATION_CLOSEST 
)

Constructor for n x m histogram from scatter xy-data with even weights.

Selected accumulation operator type is used. Defaults to closest bin accumulation.

Histogram2D::Histogram2D ( uint32_t  n,
uint32_t  m,
const std::vector< double > &  xdata,
const std::vector< double > &  ydata,
const std::vector< double > &  wdata,
histogram_accumulation_e  type = HISTOGRAM_ACCUMULATION_CLOSEST 
)

Constructor for n x m histogram from scatter xy-data with weights from wdata.

Selected accumulation operator type is used. Defaults to closest bin accumulation.

virtual Histogram2D::~Histogram2D ( )
virtual

Destructor.

Member Function Documentation

void Histogram2D::accumulate ( uint32_t  i,
uint32_t  j,
double  weight 
)
inline

Accumulate weight on bin (i,j).

Not a safe function. Input not checked.

void Histogram2D::accumulate_closest ( double  x,
double  y,
double  weight 
)

Accumulate weight to closest bin to (x,y).

void Histogram2D::accumulate_linear ( double  x,
double  y,
double  weight 
)

Accumulate weight on bins around (x,y) linearly.

Accumulation is done on four neighbouring bins around point (x,y). The distribution of weight is done using inverse bilinear interpolation.

This is a safe function. Accumulation outside histogram range is discarded.

void Histogram2D::convert_to_density ( void  )

Convert histogram to density.

Assuming the histogram has been filled with "counts", this function scales the counts to count density.

void Histogram2D::get_bin_range ( double &  min,
double &  max 
) const

Return bin range.

Returns minimum and maximum values on any bin in histogram.

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

Return a reference to the histogram data.

The data is sored in x major order (data[i+j*n]).

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

Return a reference to the histogram data.

The data is sored in x major order (data[i+j*n]).

void Histogram2D::get_range ( double  range[4]) const

Return data range.

double Histogram2D::icoord ( uint32_t  i) const

Return the coordinate along the first axis on bin i.

double Histogram2D::jcoord ( uint32_t  j) const

Return the coordinate along the second axis on bin j.

uint32_t Histogram2D::m ( void  ) const
inline

Return the number of bins along the second axis.

double Histogram2D::mstep ( void  ) const
inline

Return the step size along along the second axis.

uint32_t Histogram2D::n ( void  ) const
inline

Return the number of bins along the first axis.

double Histogram2D::nstep ( void  ) const
inline

Return the step size along along the first axis.

const double& Histogram2D::operator() ( uint32_t  i,
uint32_t  j 
) const
inline

Return a const reference to the weight on bin (i,j).

double& Histogram2D::operator() ( uint32_t  i,
uint32_t  j 
)
inline

Return a reference to the weight on bin (i,j).

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

Scale histogram.


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