26#include <initializer_list>
29namespace Experimental {
32template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
36template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
37class RHist<DIMENSIONS,
PRECISION, STAT...>
38HistFromImpl(
std::unique_ptr<typename RHist<DIMENSIONS, PRECISION, STAT...>::ImplBase_t> pHistImpl);
52template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
70 static constexpr int GetNDim() noexcept {
return DIMENSIONS; }
92 explicit RHist(std::array<RAxisConfig, DIMENSIONS> axes);
137 std::unique_ptr<ImplBase_t> &&
TakeImpl() noexcept {
return std::move(
fImpl); }
145 void FillN(
const std::span<CoordArray_t> xN,
const std::span<Weight_t> weightN)
noexcept
147 fImpl->FillN(xN, weightN);
151 void FillN(
const std::span<CoordArray_t> xN)
noexcept {
fImpl->FillN(xN); }
179 friend RHist HistFromImpl<>(std::unique_ptr<ImplBase_t>);
183template <
int DIMENSIONS,
class PRECISION>
191template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
201template <
int NDIM,
int IDIM,
class DATA,
class... PROCESSEDAXISCONFIG>
205 template <RAxisConfig::EKind KIND>
206 std::unique_ptr<Detail::RHistImplBase<DATA>>
208 PROCESSEDAXISCONFIG... processedAxisArgs)
212 using HistImpl_t =
RHistImplGen<NDIM, IDIM + 1, DATA, PROCESSEDAXISCONFIG..., NextAxis_t>;
213 return HistImpl_t()(title, axes, processedAxisArgs..., nextAxis);
229 const std::array<RAxisConfig, NDIM> &axes,
230 PROCESSEDAXISCONFIG... processedAxisArgs)
232 switch (axes[IDIM].GetKind()) {
234 case RAxisConfig::kGrow:
return MakeNextAxis<RAxisConfig::kGrow>(title, axes, processedAxisArgs...);
243template <
int NDIM,
class DATA,
class... PROCESSEDAXISCONFIG>
248 std::unique_ptr<HistImplBase_t>
252 return std::make_unique<HistImplt_t>(title, axisArgs...);
257template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
260 Internal::RHistImplGen<
RHist::GetNDim(), 0,
267template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
272template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
277 ret.fFillFunc = pHistImpl->GetFillFunc();
307template <
int DIMENSIONS,
class PRECISION_TO,
class PRECISION_FROM,
308 template <
int D_,
class P_>
class... STAT_TO,
309 template <
int D_,
class P_>
class... STAT_FROM>
314 using HistFrom_t =
RHist<DIMENSIONS, PRECISION_FROM, STAT_FROM...>;
316 using FromWeight_t =
typename HistFrom_t::Weight_t;
317 auto add = [fillFuncTo, toImpl](
const FromCoord_t &
x, FromWeight_t
c) {
318 (toImpl->*fillFuncTo)(
x,
c);
325template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
326std::shared_ptr<RHistDrawable<DIMENSIONS>>
330 return std::make_unique<RHistDrawable<DIMENSIONS>>(hist, opts);
334template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_>
class... STAT>
335std::shared_ptr<RHistDrawable<DIMENSIONS>>
339 return std::make_unique<RHistDrawable<DIMENSIONS>>(std::move(hist), opts);
#define R__ERROR_HERE(GROUP)
Iterates over the bins of a RHist or RHistImpl.
Interface class for RHistImpl.
virtual void ApplyXC(std::function< void(const CoordArray_t &, Weight_t)>) const =0
Apply a function (lambda) to all bins of the histogram.
void(RHistImplBase::*)(const CoordArray_t &x, Weight_t w) FillFunc_t
Type of the Fill(x, w) function.
Hist::CoordArray_t< DATA::GetNDim()> CoordArray_t
Type of the coordinate: a DIMENSIONS-dimensional array of doubles.
virtual FillFunc_t GetFillFunc() const =0
Retrieve the pointer to the overridden Fill(x, w) function.
Hist::AxisIterRange_t< DIMENSIONS > AxisIterRange_t
Range type.
Objects used to configure the different axis types.
@ kGrow
represents a RAxisGrow
@ kEquidistant
represents a RAxisEquidistant
@ kIrregular
represents a RAxisIrregular
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
ImplBase_t * GetImpl() const noexcept
Access the ImplBase_t this RHist points to.
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
PRECISION Weight_t
The type of weights.
Weight_t GetBinContent(const CoordArray_t &x) const
Get the content of the bin at x.
int64_t GetEntries() const noexcept
Get the number of entries this histogram was filled with.
double GetBinUncertainty(const CoordArray_t &x) const
Get the uncertainty on the content of the bin at x.
RHist(std::string_view histTitle, const RAxisConfig &xaxis, const RAxisConfig &yaxis)
Constructor overload that's only available for a 2-dimensional histogram, also passing the histogram ...
const_iterator end() const
RHist(const RAxisConfig &xaxis, const RAxisConfig &yaxis)
Constructor overload that's only available for a 2-dimensional histogram.
typename ImplBase_t::FillFunc_t FillFunc_t
Pointer type to HistImpl_t::Fill, for faster access.
RHist(const RAxisConfig &xaxis, const RAxisConfig &yaxis, const RAxisConfig &zaxis)
Constructor overload that's only available for a 3-dimensional histogram.
typename ImplBase_t::AxisIterRange_t AxisRange_t
Range.
void Fill(const CoordArray_t &x, Weight_t weight=(Weight_t) 1) noexcept
Add weight to the bin containing coordinate x.
RHist(std::string_view histTitle, std::array< RAxisConfig, DIMENSIONS > axes)
Constructor overload taking the histogram title.
Detail::RHistBinIter< ImplBase_t > const_iterator
void FillN(const std::span< CoordArray_t > xN) noexcept
Convenience overload: FillN() with weight 1.
std::unique_ptr< ImplBase_t > && TakeImpl() noexcept
"Steal" the ImplBase_t this RHist points to.
const_iterator begin() const
RHist(std::string_view histTitle, const RAxisConfig &xaxis, const RAxisConfig &yaxis, const RAxisConfig &zaxis)
Constructor overload that's only available for a 3-dimensional histogram, also passing the histogram ...
void FillN(const std::span< CoordArray_t > xN, const std::span< Weight_t > weightN) noexcept
For each coordinate in xN, add weightN[i] to the bin at coordinate xN[i].
void swap(RHist< DIMENSIONS, PRECISION, STAT... > &other) noexcept
Swap *this and other.
std::unique_ptr< ImplBase_t > fImpl
The actual histogram implementation.
RHist(const RHist &other)
RHist(const RAxisConfig &xaxis)
Constructor overload that's only available for a 1-dimensional histogram.
RHist(std::array< RAxisConfig, DIMENSIONS > axes)
Create a histogram from an array of axes (RAxisConfigs).
FillFunc_t fFillFunc
! Pinter to RHistImpl::Fill() member function
typename ImplBase_t::CoordArray_t CoordArray_t
The coordinates type: a DIMENSIONS-dimensional std::array of double.
RHist(std::string_view histTitle, const RAxisConfig &xaxis)
Constructor overload that's only available for a 1-dimensional histogram, also passing the histogram ...
RCoordArray< DIMENSIONS > CoordArray_t
class RHist< DIMENSIONS, PRECISION, STAT... > HistFromImpl(std::unique_ptr< typename RHist< DIMENSIONS, PRECISION, STAT... >::ImplBase_t > pHistImpl)
Adopt an external, stand-alone RHistImpl. The RHist will take ownership.
void Add(RHist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const RHist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
void swap(RHist< DIMENSIONS, PRECISION, STAT... > &a, RHist< DIMENSIONS, PRECISION, STAT... > &b) noexcept
Swap two histograms.
std::shared_ptr< RPadDrawable > GetDrawable(std::unique_ptr< RPad > &&pad, ARGS... args)
Namespace for new ROOT classes and functions.
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
basic_string_view< char > string_view
Converts a RAxisConfig of whatever kind to the corresponding RAxisBase-derived object.
std::unique_ptr< HistImplBase_t > operator()(std::string_view title, const std::array< RAxisConfig, DATA::GetNDim()> &, PROCESSEDAXISCONFIG... axisArgs)
Generate RHist::fImpl from RHist constructor arguments.
std::unique_ptr< Detail::RHistImplBase< DATA > > MakeNextAxis(std::string_view title, const std::array< RAxisConfig, NDIM > &axes, PROCESSEDAXISCONFIG... processedAxisArgs)
Select the template argument for the next axis type, and "recurse" into RHistImplGen for the next axi...
std::unique_ptr< Detail::RHistImplBase< DATA > > operator()(std::string_view title, const std::array< RAxisConfig, NDIM > &axes, PROCESSEDAXISCONFIG... processedAxisArgs)
Make a RHistImpl-derived object reflecting the RAxisConfig array.