File indexing completed on 2025-01-18 10:10:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROOT7_RHistBinIter
0017 #define ROOT7_RHistBinIter
0018
0019 #include "ROOT/RIndexIter.hxx"
0020
0021 namespace ROOT {
0022 namespace Experimental {
0023 namespace Detail {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 template <class HISTIMPL>
0034 class RHistBinRef {
0035 public:
0036 using HistImpl_t = HISTIMPL;
0037 using CoordArray_t = typename HISTIMPL::CoordArray_t;
0038 using Weight_t = typename HISTIMPL::Weight_t;
0039 using HistBinStat_t = decltype(((HISTIMPL *)0x123)->GetStat().GetView(1));
0040
0041 private:
0042 size_t fIndex{0};
0043 HistImpl_t *fHist{nullptr};
0044 HistBinStat_t fStatView;
0045
0046 public:
0047
0048 RHistBinRef(HistImpl_t &hist, size_t idx): fIndex(idx), fHist(&hist), fStatView(hist.GetStat().GetView(idx)) {}
0049
0050
0051
0052
0053 auto GetContent() { return fStatView.GetContent(); }
0054
0055
0056 double GetUncertainty() const { return fStatView.GetUncertainty(); }
0057
0058
0059
0060 HistBinStat_t GetStat() const { return fStatView; }
0061
0062
0063
0064
0065
0066 CoordArray_t GetCenter() const { return fHist->GetBinCenter(fIndex); }
0067
0068
0069 CoordArray_t GetFrom() const { return fHist->GetBinFrom(fIndex); }
0070
0071
0072 CoordArray_t GetTo() const { return fHist->GetBinTo(fIndex); }
0073
0074 };
0075
0076
0077
0078
0079
0080 template <class HISTIMPL>
0081 class RHistBinPtr {
0082 public:
0083 using Ref_t = RHistBinRef<HISTIMPL>;
0084
0085 const Ref_t &operator->() const noexcept { return fRef; }
0086
0087 private:
0088 Ref_t fRef;
0089 };
0090
0091
0092
0093
0094
0095
0096 template <class HISTIMPL>
0097 class RHistBinIter: public Internal::RIndexIter<RHistBinRef<HISTIMPL>, RHistBinPtr<HISTIMPL>> {
0098 public:
0099 using Ref_t = RHistBinRef<HISTIMPL>;
0100 using Ptr_t = RHistBinPtr<HISTIMPL>;
0101
0102 private:
0103 using IndexIter_t = Internal::RIndexIter<RHistBinRef<HISTIMPL>, RHistBinPtr<HISTIMPL>>;
0104
0105 HISTIMPL &fHist;
0106
0107 public:
0108
0109 RHistBinIter(HISTIMPL &hist): IndexIter_t(0), fHist(hist) {}
0110
0111
0112 RHistBinIter(HISTIMPL &hist, size_t idx): IndexIter_t(idx), fHist(hist) {}
0113
0114
0115
0116 Ref_t operator*() const noexcept { return Ref_t{fHist, IndexIter_t::GetIndex()}; }
0117
0118 Ptr_t operator->() const noexcept { return Ptr_t{*this}; }
0119
0120 };
0121
0122 }
0123 }
0124 }
0125
0126 #endif