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