Belle II Software  release-08-01-10
KLMHitRateCounter.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 /* C++ headers. */
12 #include <map>
13 
14 /* External headers. */
15 #include <TTree.h>
16 
17 /* Basf2 headers. */
18 #include <background/modules/BeamBkgHitRateMonitor/HitRateBase.h>
19 #include <klm/dataobjects/KLMDigit.h>
20 #include <klm/dataobjects/KLMElementNumbers.h>
21 #include <klm/dataobjects/KLMModuleArrayIndex.h>
22 #include <framework/database/DBObjPtr.h>
23 #include <framework/datastore/StoreArray.h>
24 #include <klm/dbobjects/KLMChannelStatus.h>
25 
26 namespace Belle2 {
32  namespace Background {
33 
38 
39  public:
40 
44  struct TreeStruct {
45 
48 
50  float averageRate = 0;
51 
53  int numEvents = 0;
54 
56  bool valid = false;
57 
61  void normalize()
62  {
63  if (numEvents == 0)
64  return;
65  for (int i = 0; i < KLMElementNumbers::getTotalModuleNumber(); ++i)
66  moduleRates[i] /= numEvents;
68  }
69 
70  };
71 
76 
81  virtual void initialize(TTree* tree) override;
82 
86  virtual void clear() override;
87 
92  virtual void accumulate(unsigned timeStamp) override;
93 
98  virtual void normalize(unsigned timeStamp) override;
99 
100  private:
101 
104 
106  std::map<unsigned, TreeStruct> m_buffer;
107 
110 
113 
116 
119 
120  };
121 
122  }
123 
125 }
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 EKLM.
std::map< unsigned, TreeStruct > m_buffer
Buffer.
StoreArray< KLMDigit > m_digits
KLM digits.
DBObjPtr< KLMChannelStatus > m_ChannelStatus
KLM channel status.
virtual void initialize(TTree *tree) override
Class initializer.
const KLMElementNumbers * m_ElementNumbers
KLM element numbers.
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
const KLMModuleArrayIndex * m_ModuleArrayIndex
KLM module array index.
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (i.e.
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
KLM element numbers.
static constexpr int getTotalModuleNumber()
Get total number of modules.
KLM module array index.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Abstract base class for different kinds of events.
float moduleRates[KLMElementNumbers::getTotalModuleNumber()]
Hit rates in each module.
float averageRate
Total detector average hit rate.
void normalize()
Normalize accumulated hits to single event.