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