A histogram for aggregation of data along multiple dimensions.
Every call to Fill increments the bin content and is reflected in global statistics:
A histogram for aggregation of data along multiple dimensions.
void Fill(const std::tuple< A... > &args)
Fill an entry into the histogram.
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:
std::vector<ROOT::Experimental::RAxisVariant> axes;
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 65 of file RHist.hxx.
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.
- Parameters
-
| [in] | dim | the dimension index, starting at 0 |
- Returns
- the standard deviation of unbinned values
Definition at line 162 of file RHist.hxx.
Fill an entry into the histogram.
For weighted filling, pass an RWeight as the last argument:
A weight for filling histograms.
This is not available for integral 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, or if an argument cannot be converted for the axis type at run-time.
- Parameters
-
| [in] | args | the arguments for each axis |
- See also
- the function overloads accepting
std::tuple for unweighted filling and for weighted filling
Definition at line 434 of file RHist.hxx.
Fill an entry into the histogram with a weight.
This overload is not available for integral bin content types (see RHistEngine::SupportsWeightedFilling).
auto args = std::make_tuple(8.5, 10.5);
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.
- Parameters
-
| [in] | args | the arguments for each axis |
| [in] | weight | the weight for this entry |
- See also
- the variadic function template overload accepting arguments directly and the overload for unweighted filling
Definition at line 403 of file RHist.hxx.
Slice this histogram with an RSliceSpec per dimension.
With a range, only the specified bins are retained. All other bin contents are transferred to the underflow and overflow bins:
auto sliced = hist.Slice(hist.GetAxes()[0].GetNormalRange(1, 5));
Slicing can also perform operations per dimension, see RSliceSpec. RSliceSpec::ROperationRebin allows to rebin the histogram axis, grouping a number of normal bins into a new one:
Rebin the dimension, grouping a number of original bins into a new one.
RSliceSpec::ROperationSum sums the bin contents along that axis, which allows to project to a lower-dimensional histogram:
Sum bins along this dimension, effectively resulting in a projection.
Specification of a slice operation along one dimension.
Note that it is not allowed to sum along all histogram axes because the return value would be a scalar.
Ranges and operations can be combined. In that case, the range is applied before the operation.
- Warning
- Combining a range and the sum operation drops bin contents, which will taint the global histogram statistics. Attempting to access its values, for example calling GetNEntries(), will throw exceptions.
- Parameters
-
| [in] | args | the arguments for each axis |
- Returns
- the sliced histogram
- See also
- the function overload accepting
std::vector
Definition at line 557 of file RHist.hxx.
Slice this histogram with an RSliceSpec per dimension.
With a range, only the specified bins are retained. All other bin contents are transferred to the underflow and overflow bins:
auto sliced = hist.Slice({hist.GetAxes()[0].GetNormalRange(1, 5)});
Slicing can also perform operations per dimension, see RSliceSpec. RSliceSpec::ROperationRebin allows to rebin the histogram axis, grouping a number of normal bins into a new one:
RSliceSpec::ROperationSum sums the bin contents along that axis, which allows to project to a lower-dimensional histogram:
Note that it is not allowed to sum along all histogram axes because the return value would be a scalar.
Ranges and operations can be combined. In that case, the range is applied before the operation.
- Warning
- Combining a range and the sum operation drops bin contents, which will taint the global histogram statistics. Attempting to access its values, for example calling GetNEntries(), will throw exceptions.
- Parameters
-
| [in] | sliceSpecs | the slice specifications for each axis |
- Returns
- the sliced histogram
- See also
- the variadic function template overload accepting arguments directly
Definition at line 493 of file RHist.hxx.