Pottu
RateHistogrammer.hpp
Go to the documentation of this file.
1 
6 #ifndef H_RATEHISTOGRAMMER
7 #define H_RATEHISTOGRAMMER
8 
9 
11 
12 #include "DetectorEvent.hpp"
13 #include "ContextBase.hpp"
14 #include "StageDetectorEvent.hpp"
15 
16 
17 namespace pottu {
18 
26  template <class Selector>
28  public:
29 
44  RateHistogrammer( _result_tree_type results, Selector selector,
45  const std::string &name,
46  uint64_t divider=60*100000000ULL, uint64_t low=0, uint64_t high=30ULL*24ULL*60ULL,
47  uint64_t binCount=30UL*24UL*60ULL )
48  : _ctxh( ContextBase::getActive().createHandle( fmt::format("RateHistogrammer_{}", name ) ) ),
49  _selector(selector),
50  _divider(divider)
51  {
52  _h = createHistogram1D( results, name.c_str(), low, high, binCount );
53  }
54 
67  RateHistogrammer( _result_tree_type results, Selector selector,
68  const std::string &name,
69  uint64_t divider=60*100000000ULL, uint64_t low=0,
70  uint64_t binCount=30UL*24UL*60ULL )
71  : _ctxh( ContextBase::getActive().createHandle( fmt::format("RateHistogrammer_{}", name ) ) ),
72  _selector(selector),
73  _divider(divider)
74  {
75  _h = createHistogram1D( results, name.c_str(), low, low+binCount, binCount );
76  }
77 
78 
84  virtual void process( std::vector<DetectorEvent> &data ) noexcept {
85  auto proci = _ctxh->processInstance();
86 
87  for( auto &event : data ) {
88  if( _selector(event) ) {
89  fill( _h, event.time / _divider );
90  }
91  }
92  }
93 
97  const Selector &getSelector() const noexcept { return _selector; }
98 
104  Selector &getSelector() noexcept { return _selector; }
105 
106  private:
107  ContextHandle *_ctxh;
108 
109  Selector _selector;
110  uint64_t _divider;
111  _histogram_1d_type *_h;
112 
113 
114  };
115 
116 
117 
118 }
119 
120 
121 #endif
122 
Handle to context used by specific class.
Definition: ContextBase.hpp:188
Simple 1D histogram.
Definition: Histogram1D.hpp:26
Class holding tree of histograms and subtrees.
Definition: ObjectTree.hpp:44
Rate histogramming stage.
Definition: RateHistogrammer.hpp:27
virtual void process(std::vector< DetectorEvent > &data) noexcept
Fills rate histograms with filtered detector events.
Definition: RateHistogrammer.hpp:84
Selector & getSelector() noexcept
Returns the constant selector instance.
Definition: RateHistogrammer.hpp:104
const Selector & getSelector() const noexcept
Returns the constant selector instance.
Definition: RateHistogrammer.hpp:97
RateHistogrammer(_result_tree_type results, Selector selector, const std::string &name, uint64_t divider=60 *100000000ULL, uint64_t low=0, uint64_t high=30ULL *24ULL *60ULL, uint64_t binCount=30UL *24UL *60ULL)
Constructs the rate histogrammer.
Definition: RateHistogrammer.hpp:44
RateHistogrammer(_result_tree_type results, Selector selector, const std::string &name, uint64_t divider=60 *100000000ULL, uint64_t low=0, uint64_t binCount=30UL *24UL *60ULL)
Constructs the rate histogrammer.
Definition: RateHistogrammer.hpp:67
Abstract baseclass for all stages which uses or modifies detector events.
Definition: StageDetectorEvent.hpp:20
Definition: mainpage.dox:6
Default context for printing and collecting statistics.
Definition: ContextBase.hpp:41