Logo ROOT  
Reference Guide
RHistBinIter.hxx
Go to the documentation of this file.
1/// \file ROOT/RHistBinIter.h
2/// \ingroup Hist ROOT7
3/// \author Axel Naumann <axel@cern.ch>
4/// \date 2015-08-07
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RHistBinIter
17#define ROOT7_RHistBinIter
18
19#include "ROOT/RIndexIter.hxx"
20
21namespace ROOT {
22namespace Experimental {
23namespace Detail {
24
25/**
26\class RHistBinRef
27Represents a bin reference. Value of the bin iteration.
28
29Provides access to bin content, bin geometry (from, to, center), and statistics
30(for instance higher moments) associated to the bin.
31*/
32
33template <class HISTIMPL>
35public:
36 using HistImpl_t = HISTIMPL;
38 using Weight_t = typename HISTIMPL::Weight_t;
39 using HistBinStat_t = decltype(((HISTIMPL *)0x123)->GetStat().GetView(1));
40
41private:
42 size_t fIndex{0}; ///< Bin index
43 HistImpl_t *fHist{nullptr}; ///< The bin's histogram.
45
46public:
47 /// Construct from a histogram.
48 RHistBinRef(HistImpl_t &hist, size_t idx): fIndex(idx), fHist(&hist), fStatView(hist.GetStat().GetView(idx)) {}
49
50 /// \{
51 /// \name Statistics operations
52 /// Get the bin content (or reference to it, for non-const HistImpl_t).
53 auto GetContent() { return fStatView.GetContent(); }
54
55 /// Get the bin uncertainty.
56 double GetUncertainty() const { return fStatView.GetUncertainty(); }
57
58 /// Get a (const, for const HistImpl_t) reference to the bin-view of the
59 /// histogram statistics (uncertainty etc).
60 HistBinStat_t GetStat() const { return fStatView; }
61 /// \}
62
63 /// \{
64 /// \name Bin operations
65 /// Get the bin center as an array over all dimensions.
66 CoordArray_t GetCenter() const { return fHist->GetBinCenter(fIndex); }
67
68 /// Get the bin lower edge as an array over all dimensions.
69 CoordArray_t GetFrom() const { return fHist->GetBinFrom(fIndex); }
70
71 /// Get the bin upper edge as an array over all dimensions.
72 CoordArray_t GetTo() const { return fHist->GetBinTo(fIndex); }
73 /// \}
74};
75
76/**
77 \class RHistBinPtr
78 Points to a histogram bin (or actually a `RHistBinRef`).
79 */
80template <class HISTIMPL>
82public:
84
85 const Ref_t &operator->() const noexcept { return fRef; }
86
87private:
88 Ref_t fRef; ///< Underlying bin reference
89};
90
91/**
92 \class RHistBinIter
93 Iterates over the bins of a RHist or RHistImpl.
94 */
95
96template <class HISTIMPL>
97class RHistBinIter: public Internal::RIndexIter<RHistBinRef<HISTIMPL>, RHistBinPtr<HISTIMPL>> {
98public:
101
102private:
104
105 HISTIMPL &fHist; ///< The histogram we iterate over.
106
107public:
108 /// Construct a RHistBinIter from a histogram.
109 RHistBinIter(HISTIMPL &hist): IndexIter_t(0), fHist(hist) {}
110
111 /// Construct a RHistBinIter from a histogram, setting the current index.
112 RHistBinIter(HISTIMPL &hist, size_t idx): IndexIter_t(idx), fHist(hist) {}
113
114 ///\{
115 ///\name Value access
116 Ref_t operator*() const noexcept { return Ref_t{fHist, IndexIter_t::GetIndex()}; }
117
118 Ptr_t operator->() const noexcept { return Ptr_t{*this}; }
119 ///\}
120};
121
122} // namespace Detail
123} // namespace Experimental
124} // namespace ROOT
125
126#endif
Iterates over the bins of a RHist or RHistImpl.
RHistBinIter(HISTIMPL &hist, size_t idx)
Construct a RHistBinIter from a histogram, setting the current index.
HISTIMPL & fHist
The histogram we iterate over.
RHistBinIter(HISTIMPL &hist)
Construct a RHistBinIter from a histogram.
Points to a histogram bin (or actually a RHistBinRef).
const Ref_t & operator->() const noexcept
Ref_t fRef
Underlying bin reference.
Represents a bin reference.
HistImpl_t * fHist
The bin's histogram.
CoordArray_t GetFrom() const
Get the bin lower edge as an array over all dimensions.
typename HISTIMPL::CoordArray_t CoordArray_t
RHistBinRef(HistImpl_t &hist, size_t idx)
Construct from a histogram.
CoordArray_t GetTo() const
Get the bin upper edge as an array over all dimensions.
HistBinStat_t GetStat() const
Get a (const, for const HistImpl_t) reference to the bin-view of the histogram statistics (uncertaint...
decltype(((HISTIMPL *) 0x123) ->GetStat().GetView(1)) HistBinStat_t
typename HISTIMPL::Weight_t Weight_t
double GetUncertainty() const
Get the bin uncertainty.
Iterates over an index; the REFERENCE is defined by the REFERENCE template parameter.
Definition: RIndexIter.hxx:35
RCoordArray< DIMENSIONS > CoordArray_t
Definition: RHistUtils.hxx:53
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21