HIPO  4.3.0
High Performance Output data format for experimental physics
twig::h1d Class Reference

Lightweight 1D histogram. More...

#include <twig.h>

Public Member Functions

 h1d (int n, double min, double max)
 Construct a histogram with uniform binning. More...
 
 h1d (int __id, int n, double min, double max)
 Construct a histogram with an ID and uniform binning. More...
 
void id (int __id)
 Set the histogram ID. More...
 
int id ()
 
void fill (double value)
 Fill the histogram with a value. More...
 
double content (int bin)
 Get the content of a bin. More...
 
void show ()
 Print histogram contents as text columns to stdout. More...
 
void setContent (int bin, double value)
 Set the content of a bin directly. More...
 
void series (std::vector< double > &data)
 Extract bin contents (excluding under/overflow) into a vector. More...
 
void print ()
 Print an ASCII chart of the histogram to stdout. More...
 

Static Public Member Functions

static h1d accumulate (std::vector< h1d > &buffer)
 Sum multiple histograms bin-by-bin. More...
 
static std::vector< h1ddeclare (int count, int bins, double xmin, double xmax)
 Create a vector of identical histograms. More...
 

Protected Attributes

int hid
 
axis x
 
std::vector< double > container
 

Detailed Description

Lightweight 1D histogram.

Provides simple histogramming with fill, content access, and ASCII printing. Serializable to HIPO files and compatible with the TWIG Java visualization library.

Definition at line 89 of file twig.h.

Constructor & Destructor Documentation

◆ h1d() [1/2]

twig::h1d::h1d ( int  n,
double  min,
double  max 
)
inline

Construct a histogram with uniform binning.

Parameters
nNumber of bins
minLower edge
maxUpper edge

Definition at line 101 of file twig.h.

◆ h1d() [2/2]

twig::h1d::h1d ( int  __id,
int  n,
double  min,
double  max 
)
inline

Construct a histogram with an ID and uniform binning.

Parameters
__idHistogram identifier
nNumber of bins
minLower edge
maxUpper edge

Definition at line 110 of file twig.h.

Member Function Documentation

◆ accumulate()

static h1d twig::h1d::accumulate ( std::vector< h1d > &  buffer)
inlinestatic

Sum multiple histograms bin-by-bin.

Parameters
bufferVector of histograms to accumulate
Returns
A new histogram containing the sum

Definition at line 148 of file twig.h.

◆ content()

double twig::h1d::content ( int  bin)
inline

Get the content of a bin.

Parameters
binBin index (0-based, not counting under/overflow)

Definition at line 126 of file twig.h.

◆ declare()

static std::vector<h1d> twig::h1d::declare ( int  count,
int  bins,
double  xmin,
double  xmax 
)
inlinestatic

Create a vector of identical histograms.

Parameters
countNumber of histograms to create
binsNumber of bins per histogram
xminLower edge
xmaxUpper edge

Definition at line 167 of file twig.h.

◆ fill()

void twig::h1d::fill ( double  value)
inline

Fill the histogram with a value.

Parameters
valueThe value to add

Definition at line 119 of file twig.h.

◆ id() [1/2]

int twig::h1d::id ( )
inline
Returns
The histogram ID.

Definition at line 116 of file twig.h.

◆ id() [2/2]

void twig::h1d::id ( int  __id)
inline

Set the histogram ID.

Definition at line 114 of file twig.h.

◆ print()

void twig::h1d::print ( )
inline

Print an ASCII chart of the histogram to stdout.

Definition at line 177 of file twig.h.

◆ series()

void twig::h1d::series ( std::vector< double > &  data)
inline

Extract bin contents (excluding under/overflow) into a vector.

Parameters
dataOutput vector to fill

Definition at line 141 of file twig.h.

◆ setContent()

void twig::h1d::setContent ( int  bin,
double  value 
)
inline

Set the content of a bin directly.

Parameters
binBin index (including under/overflow)
valueNew content value

Definition at line 134 of file twig.h.

◆ show()

void twig::h1d::show ( )
inline

Print histogram contents as text columns to stdout.

Definition at line 128 of file twig.h.

Member Data Documentation

◆ container

std::vector<double> twig::h1d::container
protected

Definition at line 94 of file twig.h.

◆ hid

int twig::h1d::hid
protected

Definition at line 92 of file twig.h.

◆ x

axis twig::h1d::x
protected

Definition at line 93 of file twig.h.


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