24template <
typename Hist,
typename T>
25std::unique_ptr<Hist> ConvertToTH3Impl(
const RHistEngine<T> &engine)
28 throw std::invalid_argument(
"TH3 requires three dimensions");
31 auto ret = std::make_unique<Hist>();
32 ret->SetDirectory(
nullptr);
34 const auto &axis0 = engine.
GetAxes()[0];
36 const auto &axis1 = engine.
GetAxes()[1];
38 const auto &axis2 = engine.
GetAxes()[2];
44 if constexpr (std::is_same_v<T, RBinWithError>) {
45 if (sumw2 ==
nullptr) {
47 sumw2 = ret->GetSumw2()->GetArray();
49 const RBinWithError &
c = engine.GetBinContent(index0, index1, index2);
50 ret->GetArray()[i] =
c.fSum;
54 ret->GetArray()[i] = engine.GetBinContent(index0, index1, index2);
59 for (
auto index0 : axis0.GetFullRange()) {
61 if (index0.IsUnderflow()) {
63 }
else if (index0.IsOverflow()) {
64 i0 = axis0.GetNNormalBins() + 1;
66 assert(index0.IsNormal());
67 i0 = index0.GetIndex() + 1;
69 Int_t n0 = ret->GetXaxis()->GetNbins() + 2;
71 for (
auto index1 : axis1.GetFullRange()) {
73 if (index1.IsUnderflow()) {
75 }
else if (index1.IsOverflow()) {
76 i1 = axis1.GetNNormalBins() + 1;
78 assert(index1.IsNormal());
79 i1 = index1.GetIndex() + 1;
81 Int_t n1 = ret->GetYaxis()->GetNbins() + 2;
83 for (
auto index2 : axis2.GetFullRange()) {
85 if (index2.IsUnderflow()) {
87 }
else if (index2.IsOverflow()) {
88 i2 = axis2.GetNNormalBins() + 1;
90 assert(index2.IsNormal());
91 i2 = index2.GetIndex() + 1;
94 Int_t i = i0 + n0 * (i1 + n1 * i2);
95 copyBinContent(i, index0, index1, index2);
103template <
typename Hist>
104void ConvertGlobalStatistics(Hist &
h,
const RHistStats &stats)
145namespace Experimental {
150 return ConvertToTH3Impl<TH3C>(engine);
155 return ConvertToTH3Impl<TH3S>(engine);
160 return ConvertToTH3Impl<TH3I>(engine);
165 return ConvertToTH3Impl<TH3L>(engine);
170 return ConvertToTH3Impl<TH3L>(engine);
175 return ConvertToTH3Impl<TH3F>(engine);
180 return ConvertToTH3Impl<TH3D>(engine);
185 return ConvertToTH3Impl<TH3D>(engine);
191 ConvertGlobalStatistics(*ret, hist.
GetStats());
198 ConvertGlobalStatistics(*ret, hist.
GetStats());
205 ConvertGlobalStatistics(*ret, hist.
GetStats());
212 ConvertGlobalStatistics(*ret, hist.
GetStats());
219 ConvertGlobalStatistics(*ret, hist.
GetStats());
226 ConvertGlobalStatistics(*ret, hist.
GetStats());
233 ConvertGlobalStatistics(*ret, hist.
GetStats());
240 ConvertGlobalStatistics(*ret, hist.
GetStats());
A bin index with special values for underflow and overflow bins.
A histogram data structure to bin data along multiple dimensions.
const std::vector< RAxisVariant > & GetAxes() const
std::size_t GetNDimensions() const
Histogram statistics of unbinned values.
const RDimensionStats & GetDimensionStats(std::size_t dim=0) const
Get the statistics object for one dimension.
std::uint64_t GetNEntries() const
bool IsEnabled(std::size_t dim) const
A histogram for aggregation of data along multiple dimensions.
const RHistStats & GetStats() const
const RHistEngine< BinContentType > & GetEngine() const
void ConvertAxis(TAxis &dst, const RAxisVariant &src)
Convert a single axis object to TAxis.
std::unique_ptr< TH3S > ConvertToTH3S(const RHistEngine< short > &engine)
Convert a three-dimensional histogram to TH3S.
std::unique_ptr< TH3C > ConvertToTH3C(const RHistEngine< char > &engine)
Convert a three-dimensional histogram to TH3C.
std::unique_ptr< TH3F > ConvertToTH3F(const RHistEngine< float > &engine)
Convert a three-dimensional histogram to TH3F.
std::unique_ptr< TH3I > ConvertToTH3I(const RHistEngine< int > &engine)
Convert a three-dimensional histogram to TH3I.
std::unique_ptr< TH3L > ConvertToTH3L(const RHistEngine< long > &engine)
Convert a three-dimensional histogram to TH3L.
std::unique_ptr< TH3D > ConvertToTH3D(const RHistEngine< double > &engine)
Convert a three-dimensional histogram to TH3D.
Namespace for ROOT features in testing.