Belle II Software  release-08-01-10
TOPCalIntegratedCharge.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 <TObject.h>
12 #include <framework/logging/Logger.h>
13 
14 namespace Belle2 {
23  class TOPCalIntegratedCharge: public TObject {
24  public:
25 
29  enum EStatus {
30  c_Default = 0,
32  c_Unusable = 2
33  };
34 
39 
46  void setCharge(int moduleID, unsigned channel, double charge)
47  {
48  unsigned module = moduleID - 1;
49  if (module >= c_numModules) {
50  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
51  return;
52  }
53  if (channel >= c_numChannels) {
54  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
55  return;
56  }
57  m_charge[module][channel] = charge;
58  m_status[module][channel] = c_Calibrated;
59  }
60 
66  void setUnusable(int moduleID, unsigned channel)
67  {
68  unsigned module = moduleID - 1;
69  if (module >= c_numModules) {
70  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
71  return;
72  }
73  if (channel >= c_numChannels) {
74  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
75  return;
76  }
77  m_status[module][channel] = c_Unusable;
78  }
79 
86  double getCharge(int moduleID, unsigned channel) const
87  {
88  unsigned module = moduleID - 1;
89  if (module >= c_numModules) {
90  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
91  return 0;
92  }
93  if (channel >= c_numChannels) {
94  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
95  return 0;
96  }
97  return m_charge[module][channel];
98  }
99 
106  bool isCalibrated(int moduleID, unsigned channel) const
107  {
108  unsigned module = moduleID - 1;
109  if (module >= c_numModules) return false;
110  if (channel >= c_numChannels) return false;
111  return m_status[module][channel] == c_Calibrated;
112  }
113 
120  bool isDefault(int moduleID, unsigned channel) const
121  {
122  unsigned module = moduleID - 1;
123  if (module >= c_numModules) return false;
124  if (channel >= c_numChannels) return false;
125  return m_status[module][channel] == c_Default;
126  }
127 
134  bool isUnusable(int moduleID, unsigned channel) const
135  {
136  unsigned module = moduleID - 1;
137  if (module >= c_numModules) return false;
138  if (channel >= c_numChannels) return false;
139  return m_status[module][channel] == c_Unusable;
140  }
141 
142  private:
143 
147  enum {
149  c_numChannels = 512
150  };
151 
157  };
158 
160 } // end namespace Belle2
161 
Class to store integrated charge per channel.
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
void setCharge(int moduleID, unsigned channel, double charge)
Sets the integrated charge for a single channel and switches status to calibrated.
TOPCalIntegratedCharge()
Default constructor.
float m_charge[c_numModules][c_numChannels]
integrated charge [C/cm^2]
double getCharge(int moduleID, unsigned channel) const
Returns the integrated charge of a single channel.
EStatus m_status[c_numModules][c_numChannels]
calibration status
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
EStatus
Calibration status of a constant.
@ c_Default
uncalibrated default value
ClassDef(TOPCalIntegratedCharge, 1)
ClassDef.
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
@ c_numChannels
number of channels per module
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Abstract base class for different kinds of events.