26 #include <initializer_list>
31 template <
int DIMENSIONS,
class PRECISION>
class THist;
34 template <
int DIMENSIONS,
class PRECISION>
36 HistFromImpl(
std::unique_ptr<typename ROOT::THist<DIMENSIONS, PRECISION>::ImplBase_t> pHistImpl);
38 template <int DIMENSIONS, class PRECISION>
39 void swap(ROOT::THist<DIMENSIONS, PRECISION> &a,
40 ROOT::THist<DIMENSIONS, PRECISION> &b) noexcept;
54 template<int DIMENSIONS, class PRECISION>
87 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>>
88 THist(std::array<TAxisConfig, DIMENSIONS> axes,
89 STATISTICS statConfig = STATISTICS());
92 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>>
93 THist(std::array<TAxisConfig, DIMENSIONS> axes,
94 std::string_view histTitle,
95 std::array<std::string_view, DIMENSIONS> axisTitles,
96 STATISTICS statConfig = STATISTICS());
99 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>,
100 class =
typename std::enable_if<DIMENSIONS == 1>>
102 THist({{xaxis}}, statConfig) {}
106 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>,
107 class =
typename std::enable_if<DIMENSIONS == 1>>
109 std::string_view xAxisTitle,
110 STATISTICS statConfig = STATISTICS()):
111 THist({{xaxis}}, histTitle, {{xAxisTitle}}, statConfig) {}
114 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>,
115 class =
typename std::enable_if<DIMENSIONS == 2>>
117 STATISTICS statConfig = STATISTICS()):
118 THist({{xaxis, yaxis}}, statConfig) {}
122 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>,
123 class =
typename std::enable_if<DIMENSIONS == 2>>
125 std::string_view histTitle,
126 std::string_view xAxisTitle, std::string_view yAxisTitle,
127 STATISTICS statConfig = STATISTICS()):
128 THist({{xaxis, yaxis}}, histTitle, {{xAxisTitle, yAxisTitle}}, statConfig) {}
131 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>,
132 class =
typename std::enable_if<DIMENSIONS == 3>>
134 const TAxisConfig& zaxis, STATISTICS statConfig = STATISTICS()):
135 THist({{xaxis, yaxis, zaxis}}, statConfig) {}
138 template<
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>,
139 class =
typename std::enable_if<DIMENSIONS == 3>>
142 std::string_view histTitle,
143 std::string_view xAxisTitle, std::string_view yAxisTitle,
144 std::string_view zAxisTitle,
145 STATISTICS statConfig = STATISTICS()):
146 THist({{xaxis, yaxis, zaxis}}, {{xAxisTitle, yAxisTitle, zAxisTitle}},
151 static constexpr
int GetNDim() noexcept {
return DIMENSIONS; }
166 fImpl->FillN(xN, weightN);
186 friend THist HistFromImpl<>(std::unique_ptr<ImplBase_t>);
195 template <
int DIMENSIONS,
class PRECISION>
207 template <
int DIMENSIONS,
class PRECISION,
class STATISTICS = THistStatUncerta
inty<DIMENSIONS, PRECISION>>
208 TCoopPtr<THist<DIMENSIONS, PRECISION>>
209 MakeCoOwnedHist(std::array<TAxisConfig, DIMENSIONS> axes, STATISTICS statConfig = STATISTICS()) {
216 template <
int DIMENSIONS,
class PRECISION>
217 THist<DIMENSIONS, PRECISION>
220 ret.
fFillFunc = pHistImpl->GetFillFunc();
230 template<
int DIMENSIONS,
int IDIM,
class PRECISION,
class STATISTICS,
231 class... PROCESSEDAXISCONFIG>
235 template<TAxisConfig::EKind KIND>
236 std::unique_ptr<Detail::THistImplBase<DIMENSIONS, PRECISION>>
238 const STATISTICS& statConfig,
239 PROCESSEDAXISCONFIG... processedAxisArgs) {
244 (axes, statConfig, processedAxisArgs..., nextAxis);
259 std::unique_ptr<Detail::THistImplBase<DIMENSIONS, PRECISION>>
261 const STATISTICS& statConfig,
262 PROCESSEDAXISCONFIG... processedAxisArgs) {
263 switch (axes[IDIM].GetKind()) {
265 return MakeNextAxis<TAxisConfig::kEquidistant>(axes, statConfig,
266 processedAxisArgs...);
268 return MakeNextAxis<TAxisConfig::kGrow>(axes, statConfig,
269 processedAxisArgs...);
271 return MakeNextAxis<TAxisConfig::kIrregular>(axes, statConfig,
272 processedAxisArgs...);
281 template<
int DIMENSIONS,
class PRECISION,
class STATISTICS,
282 class... PROCESSEDAXISCONFIG>
286 PROCESSEDAXISCONFIG...> {
287 std::unique_ptr<Detail::THistImplBase<DIMENSIONS, PRECISION>>
288 operator()(
const std::array<TAxisConfig, DIMENSIONS> &,
const STATISTICS& statConfig,
289 PROCESSEDAXISCONFIG... axisArgs) {
292 return std::make_unique<HistImplt_t>(statConfig, axisArgs...);
298 template<
int DIMENSIONS,
class PRECISION>
299 template<
class STATISTICS >
301 STATISTICS statConfig ):
306 fFillFunc = fImpl->GetFillFunc();
334 template <
int DIMENSION,
class PRECISIONA,
class PRECISIONB>
338 ImplTo_t* implTo = to.
GetImpl();
339 ImplFrom_t* implFrom = from.
GetImpl();
341 for (
auto&& bin: from) {
342 to.
Fill(implFrom->GetBinCenter(*bin), implFrom->GetBinContent(*bin));
346 template <
int DIMENSION,
class PRECISION>
347 std::unique_ptr<Internal::TDrawable>
350 return std::make_unique<Internal::THistDrawable<DIMENSION, PRECISION>>(hist, opts);
Generate THist::fImpl from THist constructor arguments.
void FillN(const std::array_view< Coord_t > xN) noexcept
Convenience overload: FillN() with weight 1.
PRECISION Weight_t
Type of the bin content (and thus weights).
std::unique_ptr< Internal::TDrawable > GetDrawable(TCoopPtr< THist< DIMENSION, PRECISION >> hist, THistDrawOptions< DIMENSION > opts={})
void Add(THist< DIMENSION, PRECISIONA > &to, THist< DIMENSION, PRECISIONB > &from)
Small helper to encapsulate whether to return the value pointed to by the iterator or its address...
Objects used to configure the different axis types.
FillFunc_t fFillFunc
Pinter to THistImpl::Fill() member function.
Namespace for new ROOT classes and functions.
void swap(ROOT::THist< DIMENSIONS, PRECISION > &a, ROOT::THist< DIMENSIONS, PRECISION > &b) noexcept
Swap two histograms.
void FillN(const std::array_view< Coord_t > xN, const std::array_view< Weight_t > weightN) noexcept
For each coordinate in xN, add weightN[i] to the bin at coordinate xN[i].
Converts a TAxisConfig of whatever kind to the corresponding TAxisBase-derived object.
class ROOT::THist< DIMENSIONS, PRECISION > HistFromImpl(std::unique_ptr< typename ROOT::THist< DIMENSIONS, PRECISION >::ImplBase_t > pHistImpl)
Adopt an external, stand-alone THistImpl. The THist will take ownership.
TCoopPtr< POINTEE > MakeCoop(ARGS &&...args)
Create an object of type POINTEE on the heap, and build a TCoopPtr for it.
std::unique_ptr< ImplBase_t > fImpl
The actual histogram implementation.
int64_t GetEntries() const noexcept
Get the number of entries this histogram was filled with.
ImplBase_t * GetImpl() const noexcept
Access the ImplBase_t this THist points to.
THist(const TAxisConfig &xaxis, const TAxisConfig &yaxis, std::string_view histTitle, std::string_view xAxisTitle, std::string_view yAxisTitle, STATISTICS statConfig=STATISTICS())
Constructor overload that's only available for DIMENSIONS == 2, also passing histogram and axis title...
std::unique_ptr< Detail::THistImplBase< DIMENSIONS, PRECISION > > operator()(const std::array< TAxisConfig, DIMENSIONS > &, const STATISTICS &statConfig, PROCESSEDAXISCONFIG...axisArgs)
typename THistImplPrecisionAgnosticBase< DIMENSIONS >::Coord_t Coord_t
Type of a coordinate: an array of DIMENSIONS doubles.
THist(const TAxisConfig &xaxis, const TAxisConfig &yaxis, const TAxisConfig &zaxis, STATISTICS statConfig=STATISTICS())
Constructor overload that's only available for DIMENSIONS == 3.
const_iterator begin() const
typename ImplBase_t::Weight_t Weight_t
The type of weights (PRECISION)
THist(const TAxisConfig &xaxis, const TAxisConfig &yaxis, STATISTICS statConfig=STATISTICS())
Constructor overload that's only available for DIMENSIONS == 2.
std::array< std::string, DIMENSIONS > fAxisTitles
Title of each axis.
represents a TAxisEquidistant
void(THistImplBase::*)(const Coord_t &x, Weight_t w) FillFunc_t
Type of the Fill(x, w) function.
std::unique_ptr< Detail::THistImplBase< DIMENSIONS, PRECISION > > operator()(const std::array< TAxisConfig, DIMENSIONS > &axes, const STATISTICS &statConfig, PROCESSEDAXISCONFIG...processedAxisArgs)
Make a THistImpl-derived object reflecting the TAxisConfig array.
THist(const TAxisConfig &xaxis, STATISTICS statConfig=STATISTICS())
Constructor overload that's only available for DIMENSIONS == 1.
THist(const TAxisConfig &xaxis, const TAxisConfig &yaxis, const TAxisConfig &zaxis, std::string_view histTitle, std::string_view xAxisTitle, std::string_view yAxisTitle, std::string_view zAxisTitle, STATISTICS statConfig=STATISTICS())
typename ImplBase_t::Coord_t Coord_t
The coordinates type: a DIMENSIONS-dimensional std::array of double.
std::string fTitle
Title of this histogram.
const_iterator end() const
Drawing options for a histogram with DIMENSIONS.
std::unique_ptr< Detail::THistImplBase< DIMENSIONS, PRECISION > > MakeNextAxis(const std::array< TAxisConfig, DIMENSIONS > &axes, const STATISTICS &statConfig, PROCESSEDAXISCONFIG...processedAxisArgs)
Select the template argument for the next axis type, and "recurse" into HistImplGen_t for the next ax...
typedef void((*Func_t)())
A bin iterator taking a predicate whether it should skip a bin.
THist< 1, int64_t > TH1LL
#define R__ERROR_HERE(GROUP)
typename ImplBase_t::FillFunc_t FillFunc_t
Pointer type to HistImpl_t::Fill, for faster access.
void Fill(const Coord_t &x, Weight_t weight=1.) noexcept
Add weight to the bin containing coordinate x.
represents a TAxisIrregular
TCoopPtr< THist< DIMENSIONS, PRECISION > > MakeCoOwnedHist(std::array< TAxisConfig, DIMENSIONS > axes, STATISTICS statConfig=STATISTICS())
Create a TCoopPtr of a THist.
Interface class for THistImpl.
THist< 3, int64_t > TH3LL
THist< 2, int64_t > TH2LL
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Internal::THistBinIter< Internal::HistIterFullRange_t > const_iterator
Several pointers point to the same object, any of them can delete the object, setting all of them to ...
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
THist(const TAxisConfig &xaxis, std::string_view histTitle, std::string_view xAxisTitle, STATISTICS statConfig=STATISTICS())
Constructor overload that's only available for DIMENSIONS == 1, also passing histogram and axis title...