Belle II Software  release-08-01-10
ARICHHitRateCounter.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 <arich/dataobjects/ARICHHit.h>
15 #include <arich/dbobjects/ARICHChannelMask.h>
16 #include <arich/dbobjects/ARICHModulesInfo.h>
17 #include <TTree.h>
18 #include <map>
19 
20 
21 namespace Belle2 {
26  namespace Background {
27 
32 
33  public:
34 
38  struct TreeStruct {
39 
40  float segmentRates[18] = {0};
41  float averageRate = 0;
42  int numEvents = 0;
43  bool valid = false;
48  void normalize()
49  {
50  if (numEvents == 0) return;
51  for (auto& segmentRate : segmentRates) segmentRate /= numEvents;
53  }
54 
55  };
56 
61  {}
62 
67  virtual void initialize(TTree* tree) override;
68 
72  virtual void clear() override;
73 
78  virtual void accumulate(unsigned timeStamp) override;
79 
84  virtual void normalize(unsigned timeStamp) override;
85 
86  private:
87 
91  void setActiveHapds();
92 
93  // tree structure
96  // buffer
97  std::map<unsigned, TreeStruct> m_buffer;
99  // collections
102  // DB payloads
106  // other
107  double m_activeHapds[18] = {0};
108  double m_activeTotal = 0;
109  int m_segmentMap[420] = {0};
110  };
111 
112  } // Background namespace
114 } // Belle2 namespace
Class for monitoring beam background hit rates of ARICH.
std::map< unsigned, TreeStruct > m_buffer
average rates in time stamps
void setActiveHapds()
Sets number of active hapds in each segment.
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
double m_activeTotal
total number of active HAPDS
int m_segmentMap[420]
mapping from module ID to segments
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
StoreArray< ARICHHit > m_hits
collection of digits
DBObjPtr< ARICHModulesInfo > m_modulesInfo
HAPD modules info.
DBObjPtr< ARICHChannelMask > m_channelMask
channel mask
double m_activeHapds[18]
number of active HAPDS in each segment
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
Abstract base class for monitoring beam background hit rates All the monitoring classes must inherit ...
Definition: HitRateBase.h:24
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 segmentRates[18]
hit rates per HAPD [Hz] for 18 segments of arich
float averageRate
total detector average hit rate per HAPD [Hz]
void normalize()
normalize accumulated hits to single event