A histogram for aggregation of data along multiple dimensions.
Every call to Fill increments the bin content and is reflected in global statistics:
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
, or the special type RBinWithError. Note that float
has a limited significand precision of 24 bits.
An object can have arbitrary dimensionality determined at run-time. The axis configuration is passed as a vector of RAxisVariant:
Public Member Functions | |
RHist (const RHist< BinContentType > &)=delete | |
The copy constructor is deleted. | |
RHist (RHist< BinContentType > &&)=default | |
Efficiently move construct a histogram. | |
RHist (std::size_t nNormalBins, double low, double high) | |
Construct a one-dimensional histogram engine with a regular axis. | |
RHist (std::vector< RAxisVariant > axes) | |
Construct a histogram. | |
~RHist ()=default | |
void | Add (const RHist< BinContentType > &other) |
Add all bin contents and statistics of another histogram. | |
void | Clear () |
Clear all bin contents and statistics. | |
RHist< BinContentType > | Clone () const |
Clone this histogram. | |
double | ComputeMean (std::size_t dim=0) const |
Compute the arithmetic mean of unbinned values. | |
double | ComputeNEffectiveEntries () const |
Compute the number of effective entries. | |
double | ComputeStdDev (std::size_t dim=0) const |
Compute the standard deviation of unbinned values. | |
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. | |
template<typename... A> | |
void | Fill (const std::tuple< A... > &args, RWeight weight) |
Fill an entry into the histogram with a weight. | |
const std::vector< RAxisVariant > & | GetAxes () const |
template<typename... A> | |
const BinContentType & | GetBinContent (const A &...args) const |
Get the content of a single bin. | |
template<std::size_t N> | |
const BinContentType & | GetBinContent (const std::array< RBinIndex, N > &indices) const |
Get the content of a single bin. | |
const RHistEngine< BinContentType > & | GetEngine () const |
std::size_t | GetNDimensions () const |
std::uint64_t | GetNEntries () const |
const RHistStats & | GetStats () const |
std::size_t | GetTotalNBins () const |
RHist< BinContentType > & | operator= (const RHist< BinContentType > &)=delete |
The copy assignment operator is deleted. | |
RHist< BinContentType > & | operator= (RHist< BinContentType > &&)=default |
Efficiently move a histogram. | |
void | Streamer (TBuffer &) |
ROOT Streamer function to throw when trying to store an object of this class. | |
Private Member Functions | |
RHist (RHistEngine< BinContentType > engine) | |
Private constructor based off an engine. | |
Private Attributes | |
RHistEngine< BinContentType > | fEngine |
The histogram engine including the bin contents. | |
RHistStats | fStats |
The global histogram statistics. | |
#include <ROOT/RHist.hxx>
|
inlineprivate |
|
inlineexplicit |
|
inline |
Construct a one-dimensional histogram engine with a regular axis.
[in] | nNormalBins | the number of normal bins, must be > 0 |
[in] | low | the lower end of the axis interval (inclusive) |
[in] | high | the upper end of the axis interval (exclusive), must be > low |
|
delete |
The copy constructor is deleted.
Copying all bin contents can be an expensive operation, depending on the number of bins. If required, users can explicitly call Clone().
|
default |
Efficiently move construct a histogram.
After this operation, the moved-from object is invalid.
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Compute the standard deviation of unbinned values.
This function computes the uncorrected sample standard deviation:
\[ \sigma = \sqrt{\frac{1}{\sum w_i} \sum(w_i \cdot x_i - \mu)^2} \]
With some rewriting, this is equivalent to:
\[ \sigma = \sqrt{\frac{\sum w_i \cdot x_i^2}{\sum w_i} - \frac{(\sum w_i \cdot x_i)^2}{(\sum w_i)^2}} \]
This function does not include Bessel's correction needed for an unbiased estimator of population variance. In other words, the return value is a biased estimation lower than the actual population standard deviation.
[in] | dim | the dimension index, starting at 0 |
|
inline |
Fill an entry into the histogram.
For weighted filling, pass an RWeight as the last argument:
This is only available for floating-point bin content types (see RHistEngine::SupportsWeightedFilling).
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.
[in] | args | the arguments for each axis |
std::tuple
for unweighted filling and for weighted filling
|
inline |
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.
[in] | args | the arguments for each axis |
|
inline |
Fill an entry into the histogram with a weight.
This overload is only available for floating-point bin content types (see RHistEngine::SupportsWeightedFilling).
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.
[in] | args | the arguments for each axis |
[in] | weight | the weight for this entry |
|
inline |
|
inline |
Get the content of a single bin.
Throws an exception if the number of arguments does not match the axis configuration or the bin is not found.
[in] | args | the arguments for each axis |
std::array
|
inline |
Get the content of a single bin.
Throws an exception if the number of indices does not match the axis configuration or the bin is not found.
[in] | indices | the array of indices for each axis |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
delete |
The copy assignment operator is deleted.
Copying all bin contents can be an expensive operation, depending on the number of bins. If required, users can explicitly call Clone().
|
default |
Efficiently move a histogram.
After this operation, the moved-from object is invalid.
|
inline |
|
private |
|
private |