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:
The class is templated on the bin content type. For counting, as in the example above, it may be an integral 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 not be an integral type, but 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:
Definition at line 69 of file RHistEngine.hxx.
Public Member Functions | |
| template<typename... Axes> | |
| RHistEngine (const RAxisVariant &axis1, const Axes &...axes) | |
| Construct a histogram engine. | |
| RHistEngine (const RHistEngine &)=delete | |
| The copy constructor is deleted. | |
| RHistEngine (RHistEngine &&)=default | |
| Efficiently move construct a histogram engine. | |
| RHistEngine (std::initializer_list< RAxisVariant > axes) | |
| Construct a histogram engine. | |
| RHistEngine (std::uint64_t nNormalBins, std::pair< double, double > interval) | |
| Construct a one-dimensional histogram engine with a regular axis. | |
| RHistEngine (std::vector< RAxisVariant > axes) | |
| Construct a histogram engine. | |
| ~RHistEngine ()=default | |
| void | Add (const RHistEngine &other) |
| Add all bin contents of another histogram. | |
| void | AddAtomic (const RHistEngine &other) |
| Add all bin contents of another histogram using atomic instructions. | |
| void | Clear () |
| Clear all bin contents. | |
| RHistEngine | Clone () const |
| Clone this histogram engine. | |
| 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, typename W > | |
| void | Fill (const std::tuple< A... > &args, const W &weight) |
| Fill an entry into the histogram with a user-defined weight. | |
| template<typename... A> | |
| void | Fill (const std::tuple< A... > &args, RWeight weight) |
| Fill an entry into the histogram with a weight. | |
| template<typename... A> | |
| void | FillAtomic (const A &...args) |
| Fill an entry into the histogram using atomic instructions. | |
| template<typename... A> | |
| void | FillAtomic (const std::tuple< A... > &args) |
| Fill an entry into the histogram using atomic instructions. | |
| template<typename... A, typename W > | |
| void | FillAtomic (const std::tuple< A... > &args, const W &weight) |
| Fill an entry into the histogram with a user-defined weight using atomic instructions. | |
| template<typename... A> | |
| void | FillAtomic (const std::tuple< A... > &args, RWeight weight) |
| Fill an entry into the histogram with a weight using atomic instructions. | |
| 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. | |
| std::size_t | GetNDimensions () const |
| std::uint64_t | GetTotalNBins () const |
| RHistEngine & | operator= (const RHistEngine &)=delete |
| The copy assignment operator is deleted. | |
| RHistEngine & | operator= (RHistEngine &&)=default |
| Efficiently move a histogram engine. | |
| void | Scale (double factor) |
| Scale all histogram bin contents. | |
| void | Streamer (TBuffer &) |
| ROOT Streamer function to throw when trying to store an object of this class. | |
Static Public Attributes | |
| static constexpr bool | SupportsWeightedFilling = !std::is_integral_v<BinContentType> |
| Whether this histogram engine type supports weighted filling. | |
Private Attributes | |
| Internal::RAxes | fAxes |
| The axis configuration for this histogram. Relevant methods are forwarded from the public interface. | |
| std::vector< BinContentType > | fBinContents |
| The bin contents for this histogram. | |
Friends | |
| template<typename T , std::size_t N> | |
| void | Internal::SetBinContent (RHistEngine< T > &, const std::array< RBinIndex, N > &, const T &) |
#include <ROOT/RHistEngine.hxx>
|
inlineexplicit |
Construct a histogram engine.
| [in] | axes | the axis objects, must have size > 0 |
Definition at line 82 of file RHistEngine.hxx.
|
inlineexplicit |
Construct a histogram engine.
Note that there is no perfect forwarding of the axis objects. If that is needed, use the overload accepting a std::vector.
| [in] | axes | the axis objects, must have size > 0 |
Definition at line 93 of file RHistEngine.hxx.
|
inlineexplicit |
Construct a histogram engine.
Note that there is no perfect forwarding of the axis objects. If that is needed, use the overload accepting a std::vector.
| [in] | axis1 | the first axis object |
| [in] | axes | the remaining axis objects |
Definition at line 103 of file RHistEngine.hxx.
|
inline |
Construct a one-dimensional histogram engine with a regular axis.
| [in] | nNormalBins | the number of normal bins, must be > 0 |
| [in] | interval | the axis interval (lower end inclusive, upper end exclusive) |
Definition at line 115 of file RHistEngine.hxx.
|
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 engine.
After this operation, the moved-from object is invalid.
|
default |
|
inline |
Add all bin contents of another histogram.
Throws an exception if the axes configurations are not identical.
| [in] | other | another histogram |
Definition at line 211 of file RHistEngine.hxx.
|
inline |
Add all bin contents of another histogram using atomic instructions.
Throws an exception if the axes configurations are not identical.
| [in] | other | another histogram that must not be modified during the operation |
Definition at line 226 of file RHistEngine.hxx.
|
inline |
Clear all bin contents.
Definition at line 237 of file RHistEngine.hxx.
|
inline |
Clone this histogram engine.
Copying all bin contents can be an expensive operation, depending on the number of bins.
Definition at line 249 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram.
For weighted filling, pass an RWeight as the last argument:
This is not available for integral bin content types (see 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, or if an argument cannot be converted for the axis type at run-time.
| [in] | args | the arguments for each axis |
std::tuple for unweighted filling and for weighted filling Definition at line 387 of file RHistEngine.hxx.
|
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, or if an argument cannot be converted for the axis type at run-time.
| [in] | args | the arguments for each axis |
Definition at line 280 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram with a user-defined weight.
This overload is only available for user-defined bin content types.
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, or if an argument cannot be converted for the axis type at run-time.
| [in] | args | the arguments for each axis |
| [in] | weight | the weight for this entry |
Definition at line 345 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram with a weight.
This overload is not available for integral bin content types (see 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, or if an argument cannot be converted for the axis type at run-time.
| [in] | args | the arguments for each axis |
| [in] | weight | the weight for this entry |
Definition at line 316 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram using atomic instructions.
| [in] | args | the arguments for each axis |
Definition at line 483 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram using atomic instructions.
| [in] | args | the arguments for each axis |
Definition at line 415 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram with a user-defined weight using atomic instructions.
This overload is only available for user-defined bin content types.
| [in] | args | the arguments for each axis |
| [in] | weight | the weight for this entry |
Definition at line 461 of file RHistEngine.hxx.
|
inline |
Fill an entry into the histogram with a weight using atomic instructions.
This overload is not available for integral bin content types (see SupportsWeightedFilling).
| [in] | args | the arguments for each axis |
| [in] | weight | the weight for this entry |
Definition at line 437 of file RHistEngine.hxx.
|
inline |
Definition at line 142 of file RHistEngine.hxx.
|
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 Definition at line 200 of file RHistEngine.hxx.
|
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 |
Definition at line 165 of file RHistEngine.hxx.
|
inline |
Definition at line 143 of file RHistEngine.hxx.
|
inline |
Definition at line 144 of file RHistEngine.hxx.
|
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 engine.
After this operation, the moved-from object is invalid.
|
inline |
Scale all histogram bin contents.
This method is not available for integral bin content types.
| [in] | factor | the scale factor |
Definition at line 511 of file RHistEngine.hxx.
|
inline |
ROOT Streamer function to throw when trying to store an object of this class.
Definition at line 520 of file RHistEngine.hxx.
|
friend |
|
private |
The axis configuration for this histogram. Relevant methods are forwarded from the public interface.
Definition at line 74 of file RHistEngine.hxx.
|
private |
The bin contents for this histogram.
Definition at line 76 of file RHistEngine.hxx.
|
staticconstexpr |
Whether this histogram engine type supports weighted filling.
Definition at line 259 of file RHistEngine.hxx.