Belle II Software  release-05-01-25
ARICHHitRateCounter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric, Luka Santelj *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <background/modules/BeamBkgHitRateMonitor/HitRateBase.h>
14 #include <framework/datastore/StoreArray.h>
15 #include <framework/database/DBObjPtr.h>
16 #include <arich/dataobjects/ARICHHit.h>
17 #include <arich/dbobjects/ARICHChannelMask.h>
18 #include <arich/dbobjects/ARICHModulesInfo.h>
19 #include <TTree.h>
20 #include <map>
21 
22 
23 namespace Belle2 {
28  namespace Background {
29 
33  class ARICHHitRateCounter: public HitRateBase {
34 
35  public:
36 
40  struct TreeStruct {
41 
42  float segmentRates[18] = {0};
43  float averageRate = 0;
44  int numEvents = 0;
45  bool valid = false;
50  void normalize()
51  {
52  if (numEvents == 0) return;
53  for (auto& segmentRate : segmentRates) segmentRate /= numEvents;
55  }
56 
57  };
58 
63  {}
64 
69  virtual void initialize(TTree* tree) override;
70 
74  virtual void clear() override;
75 
80  virtual void accumulate(unsigned timeStamp) override;
81 
86  virtual void normalize(unsigned timeStamp) override;
87 
88  private:
89 
93  void setActiveHapds();
94 
95  // tree structure
98  // buffer
99  std::map<unsigned, TreeStruct> m_buffer;
101  // collections
104  // DB payloads
108  // other
109  double m_activeHapds[18] = {0};
110  double m_activeTotal = 0;
111  int m_segmentMap[420] = {0};
112  };
113 
114  } // Background namespace
116 } // Belle2 namespace
Belle2::Background::ARICHHitRateCounter::clear
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
Definition: ARICHHitRateCounter.cc:50
Belle2::Background::ARICHHitRateCounter::m_rates
TreeStruct m_rates
tree variables
Definition: ARICHHitRateCounter.h:104
Belle2::Background::ARICHHitRateCounter::m_activeHapds
double m_activeHapds[18]
number of active HAPDS in each segment
Definition: ARICHHitRateCounter.h:117
Belle2::Background::ARICHHitRateCounter::accumulate
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
Definition: ARICHHitRateCounter.cc:55
Belle2::Background::ARICHHitRateCounter::TreeStruct::segmentRates
float segmentRates[18]
hit rates per HAPD [Hz] for 18 segments of arich
Definition: ARICHHitRateCounter.h:50
Belle2::Background::ARICHHitRateCounter::m_modulesInfo
DBObjPtr< ARICHModulesInfo > m_modulesInfo
HAPD modules info.
Definition: ARICHHitRateCounter.h:114
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::Background::ARICHHitRateCounter::m_activeTotal
double m_activeTotal
total number of active HAPDS
Definition: ARICHHitRateCounter.h:118
Belle2::Background::ARICHHitRateCounter::TreeStruct::normalize
void normalize()
normalize accumulated hits to single event
Definition: ARICHHitRateCounter.h:58
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Background::ARICHHitRateCounter::setActiveHapds
void setActiveHapds()
Sets number of active hapds in each segment.
Definition: ARICHHitRateCounter.cc:101
Belle2::Background::ARICHHitRateCounter::m_hits
StoreArray< ARICHHit > m_hits
collection of digits
Definition: ARICHHitRateCounter.h:110
Belle2::Background::ARICHHitRateCounter::m_channelMask
DBObjPtr< ARICHChannelMask > m_channelMask
channel mask
Definition: ARICHHitRateCounter.h:113
Belle2::Background::ARICHHitRateCounter::m_buffer
std::map< unsigned, TreeStruct > m_buffer
average rates in time stamps
Definition: ARICHHitRateCounter.h:107
Belle2::Background::ARICHHitRateCounter::TreeStruct
tree structure
Definition: ARICHHitRateCounter.h:48
Belle2::Background::ARICHHitRateCounter::ARICHHitRateCounter
ARICHHitRateCounter()
Constructor.
Definition: ARICHHitRateCounter.h:70
Belle2::Background::ARICHHitRateCounter::TreeStruct::numEvents
int numEvents
number of events accumulated
Definition: ARICHHitRateCounter.h:52
Belle2::Background::ARICHHitRateCounter::initialize
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
Definition: ARICHHitRateCounter.cc:26
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::Background::ARICHHitRateCounter::TreeStruct::averageRate
float averageRate
total detector average hit rate per HAPD [Hz]
Definition: ARICHHitRateCounter.h:51
Belle2::Background::ARICHHitRateCounter::m_segmentMap
int m_segmentMap[420]
mapping from module ID to segments
Definition: ARICHHitRateCounter.h:119
Belle2::Background::ARICHHitRateCounter::TreeStruct::valid
bool valid
status: true = rates valid
Definition: ARICHHitRateCounter.h:53
Belle2::Background::ARICHHitRateCounter::normalize
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
Definition: ARICHHitRateCounter.cc:80