Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RHistEngine< BinContentType > Class Template Referencefinal

template<typename BinContentType>
class ROOT::Experimental::RHistEngine< BinContentType >

A histogram data structure to bin data along multiple dimensions.

Every call to Fill bins the data according to the axis configuration and increments the bin content:

hist.Fill(8.5);
// hist.GetBinContent(ROOT::Experimental::RBinIndex(3)) will return 1
A histogram data structure to bin data along multiple dimensions.

The class is templated on the bin content type. For counting, as in the example above, it may be an integer type such as int or long. Narrower types such as unsigned char or short are supported, but may overflow due to their limited range and must be used with care. For weighted filling, the bin content type must be a floating-point type such as float or double. Note that float has a limited significant precision of 24 bits.

An object can have arbitrary dimensionality determined at run-time. The axis configuration is passed as a vector of RAxisVariant:

std::vector<ROOT::Experimental::RAxisVariant> axes;
axes.push_back(ROOT::Experimental::RRegularAxis(10, 5, 15));
axes.push_back(ROOT::Experimental::RVariableBinAxis({1, 10, 100, 1000}));
// hist.GetNDimensions() will return 2
A regular axis with equidistant bins in the interval .
An axis with variable bins defined by their edges.
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

Definition at line 55 of file RHistEngine.hxx.

Public Member Functions

 RHistEngine (const RHistEngine< BinContentType > &)=delete
 
 RHistEngine (RHistEngine< BinContentType > &&)=default
 
 RHistEngine (std::size_t nNormalBins, double low, double high)
 Construct a one-dimensional histogram engine with a regular axis.
 
 RHistEngine (std::vector< RAxisVariant > axes)
 Construct a histogram engine.
 
 ~RHistEngine ()=default
 
template<typename... A>
void Fill (const A &...args)
 Fill an entry into the histogram.
 
template<typename... A>
void Fill (const std::tuple< A... > &args)
 Fill an entry into the histogram.
 
const std::vector< RAxisVariant > & GetAxes () const
 
template<typename... A>
const BinContentTypeGetBinContent (const A &...args) const
 Get the content of a single bin.
 
template<std::size_t N>
const BinContentTypeGetBinContent (const std::array< RBinIndex, N > &indices) const
 Get the content of a single bin.
 
std::size_t GetNDimensions () const
 
std::size_t GetTotalNBins () const
 
RHistEngine< BinContentType > & operator= (const RHistEngine< BinContentType > &)=delete
 
RHistEngine< BinContentType > & operator= (RHistEngine< BinContentType > &&)=default
 
void Streamer (TBuffer &)
 ROOT Streamer function to throw when trying to store an object of this class.
 

Private Attributes

Internal::RAxes fAxes
 The axis configuration for this histogram. Relevant methods are forwarded from the public interface.
 
std::vector< BinContentTypefBinContents
 The bin contents for this histogram.
 

#include <ROOT/RHistEngine.hxx>

Constructor & Destructor Documentation

◆ RHistEngine() [1/4]

ROOT::Experimental::RHistEngine< BinContentType >::RHistEngine ( std::vector< RAxisVariant > axes)
inlineexplicit

Construct a histogram engine.

Parameters
[in]axesthe axis objects, must have size > 0

Definition at line 65 of file RHistEngine.hxx.

◆ RHistEngine() [2/4]

ROOT::Experimental::RHistEngine< BinContentType >::RHistEngine ( std::size_t nNormalBins,
double low,
double high )
inline

Construct a one-dimensional histogram engine with a regular axis.

Parameters
[in]nNormalBinsthe number of normal bins, must be > 0
[in]lowthe lower end of the axis interval (inclusive)
[in]highthe upper end of the axis interval (exclusive), must be > low
See also
the constructor of RRegularAxis

Definition at line 78 of file RHistEngine.hxx.

◆ RHistEngine() [3/4]

◆ RHistEngine() [4/4]

◆ ~RHistEngine()

Member Function Documentation

◆ Fill() [1/2]

template<typename... A>
void ROOT::Experimental::RHistEngine< BinContentType >::Fill ( const A &... args)
inline

Fill an entry into the histogram.

ROOT::Experimental::RHistEngine<int> hist({/* two dimensions */});
hist.Fill(8.5, 10.5);
void Fill(const std::tuple< A... > &args)
Fill an entry into the histogram.

If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently discarded.

Throws an exception if the number of arguments does not match the axis configuration.

Parameters
[in]argsthe arguments for each axis
See also
the function overload accepting std::tuple

Definition at line 200 of file RHistEngine.hxx.

◆ Fill() [2/2]

template<typename... A>
void ROOT::Experimental::RHistEngine< BinContentType >::Fill ( const std::tuple< A... > & args)
inline

Fill an entry into the histogram.

ROOT::Experimental::RHistEngine<int> hist({/* two dimensions */});
auto args = std::make_tuple(8.5, 10.5);
hist.Fill(args);

If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently discarded.

Throws an exception if the number of arguments does not match the axis configuration.

Parameters
[in]argsthe arguments for each axis
See also
the variadic function template overload accepting arguments directly

Definition at line 170 of file RHistEngine.hxx.

◆ GetAxes()

const std::vector< RAxisVariant > & ROOT::Experimental::RHistEngine< BinContentType >::GetAxes ( ) const
inline

Definition at line 89 of file RHistEngine.hxx.

◆ GetBinContent() [1/2]

template<typename... A>
const BinContentType & ROOT::Experimental::RHistEngine< BinContentType >::GetBinContent ( const A &... args) const
inline

Get the content of a single bin.

ROOT::Experimental::RHistEngine<int> hist({/* two dimensions */});
// ... or construct the RBinIndex arguments implicitly from integers:
content = hist.GetBinContent(3, 5);
A bin index with special values for underflow and overflow bins.
Definition RBinIndex.hxx:22
Note
Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special values. See also the class documentation of RBinIndex.

Throws an exception if the number of arguments does not match the axis configuration or the bin is not found.

Parameters
[in]argsthe arguments for each axis
Returns
the bin content
See also
the function overload accepting std::array

Definition at line 147 of file RHistEngine.hxx.

◆ GetBinContent() [2/2]

template<std::size_t N>
const BinContentType & ROOT::Experimental::RHistEngine< BinContentType >::GetBinContent ( const std::array< RBinIndex, N > & indices) const
inline

Get the content of a single bin.

ROOT::Experimental::RHistEngine<int> hist({/* two dimensions */});
std::array<ROOT::Experimental::RBinIndex, 2> indices = {3, 5};
int content = hist.GetBinContent(indices);
Note
Compared to TH1 conventions, the first normal bin has index 0 and underflow and overflow bins are special values. See also the class documentation of RBinIndex.

Throws an exception if the number of indices does not match the axis configuration or the bin is not found.

Parameters
[in]indicesthe array of indices for each axis
Returns
the bin content
See also
the variadic function template overload accepting arguments directly

Definition at line 112 of file RHistEngine.hxx.

◆ GetNDimensions()

std::size_t ROOT::Experimental::RHistEngine< BinContentType >::GetNDimensions ( ) const
inline

Definition at line 90 of file RHistEngine.hxx.

◆ GetTotalNBins()

std::size_t ROOT::Experimental::RHistEngine< BinContentType >::GetTotalNBins ( ) const
inline

Definition at line 91 of file RHistEngine.hxx.

◆ operator=() [1/2]

◆ operator=() [2/2]

◆ Streamer()

ROOT Streamer function to throw when trying to store an object of this class.

Definition at line 206 of file RHistEngine.hxx.

Member Data Documentation

◆ fAxes

The axis configuration for this histogram. Relevant methods are forwarded from the public interface.

Definition at line 57 of file RHistEngine.hxx.

◆ fBinContents

std::vector<BinContentType> ROOT::Experimental::RHistEngine< BinContentType >::fBinContents
private

The bin contents for this histogram.

Definition at line 59 of file RHistEngine.hxx.

  • hist/histv7/inc/ROOT/RHistEngine.hxx