5#ifndef ROOT_RHistAutoAxisFiller
6#define ROOT_RHistAutoAxisFiller
49template <
typename BinContentType>
56 std::optional<RHist<BinContentType>>
fHist;
65 using BufferElement = std::conditional_t<SupportsWeightedFilling, std::pair<double, RWeight>,
double>;
70 double fMinimum = std::numeric_limits<double>::infinity();
72 double fMaximum = -std::numeric_limits<double>::infinity();
81 double marginFraction = 0.05)
84 if (nNormalBins == 0) {
85 throw std::invalid_argument(
"nNormalBins must be > 0");
87 if (maxBufferSize == 0) {
88 throw std::invalid_argument(
"maxBufferSize must be > 0");
90 if (marginFraction <= 0) {
91 throw std::invalid_argument(
"marginFraction must be > 0");
105 assert(weight.
fValue == 1.0);
160 assert(
fBuffer.empty() &&
"buffer should have been emptied");
165 throw std::runtime_error(
"buffer is empty, cannot create histogram");
168 throw std::runtime_error(
"could not determine axis interval");
171 throw std::runtime_error(
"axis interval is empty");
177 const auto high =
fMaximum + margin;
184 fHist->Fill(
x.first,
x.second);
198 assert(
fHist.has_value());
double GetMarginFraction() const
std::size_t GetMaxBufferSize() const
std::vector< BufferElement > fBuffer
The buffer of filled entries.
static constexpr bool SupportsWeightedFilling
void Fill(double x)
Fill an entry into the histogram.
std::uint64_t fNNormalBins
The number of normal bins.
double fMaximum
The maximum of the filled entries.
double fMarginFraction
The fraction of the axis interval to use as margin.
std::size_t fMaxBufferSize
The maximum buffer size until Flush() is automatically called.
std::conditional_t< SupportsWeightedFilling, std::pair< double, RWeight >, double > BufferElement
double fMinimum
The minimum of the filled entries.
std::uint64_t GetNNormalBins() const
RHistAutoAxisFiller(std::uint64_t nNormalBins, std::size_t maxBufferSize=1024, double marginFraction=0.05)
Create a filler object.
RHist< BinContentType > & GetHist()
Return the constructed histogram.
void Fill(double x, RWeight weight)
Fill an entry into the histogram with a weight.
void BufferImpl(double x, RWeight weight)
std::optional< RHist< BinContentType > > fHist
The filled histogram, after it has been constructed.
void Flush()
Flush the buffer of entries and construct the histogram.
static constexpr bool SupportsWeightedFilling
Whether this histogram engine type supports weighted filling.
A histogram for aggregation of data along multiple dimensions.
Namespace for ROOT features in testing.
A weight for filling histograms.