Belle II Software  release-08-01-10
TOPHitRateCounter.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <background/modules/BeamBkgHitRateMonitor/HitRateBase.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/database/DBObjPtr.h>
14 #include <top/dataobjects/TOPDigit.h>
15 #include <top/dbobjects/TOPCalChannelMask.h>
16 #include <TTree.h>
17 #include <TH1F.h>
18 #include <map>
19 
20 namespace Belle2 {
25  namespace Background {
26 
34 
35  public:
36 
40  struct TreeStruct {
41  float slotRates[16] = {0};
42  float averageRate = 0;
43  int numEvents = 0;
44  bool valid = false;
49  void normalize()
50  {
51  if (numEvents == 0) return;
52  for (auto& slotRate : slotRates) slotRate /= numEvents;
54  }
55 
56  };
57 
63  TOPHitRateCounter(double timeOffset, double timeWindow):
64  m_timeOffset(timeOffset), m_timeWindow(timeWindow)
65  {}
66 
71  virtual void initialize(TTree* tree) override;
72 
76  virtual void clear() override;
77 
82  virtual void accumulate(unsigned timeStamp) override;
83 
88  virtual void normalize(unsigned timeStamp) override;
89 
90  private:
91 
95  void setActiveFractions();
96 
97  // class parameters: to be set via constructor or setters
98  double m_timeOffset = 0;
99  double m_timeWindow = 0;
101  // tree structure
104  // buffer
105  std::map<unsigned, TreeStruct> m_buffer;
107  // collections
110  // DB payloads
113  // control histograms: to check if time offset and window size are correctly set
114  TH1F* m_hits = 0;
115  TH1F* m_hitsInWindow = 0;
117  // other
118  double m_activeFractions[16] = {0};
119  double m_activeTotal = 0;
121  };
122 
123  } // Background namespace
125 } // Belle2 namespace
Abstract base class for monitoring beam background hit rates All the monitoring classes must inherit ...
Definition: HitRateBase.h:24
Class for monitoring beam background hit rates of TOP.
std::map< unsigned, TreeStruct > m_buffer
average rates in time stamps
DBObjPtr< TOPCalChannelMask > m_channelMask
channel mask
void setActiveFractions()
Sets fractions of active channels.
TH1F * m_hitsInWindow
time distribution of hits inside timeWindow
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
double m_activeTotal
total fraction of active channels
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
double m_activeFractions[16]
fractions of active channels in slots
TOPHitRateCounter(double timeOffset, double timeWindow)
Constructor.
double m_timeWindow
time window in which to count hits [ns]
StoreArray< TOPDigit > m_digits
collection of digits
TH1F * m_hits
time distribution of hits in wide range
double m_timeOffset
time offset of hits [ns]
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Abstract base class for different kinds of events.
float slotRates[16]
hit rates per PMT of the modules (slots) [MHz]
float averageRate
average hit rate per PMT [MHz]
void normalize()
normalize accumulated hits to single event