18 #include "ROOT/RArrayView.hxx"
25 #include <initializer_list>
28 namespace Experimental {
32 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
37 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
39 HistFromImpl(std::unique_ptr<typename THist<DIMENSIONS, PRECISION, STAT...>::ImplBase_t> pHistImpl);
53 template<int DIMENSIONS, class PRECISION,
54 template <int D_, class P_, template <class P__> class S_> class... STAT>
73 static constexpr
int GetNDim() noexcept {
return DIMENSIONS; }
93 explicit THist(std::array<TAxisConfig, DIMENSIONS> axes);
96 THist(std::string_view histTitle, std::array<TAxisConfig, DIMENSIONS> axes);
99 template <
int ENABLEIF_NDIM = DIMENSIONS,
107 template <
int ENABLEIF_NDIM = DIMENSIONS,
109 THist(std::string_view histTitle,
const TAxisConfig &xaxis):
110 THist(histTitle, std::array<TAxisConfig, 1>{{xaxis}})
114 template<
int ENABLEIF_NDIM = DIMENSIONS,
116 THist(
const TAxisConfig &xaxis,
const TAxisConfig &yaxis):
117 THist(std::array<TAxisConfig, 2>{{xaxis, yaxis}})
122 template<
int ENABLEIF_NDIM = DIMENSIONS,
124 THist(std::string_view histTitle,
const TAxisConfig &xaxis,
const TAxisConfig &yaxis):
125 THist(histTitle, std::array<TAxisConfig, 2>{{xaxis, yaxis}})
129 template<
int ENABLEIF_NDIM = DIMENSIONS,
131 THist(
const TAxisConfig &xaxis,
const TAxisConfig &yaxis,
const TAxisConfig &zaxis):
132 THist(std::array<TAxisConfig, 3>{{xaxis, yaxis, zaxis}})
137 template<
int ENABLEIF_NDIM = DIMENSIONS,
139 THist(std::string_view histTitle,
140 const TAxisConfig &xaxis,
const TAxisConfig &yaxis,
const TAxisConfig &zaxis):
141 THist(histTitle, std::array<TAxisConfig, 3>{{xaxis, yaxis, zaxis}})
146 ImplBase_t *GetImpl() const noexcept {
return fImpl.get(); }
149 std::unique_ptr<ImplBase_t>&& TakeImpl() noexcept {
return std::move(fImpl); }
157 void FillN(
const std::array_view <CoordArray_t> xN,
158 const std::array_view <Weight_t> weightN) noexcept { fImpl->FillN(xN, weightN); }
161 void FillN(
const std::array_view <CoordArray_t> xN) noexcept { fImpl->FillN(xN); }
164 int64_t GetEntries() const noexcept {
return fImpl->GetStat().GetEntries(); }
170 double GetBinUncertainty(
const CoordArray_t &x)
const {
return fImpl->GetBinUncertainty(x); }
179 void swap(THist<DIMENSIONS, PRECISION, STAT...> &other) noexcept {
185 std::unique_ptr<ImplBase_t> fImpl;
188 friend THist HistFromImpl<>(std::unique_ptr<ImplBase_t>);
192 template<
int DIMENSIONS,
class PRECISION>
194 public THist<DIMENSIONS, PRECISION, THistStatContent>
203 template<
int DIMENSIONS,
class PRECISION,
204 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
216 template<
int NDIM,
int IDIM,
class DATA,
class... PROCESSEDAXISCONFIG>
220 template<TAxisConfig::EKind KIND>
221 std::unique_ptr<Detail::THistImplBase<DATA>>
222 MakeNextAxis(std::string_view title,
const std::array<TAxisConfig, NDIM> &axes,
223 PROCESSEDAXISCONFIG... processedAxisArgs)
227 using HistImpl_t =
THistImplGen<NDIM, IDIM + 1, DATA, PROCESSEDAXISCONFIG..., NextAxis_t>;
228 return HistImpl_t()(title, axes, processedAxisArgs..., nextAxis);
243 std::unique_ptr<Detail::THistImplBase<DATA>>
244 operator()(std::string_view title,
const std::array <TAxisConfig, NDIM> &axes,
245 PROCESSEDAXISCONFIG... processedAxisArgs)
247 switch (axes[IDIM].GetKind()) {
249 return MakeNextAxis<TAxisConfig::kEquidistant>(title, axes, processedAxisArgs...);
251 return MakeNextAxis<TAxisConfig::kGrow>(title, axes, processedAxisArgs...);
253 return MakeNextAxis<TAxisConfig::kIrregular>(title, axes, processedAxisArgs...);
262 template<
int NDIM,
class DATA,
class... PROCESSEDAXISCONFIG>
267 std::unique_ptr<HistImplBase_t>
268 operator()(std::string_view title,
const std::array<
TAxisConfig, DATA::GetNDim()> &, PROCESSEDAXISCONFIG... axisArgs)
271 return std::make_unique<HistImplt_t>(title, axisArgs...);
277 template<
int DIMENSIONS,
class PRECISION,
278 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
283 fFillFunc = fImpl->GetFillFunc();
287 template<
int DIMENSIONS,
class PRECISION,
288 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
294 template<
int DIMENSIONS,
class PRECISION,
295 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
300 ret.fFillFunc = pHistImpl->GetFillFunc();
332 template<
int DIMENSIONS,
333 class PRECISION_TO,
class PRECISION_FROM,
334 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT_TO,
335 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT_FROM>
339 auto toImpl = to.GetImpl();
340 auto fillFuncTo = toImpl->GetFillFunc();
341 using HistFrom_t =
THist<DIMENSIONS, PRECISION_FROM, STAT_FROM...>;
343 using FromWeight_t =
typename HistFrom_t::Weight_t;
344 auto add = [fillFuncTo, toImpl](
const FromCoord_t&
x, FromWeight_t c)
346 (toImpl->*fillFuncTo)(x, c);
349 from.GetImpl()->ApplyXC(add);
354 template<
int DIMENSIONS,
class PRECISION,
355 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
356 std::unique_ptr <Internal::TDrawable>
360 return std::make_unique<Internal::THistDrawable<DIMENSIONS>>(hist, opts);
364 template<
int DIMENSIONS,
class PRECISION,
365 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
366 std::unique_ptr <Internal::TDrawable>
370 return std::make_unique<Internal::THistDrawable<DIMENSIONS>>(std::move(hist), opts);
std::vector< PRECISION > THistDataDefaultStorage
std::vector has more template arguments; for the default storage we don't care about them...
std::array< double, DIMENSIONS > CoordArray_t
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
void swap(THist< DIMENSIONS, PRECISION, STAT...> &a, THist< DIMENSIONS, PRECISION, STAT...> &b) noexcept
Swap two histograms.
Interface class for THistImpl.
void swap(TDirectoryEntry &e1, TDirectoryEntry &e2) noexcept
typename ImplBase_t::FillFunc_t FillFunc_t
Pointer type to HistImpl_t::Fill, for faster access.
Generate THist::fImpl from THist constructor arguments.
Iterates over the bins of a THist or THistImpl.
std::unique_ptr< HistImplBase_t > operator()(std::string_view title, const std::array< TAxisConfig, DATA::GetNDim()> &, PROCESSEDAXISCONFIG...axisArgs)
THist(const TAxisConfig &xaxis)
Constructor overload that's only available for a 1-dimensional histogram.
class THist< DIMENSIONS, PRECISION, STAT...> HistFromImpl(std::unique_ptr< typename THist< DIMENSIONS, PRECISION, STAT...>::ImplBase_t > pHistImpl)
Adopt an external, stand-alone THistImpl. The THist will take ownership.
Detail::THistBinIter< ImplBase_t > const_iterator
represents a TAxisEquidistant
PRECISION Weight_t
The type of weights.
std::unique_ptr< Detail::THistImplBase< DATA > > operator()(std::string_view title, const std::array< TAxisConfig, NDIM > &axes, PROCESSEDAXISCONFIG...processedAxisArgs)
Make a THistImpl-derived object reflecting the TAxisConfig array.
Objects used to configure the different axis types.
A THistImplBase's data, provides accessors to all its statistics.
Detail::THistImplBase< Detail::THistData< DIMENSIONS, PRECISION, Detail::THistDataDefaultStorage, STAT...>> ImplBase_t
The type of the Detail::THistImplBase of this histogram.
represents a TAxisIrregular
Hist::CoordArray_t< DATA::GetNDim()> CoordArray_t
Type of the coordinate: a DIMENSIONS-dimensional array of doubles.
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
std::unique_ptr< Internal::TDrawable > GetDrawable(const std::shared_ptr< THist< DIMENSIONS, PRECISION, STAT...>> &hist, THistDrawOptions< DIMENSIONS > opts={})
Interface to graphics taking a unique_ptr<THist>.
void(THistImplBase::*)(const CoordArray_t &x, Weight_t w) FillFunc_t
Type of the Fill(x, w) function.
Hist::AxisIterRange_t< DIMENSIONS > AxisIterRange_t
Range type.
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO...> &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM...> &from)
Add two histograms.
FillFunc_t fFillFunc
The actual histogram implementation.
Converts a TAxisConfig of whatever kind to the corresponding TAxisBase-derived object.
typename ImplBase_t::CoordArray_t CoordArray_t
The coordinates type: a DIMENSIONS-dimensional std::array of double.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
typename ImplBase_t::AxisIterRange_t AxisRange_t
Range.
static void Fill(TTree *tree, int init, int count)
#define R__ERROR_HERE(GROUP)
std::unique_ptr< Detail::THistImplBase< DATA > > MakeNextAxis(std::string_view title, const std::array< TAxisConfig, NDIM > &axes, PROCESSEDAXISCONFIG...processedAxisArgs)
Select the template argument for the next axis type, and "recurse" into THistImplGen for the next axi...