Belle II Software development
TOPCalChannelNoise.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
14namespace Belle2 {
26 class TOPCalChannelNoise: public TObject {
27 public:
28
32 enum EStatus {
35 c_Unusable = 2
36 };
37
43
51 void setNoise(int moduleID, unsigned channel, double rmsNoise)
52 {
53 unsigned module = moduleID - 1;
54 if (module >= c_numModules) {
55 B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
56 return;
57 }
58 if (channel >= c_numChannels) {
59 B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
60 return;
61 }
62 m_rmsNoise[module][channel] = rmsNoise;
63 m_status[module][channel] = c_Calibrated;
64 }
65
71 void setUnusable(int moduleID, unsigned channel)
72 {
73 unsigned module = moduleID - 1;
74 if (module >= c_numModules) {
75 B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
76 return;
77 }
78 if (channel >= c_numChannels) {
79 B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
80 return;
81 }
82 m_status[module][channel] = c_Unusable;
83 }
84
91 double getNoise(int moduleID, unsigned channel) const
92 {
93 unsigned module = moduleID - 1;
94 if (module >= c_numModules) {
95 B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
96 return 0;
97 }
98 if (channel >= c_numChannels) {
99 B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
100 return 0;
101 }
102 return m_rmsNoise[module][channel];
103 }
104
111 bool isCalibrated(int moduleID, unsigned channel) const
112 {
113 unsigned module = moduleID - 1;
114 if (module >= c_numModules) return false;
115 if (channel >= c_numChannels) return false;
116 return m_status[module][channel] == c_Calibrated;
117 }
118
125 bool isDefault(int moduleID, unsigned channel) const
126 {
127 unsigned module = moduleID - 1;
128 if (module >= c_numModules) return false;
129 if (channel >= c_numChannels) return false;
130 return m_status[module][channel] == c_Default;
131 }
132
139 bool isUnusable(int moduleID, unsigned channel) const
140 {
141 unsigned module = moduleID - 1;
142 if (module >= c_numModules) return false;
143 if (channel >= c_numChannels) return false;
144 return m_status[module][channel] == c_Unusable;
145 }
146
147 private:
148
152 enum {
154 c_numChannels = 512
155 };
156
162 };
163
165} // end namespace Belle2
166
167
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
void setNoise(int moduleID, unsigned channel, double rmsNoise)
Sets the noise r.m.s for a single channel and switches status to calibrated.
double getNoise(int moduleID, unsigned channel) const
Returns the noise r.m.s of a single channel (0 or negative: data not available)
EStatus m_status[c_numModules][c_numChannels]
calibration status
TOPCalChannelNoise()
Default constructor.
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
ClassDef(TOPCalChannelNoise, 2)
ClassDef.
EStatus
Calibration status of a constant.
@ c_Calibrated
good calibrated value
@ c_Unusable
bad calibrated value
@ c_Default
uncalibrated default value
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
@ c_numChannels
number of channels per module
@ c_numModules
number of modules
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
float m_rmsNoise[c_numModules][c_numChannels]
noise [ADC counts]
Abstract base class for different kinds of events.