26 #include <initializer_list>
29 namespace Experimental {
32 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
36 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
38 HistFromImpl(std::unique_ptr<typename THist<DIMENSIONS, PRECISION, STAT...>::ImplBase_t> pHistImpl);
52 template <int DIMENSIONS, class PRECISION, template <int D_, class P_, template <class P__> class S_> class... STAT>
70 static constexpr
int GetNDim() noexcept {
return DIMENSIONS; }
90 explicit THist(std::array<TAxisConfig, DIMENSIONS> axes);
93 THist(std::string_view histTitle, std::array<TAxisConfig, DIMENSIONS> axes);
96 template <int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 1>::type>
102 template <int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 1>::type>
103 THist(std::string_view histTitle,
const TAxisConfig &xaxis): THist(histTitle, std::array<TAxisConfig, 1>{{xaxis}})
107 template <int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 2>::type>
108 THist(
const TAxisConfig &xaxis,
const TAxisConfig &yaxis): THist(std::array<TAxisConfig, 2>{{xaxis, yaxis}})
113 template <int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 2>::type>
114 THist(std::string_view histTitle,
const TAxisConfig &xaxis,
const TAxisConfig &yaxis)
115 : THist(histTitle, std::array<TAxisConfig, 2>{{xaxis, yaxis}})
119 template <int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 3>::type>
120 THist(
const TAxisConfig &xaxis,
const TAxisConfig &yaxis,
const TAxisConfig &zaxis)
121 : THist(std::array<TAxisConfig, 3>{{xaxis, yaxis, zaxis}})
126 template <int ENABLEIF_NDIM = DIMENSIONS, class = typename std::enable_if<ENABLEIF_NDIM == 3>::type>
127 THist(std::string_view histTitle,
const TAxisConfig &xaxis,
const TAxisConfig &yaxis,
const TAxisConfig &zaxis)
128 : THist(histTitle, std::array<TAxisConfig, 3>{{xaxis, yaxis, zaxis}})
132 ImplBase_t *GetImpl() const noexcept {
return fImpl.get(); }
135 std::unique_ptr<ImplBase_t> &&TakeImpl() noexcept {
return std::move(fImpl); }
143 void FillN(
const std::array_view<CoordArray_t> xN,
const std::array_view<Weight_t> weightN) noexcept
145 fImpl->FillN(xN, weightN);
149 void FillN(
const std::array_view<CoordArray_t> xN) noexcept { fImpl->FillN(xN); }
152 int64_t GetEntries() const noexcept {
return fImpl->GetStat().GetEntries(); }
158 double GetBinUncertainty(
const CoordArray_t &x)
const {
return fImpl->GetBinUncertainty(x); }
167 void swap(THist<DIMENSIONS, PRECISION, STAT...> &other) noexcept
174 std::unique_ptr<ImplBase_t> fImpl;
177 friend THist HistFromImpl<>(std::unique_ptr<ImplBase_t>);
181 template <
int DIMENSIONS,
class PRECISION>
189 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
199 template <
int NDIM,
int IDIM,
class DATA,
class... PROCESSEDAXISCONFIG>
203 template <TAxisConfig::EKind KIND>
204 std::unique_ptr<Detail::THistImplBase<DATA>>
205 MakeNextAxis(std::string_view title,
const std::array<TAxisConfig, NDIM> &axes,
206 PROCESSEDAXISCONFIG... processedAxisArgs)
210 using HistImpl_t =
THistImplGen<NDIM, IDIM + 1, DATA, PROCESSEDAXISCONFIG..., NextAxis_t>;
211 return HistImpl_t()(title, axes, processedAxisArgs..., nextAxis);
226 std::unique_ptr<Detail::THistImplBase<DATA>>
operator()(std::string_view title,
227 const std::array<TAxisConfig, NDIM> &axes,
228 PROCESSEDAXISCONFIG... processedAxisArgs)
230 switch (axes[IDIM].GetKind()) {
232 case TAxisConfig::kGrow:
return MakeNextAxis<TAxisConfig::kGrow>(title, axes, processedAxisArgs...);
241 template <
int NDIM,
class DATA,
class... PROCESSEDAXISCONFIG>
246 std::unique_ptr<HistImplBase_t>
247 operator()(std::string_view title,
const std::array<
TAxisConfig, DATA::GetNDim()> &, PROCESSEDAXISCONFIG... axisArgs)
250 return std::make_unique<HistImplt_t>(title, axisArgs...);
255 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
262 fFillFunc = fImpl->GetFillFunc();
265 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
270 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
275 ret.fFillFunc = pHistImpl->GetFillFunc();
305 template <
int DIMENSIONS,
class PRECISION_TO,
class PRECISION_FROM,
306 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT_TO,
307 template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT_FROM>
310 auto toImpl = to.GetImpl();
311 auto fillFuncTo = toImpl->GetFillFunc();
312 using HistFrom_t =
THist<DIMENSIONS, PRECISION_FROM, STAT_FROM...>;
314 using FromWeight_t =
typename HistFrom_t::Weight_t;
315 auto add = [fillFuncTo, toImpl](
const FromCoord_t &
x, FromWeight_t c) {
316 (toImpl->*fillFuncTo)(x, c);
319 from.GetImpl()->ApplyXC(add);
323 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
324 std::unique_ptr<THistDrawable<DIMENSIONS>>
327 return std::make_unique<THistDrawable<DIMENSIONS>>(hist, pad);
331 template <
int DIMENSIONS,
class PRECISION,
template <
int D_,
class P_,
template <
class P__>
class S_>
class... STAT>
332 std::unique_ptr<THistDrawable<DIMENSIONS>>
335 return std::make_unique<THistDrawable<DIMENSIONS>>(std::move(hist), pad);
std::vector< PRECISION > THistDataDefaultStorage
std::vector has more template arguments; for the default storage we don't care about them...
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
Base class for graphic containers for TDrawable-s.
PRECISION Weight_t
The type of weights.
TCoordArray< DIMENSIONS > CoordArray_t
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.
void(THistImplBase::*)(const CoordArray_t &x, Weight_t w) FillFunc_t
Type of the Fill(x, w) function.
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 ...
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
std::unique_ptr< TPadDrawable > GetDrawable(std::unique_ptr< TPad > &&pad, TPadBase &parent)
typename ImplBase_t::AxisIterRange_t AxisRange_t
Range.
#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...