24template <
typename Hist,
typename T>
25std::unique_ptr<Hist> ConvertToTH2Impl(
const RHistEngine<T> &engine)
28 throw std::invalid_argument(
"TH2 requires two 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];
42 if constexpr (std::is_same_v<T, RBinWithError>) {
43 if (sumw2 ==
nullptr) {
45 sumw2 = ret->GetSumw2()->GetArray();
48 ret->GetArray()[i] =
c.fSum;
52 ret->GetArray()[i] = engine.GetBinContent(index0, index1);
57 for (
auto index0 : axis0.GetFullRange()) {
59 if (index0.IsUnderflow()) {
61 }
else if (index0.IsOverflow()) {
62 i0 = axis0.GetNNormalBins() + 1;
64 assert(index0.IsNormal());
65 i0 = index0.GetIndex() + 1;
67 Int_t n0 = ret->GetXaxis()->GetNbins() + 2;
69 for (
auto index1 : axis1.GetFullRange()) {
70 if (index1.IsUnderflow()) {
71 copyBinContent(i0, index0, index1);
72 }
else if (index1.IsOverflow()) {
73 copyBinContent(i0 + n0 * (axis1.GetNNormalBins() + 1), index0, index1);
75 assert(index1.IsNormal());
76 copyBinContent(i0 + n0 * (index1.GetIndex() + 1), index0, index1);
84template <
typename Hist>
121 return ConvertToTH2Impl<TH2C>(engine);
126 return ConvertToTH2Impl<TH2S>(engine);
131 return ConvertToTH2Impl<TH2I>(engine);
136 return ConvertToTH2Impl<TH2L>(engine);
141 return ConvertToTH2Impl<TH2L>(engine);
146 return ConvertToTH2Impl<TH2F>(engine);
151 return ConvertToTH2Impl<TH2D>(engine);
156 return ConvertToTH2Impl<TH2D>(engine);
162 ConvertGlobalStatistics(*ret, hist.
GetStats());
169 ConvertGlobalStatistics(*ret, hist.
GetStats());
176 ConvertGlobalStatistics(*ret, hist.
GetStats());
183 ConvertGlobalStatistics(*ret, hist.
GetStats());
190 ConvertGlobalStatistics(*ret, hist.
GetStats());
197 ConvertGlobalStatistics(*ret, hist.
GetStats());
204 ConvertGlobalStatistics(*ret, hist.
GetStats());
211 ConvertGlobalStatistics(*ret, hist.
GetStats());
int Int_t
Signed integer 4 bytes (int)
double Double_t
Double 8 bytes.
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< TH2D > ConvertToTH2D(const RHistEngine< double > &engine)
Convert a two-dimensional histogram to TH2D.
std::unique_ptr< TH2F > ConvertToTH2F(const RHistEngine< float > &engine)
Convert a two-dimensional histogram to TH2F.
std::unique_ptr< TH2I > ConvertToTH2I(const RHistEngine< int > &engine)
Convert a two-dimensional histogram to TH2I.
std::unique_ptr< TH2C > ConvertToTH2C(const RHistEngine< char > &engine)
Convert a two-dimensional histogram to TH2C.
std::unique_ptr< TH2L > ConvertToTH2L(const RHistEngine< long > &engine)
Convert a two-dimensional histogram to TH2L.
std::unique_ptr< TH2S > ConvertToTH2S(const RHistEngine< short > &engine)
Convert a two-dimensional histogram to TH2S.
Namespace for ROOT features in testing.