Belle II Software  release-05-01-25
SVDHitRateCounter.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, Hikaru Tanigawa *
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 <mdst/dataobjects/SoftwareTriggerResult.h>
16 #include <svd/dataobjects/SVDShaperDigit.h>
17 #include <svd/dataobjects/SVDCluster.h>
18 #include <svd/calibration/SVDHotStripsCalibrations.h>
19 #include <svd/calibration/SVDFADCMaskedStrips.h>
20 #include <TTree.h>
21 #include <map>
22 #include <string>
23 
24 
25 namespace Belle2 {
30  namespace Background {
31 
35  class SVDHitRateCounter: public HitRateBase {
36 
37  public:
38 
42  struct TreeStruct {
43  float layerAverageRates[4] = {0};
44  float layerLadderAverageRates[4][16] = {0};
45  float layerSensorAverageRates[4][5] = {0};
46  float averageRate = 0;
47  float l3LadderSensorAverageRates[7][2] = {0};
48  int numEvents = 0;
49  bool valid = false;
54  void normalize()
55  {
56  if (numEvents == 0) return;
58  for (auto& rate : layerAverageRates) rate /= numEvents;
59  for (auto& row : layerLadderAverageRates) {
60  for (auto& rate : row) {
61  rate /= numEvents;
62  }
63  }
64  for (auto& row : layerSensorAverageRates) {
65  for (auto& rate : row) {
66  rate /= numEvents;
67  }
68  }
69  for (auto& row : l3LadderSensorAverageRates) {
70  for (auto& rate : row) {
71  rate /= numEvents;
72  }
73  }
74  }
75  };
76 
82  explicit SVDHitRateCounter(const std::string& svdShaperDigitsName, double thrCharge):
83  m_svdShaperDigitsName(svdShaperDigitsName), m_thrCharge(thrCharge)
84  {}
85 
90  virtual void initialize(TTree* tree) override;
91 
95  virtual void clear() override;
96 
101  virtual void accumulate(unsigned timeStamp) override;
102 
107  virtual void normalize(unsigned timeStamp) override;
108 
113  virtual void normalize_rates(TreeStruct& rates);
114 
120  int nStripsOnLayerSide(int layer, bool isU)
121  {
122  if (!isU && layer > 0) return 512; // V side on Layer 4,5,6
123  else return 768;
124  }
125 
126  private:
127 
128  // class parameters: to be set via constructor or setters
129  int m_nLayers = 4;
130  int m_nLadders[4] = {7, 10, 12, 16};
131  int m_nSensors[4] = {2, 3, 4, 5};
133  // tree structure
134  TreeStruct m_rates;
135  TreeStruct m_rates_highE;
136  TreeStruct m_rates_lowE;
138  // buffer
139  std::map<unsigned, TreeStruct> m_buffer;
140  std::map<unsigned, TreeStruct> m_buffer_highE;
141  std::map<unsigned, TreeStruct> m_buffer_lowE;
143  // collections
147  // store object
150  // DB payloads
154  // other
155  std::string m_svdShaperDigitsName;
156  int m_activeStrips = 0;
157  int m_layerActiveStrips[4] = {0};
158  int m_layerLadderActiveStrips[4][16] = {0};
159  int m_layerSensorActiveStrips[4][5] = {0};
161  double m_thrCharge = 0;
163  };
164 
165  } // Background namespace
167 } // Belle2 namespace
Belle2::Background::SVDHitRateCounter::normalize_rates
virtual void normalize_rates(TreeStruct &rates)
Normalize TreeStruct.
Definition: SVDHitRateCounter.cc:176
Belle2::Background::SVDHitRateCounter::nStripsOnLayerSide
int nStripsOnLayerSide(int layer, bool isU)
Return number of strips on a sensor.
Definition: SVDHitRateCounter.h:128
Belle2::SVDFADCMaskedStrips
This class defines the dbobject and the method to access strips which are masked at FADC level.
Definition: SVDFADCMaskedStrips.h:44
Belle2::Background::SVDHitRateCounter::m_resultStoreObjectPointer
StoreObjPtr< SoftwareTriggerResult > m_resultStoreObjectPointer
trigger decision
Definition: SVDHitRateCounter.h:156
Belle2::Background::SVDHitRateCounter::m_nLayers
int m_nLayers
number of layers
Definition: SVDHitRateCounter.h:137
Belle2::Background::SVDHitRateCounter::TreeStruct
tree structure
Definition: SVDHitRateCounter.h:50
Belle2::Background::SVDHitRateCounter::TreeStruct::numEvents
int numEvents
number of events accumulated
Definition: SVDHitRateCounter.h:56
Belle2::Background::SVDHitRateCounter::m_thrCharge
double m_thrCharge
cut on cluster energy in electrons
Definition: SVDHitRateCounter.h:169
Belle2::Background::SVDHitRateCounter::TreeStruct::l3LadderSensorAverageRates
float l3LadderSensorAverageRates[7][2]
Layer 3 sensors [#ladder][#sensor].
Definition: SVDHitRateCounter.h:55
Belle2::Background::SVDHitRateCounter::m_nSensors
int m_nSensors[4]
number of sensors on a ladder on each layer
Definition: SVDHitRateCounter.h:139
Belle2::Background::SVDHitRateCounter::m_clusters
StoreArray< SVDCluster > m_clusters
collection of clusters
Definition: SVDHitRateCounter.h:153
Belle2::Background::SVDHitRateCounter::normalize
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
Definition: SVDHitRateCounter.cc:163
Belle2::Background::SVDHitRateCounter::TreeStruct::normalize
void normalize()
normalize accumulated hits to single event
Definition: SVDHitRateCounter.h:62
Belle2::Background::SVDHitRateCounter::SVDHitRateCounter
SVDHitRateCounter(const std::string &svdShaperDigitsName, double thrCharge)
Constructor.
Definition: SVDHitRateCounter.h:90
Belle2::Background::SVDHitRateCounter::m_rates_highE
TreeStruct m_rates_highE
tree variables for high-energy clusters
Definition: SVDHitRateCounter.h:143
Belle2::Background::SVDHitRateCounter::TreeStruct::averageRate
float averageRate
total SVD average occupancy
Definition: SVDHitRateCounter.h:54
Belle2::Background::SVDHitRateCounter::m_digits
StoreArray< SVDShaperDigit > m_digits
collection of digits
Definition: SVDHitRateCounter.h:152
Belle2::Background::SVDHitRateCounter::m_buffer_highE
std::map< unsigned, TreeStruct > m_buffer_highE
average cluster occupancies (high energy) in time stamps
Definition: SVDHitRateCounter.h:148
Belle2::SVDHotStripsCalibrations
This class defines the wrapper to retrieve the the list of the hot strips flgged offline.
Definition: SVDHotStripsCalibrations.h:44
Belle2::Background::SVDHitRateCounter::TreeStruct::layerLadderAverageRates
float layerLadderAverageRates[4][16]
[#layer][#ladder]
Definition: SVDHitRateCounter.h:52
Belle2::Background::SVDHitRateCounter::m_l3LadderSensorActiveStrips
int m_l3LadderSensorActiveStrips[7][2]
number of active strips in each sensor in Layer 3
Definition: SVDHitRateCounter.h:168
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::Background::SVDHitRateCounter::m_activeStrips
int m_activeStrips
number of active strips
Definition: SVDHitRateCounter.h:164
Belle2::Background::SVDHitRateCounter::clear
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
Definition: SVDHitRateCounter.cc:79
Belle2::Background::SVDHitRateCounter::TreeStruct::layerSensorAverageRates
float layerSensorAverageRates[4][5]
[#layer][#sensor]
Definition: SVDHitRateCounter.h:53
Belle2::Background::SVDHitRateCounter::m_svdShaperDigitsName
std::string m_svdShaperDigitsName
name of the input SVDShaperDigits collection
Definition: SVDHitRateCounter.h:163
Belle2::Background::SVDHitRateCounter::m_buffer
std::map< unsigned, TreeStruct > m_buffer
average strip occupancies in time stamps
Definition: SVDHitRateCounter.h:147
Belle2::Background::SVDHitRateCounter::m_rates
TreeStruct m_rates
tree variables for fired strips
Definition: SVDHitRateCounter.h:142
Belle2::Background::SVDHitRateCounter::m_layerSensorActiveStrips
int m_layerSensorActiveStrips[4][5]
number of active strips in each layer, sensor position
Definition: SVDHitRateCounter.h:167
Belle2::Background::SVDHitRateCounter::TreeStruct::valid
bool valid
status: true = rates valid
Definition: SVDHitRateCounter.h:57
Belle2::Background::SVDHitRateCounter::m_layerLadderActiveStrips
int m_layerLadderActiveStrips[4][16]
number of active strips in each layer, ladder
Definition: SVDHitRateCounter.h:166
Belle2::Background::SVDHitRateCounter::m_HotStripsCalib
SVDHotStripsCalibrations m_HotStripsCalib
payload for hot strips
Definition: SVDHitRateCounter.h:159
Belle2::Background::SVDHitRateCounter::accumulate
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
Definition: SVDHitRateCounter.cc:84
Belle2::Background::SVDHitRateCounter::m_FADCMaskedStrips
SVDFADCMaskedStrips m_FADCMaskedStrips
payload for strips masked on FADC level
Definition: SVDHitRateCounter.h:160
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::Background::SVDHitRateCounter::m_nLadders
int m_nLadders[4]
number of ladders on each layer
Definition: SVDHitRateCounter.h:138
Belle2::Background::SVDHitRateCounter::m_buffer_lowE
std::map< unsigned, TreeStruct > m_buffer_lowE
average cluster occupancies (low energy) in time stamps
Definition: SVDHitRateCounter.h:149
Belle2::Background::SVDHitRateCounter::m_rates_lowE
TreeStruct m_rates_lowE
tree variables for low-energy clusters
Definition: SVDHitRateCounter.h:144
Belle2::Background::SVDHitRateCounter::m_layerActiveStrips
int m_layerActiveStrips[4]
number of active strips in each layer
Definition: SVDHitRateCounter.h:165
Belle2::Background::SVDHitRateCounter::initialize
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
Definition: SVDHitRateCounter.cc:27
Belle2::Background::SVDHitRateCounter::TreeStruct::layerAverageRates
float layerAverageRates[4]
layer average occupancy
Definition: SVDHitRateCounter.h:51