Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RHistFillContext.hxx
Go to the documentation of this file.
1/// \file
2/// \warning This is part of the %ROOT 7 prototype! It will change without notice. It might trigger earthquakes.
3/// Feedback is welcome!
4
5#ifndef ROOT_RHistFillContext
6#define ROOT_RHistFillContext
7
8#include "RHist.hxx"
9#include "RHistEngine.hxx"
10#include "RHistStats.hxx"
11#include "RWeight.hxx"
12
13#include <cstddef>
14#include <tuple>
15
16namespace ROOT {
17namespace Experimental {
18
19// forward declaration for friend declaration
20template <typename BinContentType>
21class RHistConcurrentFiller;
22
23/**
24A context to concurrently fill an RHist.
25
26\sa RHistConcurrentFiller
27
28\warning This is part of the %ROOT 7 prototype! It will change without notice. It might trigger earthquakes.
29Feedback is welcome!
30*/
31template <typename BinContentType>
34
35private:
36 /// A pointer to the filled histogram
38
39 /// Local histogram statistics
41
42 /// \sa RHistConcurrentFiller::CreateFillContent()
43 explicit RHistFillContext(RHist<BinContentType> &hist) : fHist(&hist), fStats(hist.GetNDimensions())
44 {
45 // Propagate disabled dimensions to the local histogram statistics object.
46 const auto &histStats = hist.GetStats();
47 for (std::size_t i = 0; i < histStats.GetNDimensions(); i++) {
48 if (!histStats.IsEnabled(i)) {
50 }
51 }
52 }
57
58public:
60
61 /// Fill an entry into the histogram.
62 ///
63 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
64 /// discarded.
65 ///
66 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
67 /// converted for the axis type at run-time.
68 ///
69 /// \param[in] args the arguments for each axis
70 /// \sa RHist::Fill(const std::tuple<A...> &args)
71 template <typename... A>
72 void Fill(const std::tuple<A...> &args)
73 {
74 fHist->fEngine.FillAtomic(args);
75 fStats.Fill(args);
76 }
77
78 /// Fill an entry into the histogram with a weight.
79 ///
80 /// This overload is not available for integral bin content types (see \ref RHistEngine::SupportsWeightedFilling).
81 ///
82 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
83 /// discarded.
84 ///
85 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
86 /// converted for the axis type at run-time.
87 ///
88 /// \param[in] args the arguments for each axis
89 /// \param[in] weight the weight for this entry
90 /// \sa RHist::Fill(const std::tuple<A...> &args, RWeight weight)
91 template <typename... A>
92 void Fill(const std::tuple<A...> &args, RWeight weight)
93 {
94 fHist->fEngine.FillAtomic(args, weight);
95 fStats.Fill(args, weight);
96 }
97
98 /// Fill an entry into the histogram.
99 ///
100 /// For weighted filling, pass an RWeight as the last argument. This is not available for integral bin content types
101 /// (see \ref RHistEngine::SupportsWeightedFilling).
102 ///
103 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
104 /// discarded.
105 ///
106 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
107 /// converted for the axis type at run-time.
108 ///
109 /// \param[in] args the arguments for each axis
110 /// \sa RHist::Fill(const A &...args)
111 template <typename... A>
112 void Fill(const A &...args)
113 {
114 static_assert(sizeof...(A) >= 1, "need at least one argument to Fill");
115 if constexpr (sizeof...(A) >= 1) {
116 fHist->fEngine.FillAtomic(args...);
117 fStats.Fill(args...);
118 }
119 }
120
121 /// Flush locally accumulated entries to the histogram.
122 void Flush()
123 {
124 fHist->fStats.AddAtomic(fStats);
125 fStats.Clear();
126 }
127};
128
129} // namespace Experimental
130} // namespace ROOT
131
132#endif
A histogram filler to concurrently fill an RHist.
A context to concurrently fill an RHist.
RHistFillContext(RHist< BinContentType > &hist)
RHist< BinContentType > * fHist
A pointer to the filled histogram.
RHistFillContext & operator=(RHistFillContext &&)=default
RHistFillContext(const RHistFillContext &)=delete
void Fill(const std::tuple< A... > &args)
Fill an entry into the histogram.
void Fill(const std::tuple< A... > &args, RWeight weight)
Fill an entry into the histogram with a weight.
RHistStats fStats
Local histogram statistics.
void Flush()
Flush locally accumulated entries to the histogram.
RHistFillContext(RHistFillContext &&)=default
void Fill(const A &...args)
Fill an entry into the histogram.
RHistFillContext & operator=(const RHistFillContext &)=delete
Histogram statistics of unbinned values.
void Clear()
Clear this statistics object.
void Fill(const std::tuple< A... > &args)
Fill an entry into this statistics object.
void DisableDimension(std::size_t dim)
Disable one dimension of this statistics object.
A weight for filling histograms.
Definition RWeight.hxx:17