5#ifndef ROOT_RHistAutoAxisFiller
6#define ROOT_RHistAutoAxisFiller
22namespace Experimental {
46template <
typename BinContentType>
53 std::optional<RHist<BinContentType>>
fHist;
62 using BufferElement = std::conditional_t<SupportsWeightedFilling, std::pair<double, RWeight>,
double>;
67 double fMinimum = std::numeric_limits<double>::infinity();
69 double fMaximum = -std::numeric_limits<double>::infinity();
81 throw std::invalid_argument(
"nNormalBins must be > 0");
84 throw std::invalid_argument(
"maxBufferSize must be > 0");
87 throw std::invalid_argument(
"marginFraction must be > 0");
156 assert(
fBuffer.empty() &&
"buffer should have been emptied");
161 throw std::runtime_error(
"buffer is empty, cannot create histogram");
164 throw std::runtime_error(
"could not determine axis interval");
167 throw std::runtime_error(
"axis interval is empty");
173 const auto high =
fMaximum + margin;
180 fHist->Fill(
x.first,
x.second);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
A histogram filler that automatically determines the axis interval.
double GetMarginFraction() const
RHistAutoAxisFiller(std::size_t nNormalBins, std::size_t maxBufferSize=1024, double marginFraction=0.05)
Create a filler object.
std::size_t GetMaxBufferSize() const
std::vector< BufferElement > fBuffer
The buffer of filled entries.
std::size_t fNNormalBins
The number of normal bins.
static constexpr bool SupportsWeightedFilling
void Fill(double x)
Fill an entry into the histogram.
std::size_t GetNNormalBins() const
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.
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.
A histogram data structure to bin data along multiple dimensions.
A weight for filling histograms.