Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
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 (uint32_t i)
 Accumulate unity weight on bin i. More...
 
void accumulate_closest (double x, double weight=1.0)
 Accumulate weight to closest bin to x. More...
 
void accumulate_closest (const std::vector< double > &xdata)
 Accumulate data xdata with unity weights to bins closest to each data point. More...
 
void accumulate_closest (const std::vector< double > &xdata, const std::vector< double > &wdata)
 Accumulate data xdata with weights wdata to bins closest to each data point. More...
 
void accumulate_linear (double x, double weight=1.0)
 Accumulate weight on bins around x linearly. More...
 
void accumulate_linear (const std::vector< double > &xdata)
 Accumulate data xdata with unity weights linearly to closest bins. More...
 
void accumulate_linear (const std::vector< double > &xdata, const std::vector< double > &wdata)
 Accumulate data xdata with weights wdata linearly to closest bins. 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() [1/3]

Histogram1D::Histogram1D ( uint32_t  n,
const double  range[2] 
)

Constructor for n bin histogram with ranges.

◆ Histogram1D() [2/3]

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() [3/3]

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.

◆ ~Histogram1D()

Histogram1D::~Histogram1D ( )
virtual

Destructor.

Member Function Documentation

◆ accumulate() [1/2]

void Histogram1D::accumulate ( uint32_t  i)
inline

Accumulate unity weight on bin i.

Not a safe function. Input not checked.

◆ accumulate() [2/2]

void Histogram1D::accumulate ( uint32_t  i,
double  weight 
)
inline

Accumulate weight on bin i.

Not a safe function. Input not checked.

◆ accumulate_closest() [1/3]

void Histogram1D::accumulate_closest ( const std::vector< double > &  xdata)

Accumulate data xdata with unity weights to bins closest to each data point.

◆ accumulate_closest() [2/3]

void Histogram1D::accumulate_closest ( const std::vector< double > &  xdata,
const std::vector< double > &  wdata 
)

Accumulate data xdata with weights wdata to bins closest to each data point.

◆ accumulate_closest() [3/3]

void Histogram1D::accumulate_closest ( double  x,
double  weight = 1.0 
)

Accumulate weight to closest bin to x.

◆ accumulate_linear() [1/3]

void Histogram1D::accumulate_linear ( const std::vector< double > &  xdata)

Accumulate data xdata with unity weights linearly to closest bins.

◆ accumulate_linear() [2/3]

void Histogram1D::accumulate_linear ( const std::vector< double > &  xdata,
const std::vector< double > &  wdata 
)

Accumulate data xdata with weights wdata linearly to closest bins.

◆ accumulate_linear() [3/3]

void Histogram1D::accumulate_linear ( double  x,
double  weight = 1.0 
)

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.

◆ convert_to_density()

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.

◆ coord()

double Histogram1D::coord ( uint32_t  i) const

Return the coordinate on bin i.

◆ get_bin_range()

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

Return bin range.

Returns minimum and maximum values on any bin in histogram.

◆ get_data() [1/2]

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

Return a reference to the histogram data.

◆ get_data() [2/2]

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

Return a reference to the histogram data.

◆ get_range()

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

Return data range.

◆ n()

uint32_t Histogram1D::n ( void  ) const
inline

Return the number of bins.

◆ operator()() [1/2]

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

Return a reference to the weight on bin i.

◆ operator()() [2/2]

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

Return a const reference to the weight on bin i.

◆ operator*=()

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

Scale histogram.

◆ step()

double Histogram1D::step ( void  ) const
inline

Return the step size.


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


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.