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()) {}
47
48public:
50
51 /// Fill an entry into the histogram.
52 ///
53 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
54 /// discarded.
55 ///
56 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
57 /// converted for the axis type at run-time.
58 ///
59 /// \param[in] args the arguments for each axis
60 /// \sa RHist::Fill(const std::tuple<A...> &args)
61 template <typename... A>
62 void Fill(const std::tuple<A...> &args)
63 {
64 fHist->fEngine.FillAtomic(args);
65 fStats.Fill(args);
66 }
67
68 /// Fill an entry into the histogram with a weight.
69 ///
70 /// This overload is not available for integral bin content types (see \ref RHistEngine::SupportsWeightedFilling).
71 ///
72 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
73 /// discarded.
74 ///
75 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
76 /// converted for the axis type at run-time.
77 ///
78 /// \param[in] args the arguments for each axis
79 /// \param[in] weight the weight for this entry
80 /// \sa RHist::Fill(const std::tuple<A...> &args, RWeight weight)
81 template <typename... A>
82 void Fill(const std::tuple<A...> &args, RWeight weight)
83 {
84 fHist->fEngine.FillAtomic(args, weight);
85 fStats.Fill(args, weight);
86 }
87
88 /// Fill an entry into the histogram.
89 ///
90 /// For weighted filling, pass an RWeight as the last argument. This is not available for integral bin content types
91 /// (see \ref RHistEngine::SupportsWeightedFilling).
92 ///
93 /// If one of the arguments is outside the corresponding axis and flow bins are disabled, the entry will be silently
94 /// discarded.
95 ///
96 /// Throws an exception if the number of arguments does not match the axis configuration, or if an argument cannot be
97 /// converted for the axis type at run-time.
98 ///
99 /// \param[in] args the arguments for each axis
100 /// \sa RHist::Fill(const A &...args)
101 template <typename... A>
102 void Fill(const A &...args)
103 {
104 fHist->fEngine.FillAtomic(args...);
105 fStats.Fill(args...);
106 }
107
108 /// Flush locally accumulated entries to the histogram.
109 void Flush()
110 {
111 fHist->fStats.AddAtomic(fStats);
112 fStats.Clear();
113 }
114};
115
116} // namespace Experimental
117} // namespace ROOT
118
119#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.
A weight for filling histograms.
Definition RWeight.hxx:17