Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Experimental::RHistAutoAxisFiller< BinContentType > Class Template Referencefinal

template<typename BinContentType>
class ROOT::Experimental::RHistAutoAxisFiller< BinContentType >

A histogram filler that automatically determines the axis interval.

This class allows filling a regular one-dimensional histogram without specifying an axis interval during construction. After a configurable number of buffered entries, or upon request, a RRegularAxis is constructed using the minimum and maximum values until that point. This ensures all initial entries are filled into normal bins. Note that this cannot be guaranteed for further calls to Fill.

filler.Fill(1.0);
filler.Fill(1.5);
filler.Fill(2.0);
// The following will implicitly trigger the histogram creation
auto &hist = filler.GetHist();
// hist.GetNEntries() will return 3
A histogram filler that automatically determines the axis interval.
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

Definition at line 50 of file RHistAutoAxisFiller.hxx.

Public Member Functions

 RHistAutoAxisFiller (std::uint64_t nNormalBins, std::size_t maxBufferSize=1024, double marginFraction=0.05)
 Create a filler object.
void Fill (double x)
 Fill an entry into the histogram.
void Fill (double x, RWeight weight)
 Fill an entry into the histogram with a weight.
void Flush ()
 Flush the buffer of entries and construct the histogram.
RHist< BinContentType > & GetHist ()
 Return the constructed histogram.
double GetMarginFraction () const
std::size_t GetMaxBufferSize () const
std::uint64_t GetNNormalBins () const

Static Public Attributes

static constexpr bool SupportsWeightedFilling = RHistEngine<BinContentType>::SupportsWeightedFilling

Private Types

using BufferElement = std::conditional_t<SupportsWeightedFilling, std::pair<double, RWeight>, double>

Private Member Functions

void BufferImpl (double x, RWeight weight)

Private Attributes

std::vector< BufferElementfBuffer
 The buffer of filled entries.
std::optional< RHist< BinContentType > > fHist
 The filled histogram, after it has been constructed.
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.
double fMaximum = -std::numeric_limits<double>::infinity()
 The maximum of the filled entries.
double fMinimum = std::numeric_limits<double>::infinity()
 The minimum of the filled entries.
std::uint64_t fNNormalBins
 The number of normal bins.

#include <ROOT/RHistAutoAxisFiller.hxx>

Member Typedef Documentation

◆ BufferElement

template<typename BinContentType>
using ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::BufferElement = std::conditional_t<SupportsWeightedFilling, std::pair<double, RWeight>, double>
private

Definition at line 65 of file RHistAutoAxisFiller.hxx.

Constructor & Destructor Documentation

◆ RHistAutoAxisFiller()

template<typename BinContentType>
ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::RHistAutoAxisFiller ( std::uint64_t nNormalBins,
std::size_t maxBufferSize = 1024,
double marginFraction = 0.05 )
inlineexplicit

Create a filler object.

Parameters
[in]nNormalBinsthe number of normal bins, must be > 0
[in]maxBufferSizethe maximum buffer size, must be > 0
[in]marginFractionthe fraction of the axis interval to use as margin, must be > 0

Definition at line 80 of file RHistAutoAxisFiller.hxx.

Member Function Documentation

◆ BufferImpl()

template<typename BinContentType>
void ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::BufferImpl ( double x,
RWeight weight )
inlineprivate

Definition at line 100 of file RHistAutoAxisFiller.hxx.

◆ Fill() [1/2]

template<typename BinContentType>
void ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::Fill ( double x)
inline

Fill an entry into the histogram.

Parameters
[in]xthe argument
See also
the overload for weighted filling

Definition at line 124 of file RHistAutoAxisFiller.hxx.

◆ Fill() [2/2]

template<typename BinContentType>
void ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::Fill ( double x,
RWeight weight )
inline

Fill an entry into the histogram with a weight.

This overload is only available for floating-point bin content types (see RHistEngine::SupportsWeightedFilling).

Parameters
[in]xthe argument
[in]weightthe weight for this entry
See also
the overload for unweighted filling

Definition at line 143 of file RHistAutoAxisFiller.hxx.

◆ Flush()

template<typename BinContentType>
void ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::Flush ( )
inline

Flush the buffer of entries and construct the histogram.

Throws an exception if the buffer is empty, the axis interval cannot be determined, or if it would be empty because the minimum equals the maximum.

Definition at line 157 of file RHistAutoAxisFiller.hxx.

◆ GetHist()

template<typename BinContentType>
RHist< BinContentType > & ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::GetHist ( )
inline

Return the constructed histogram.

See also
Flush()

Definition at line 195 of file RHistAutoAxisFiller.hxx.

◆ GetMarginFraction()

template<typename BinContentType>
double ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::GetMarginFraction ( ) const
inline

Definition at line 97 of file RHistAutoAxisFiller.hxx.

◆ GetMaxBufferSize()

template<typename BinContentType>
std::size_t ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::GetMaxBufferSize ( ) const
inline

Definition at line 96 of file RHistAutoAxisFiller.hxx.

◆ GetNNormalBins()

template<typename BinContentType>
std::uint64_t ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::GetNNormalBins ( ) const
inline

Definition at line 95 of file RHistAutoAxisFiller.hxx.

Member Data Documentation

◆ fBuffer

template<typename BinContentType>
std::vector<BufferElement> ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fBuffer
private

The buffer of filled entries.

Definition at line 68 of file RHistAutoAxisFiller.hxx.

◆ fHist

template<typename BinContentType>
std::optional<RHist<BinContentType> > ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fHist
private

The filled histogram, after it has been constructed.

Definition at line 56 of file RHistAutoAxisFiller.hxx.

◆ fMarginFraction

template<typename BinContentType>
double ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fMarginFraction
private

The fraction of the axis interval to use as margin.

Definition at line 63 of file RHistAutoAxisFiller.hxx.

◆ fMaxBufferSize

template<typename BinContentType>
std::size_t ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fMaxBufferSize
private

The maximum buffer size until Flush() is automatically called.

Definition at line 61 of file RHistAutoAxisFiller.hxx.

◆ fMaximum

template<typename BinContentType>
double ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fMaximum = -std::numeric_limits<double>::infinity()
private

The maximum of the filled entries.

Definition at line 72 of file RHistAutoAxisFiller.hxx.

◆ fMinimum

template<typename BinContentType>
double ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fMinimum = std::numeric_limits<double>::infinity()
private

The minimum of the filled entries.

Definition at line 70 of file RHistAutoAxisFiller.hxx.

◆ fNNormalBins

template<typename BinContentType>
std::uint64_t ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::fNNormalBins
private

The number of normal bins.

Definition at line 59 of file RHistAutoAxisFiller.hxx.

◆ SupportsWeightedFilling

template<typename BinContentType>
bool ROOT::Experimental::RHistAutoAxisFiller< BinContentType >::SupportsWeightedFilling = RHistEngine<BinContentType>::SupportsWeightedFilling
staticconstexpr

Definition at line 52 of file RHistAutoAxisFiller.hxx.


The documentation for this class was generated from the following file: