Belle II Software  release-05-01-25
TOPCalChannelNoise.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TObject.h>
14 #include <framework/logging/Logger.h>
15 
16 namespace Belle2 {
28  class TOPCalChannelNoise: public TObject {
29  public:
30 
34  enum EStatus {
35  c_Default = 0,
37  c_Unusable = 2
38  };
39 
45 
53  void setNoise(int moduleID, unsigned channel, double rmsNoise)
54  {
55  unsigned module = moduleID - 1;
56  if (module >= c_numModules) {
57  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
58  return;
59  }
60  if (channel >= c_numChannels) {
61  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
62  return;
63  }
64  m_rmsNoise[module][channel] = rmsNoise;
65  m_status[module][channel] = c_Calibrated;
66  }
67 
73  void setUnusable(int moduleID, unsigned channel)
74  {
75  unsigned module = moduleID - 1;
76  if (module >= c_numModules) {
77  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
78  return;
79  }
80  if (channel >= c_numChannels) {
81  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
82  return;
83  }
84  m_status[module][channel] = c_Unusable;
85  }
86 
93  double getNoise(int moduleID, unsigned channel) const
94  {
95  unsigned module = moduleID - 1;
96  if (module >= c_numModules) {
97  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
98  return 0;
99  }
100  if (channel >= c_numChannels) {
101  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
102  return 0;
103  }
104  return m_rmsNoise[module][channel];
105  }
106 
113  bool isCalibrated(int moduleID, unsigned channel) const
114  {
115  unsigned module = moduleID - 1;
116  if (module >= c_numModules) return false;
117  if (channel >= c_numChannels) return false;
118  return m_status[module][channel] == c_Calibrated;
119  }
120 
127  bool isDefault(int moduleID, unsigned channel) const
128  {
129  unsigned module = moduleID - 1;
130  if (module >= c_numModules) return false;
131  if (channel >= c_numChannels) return false;
132  return m_status[module][channel] == c_Default;
133  }
134 
141  bool isUnusable(int moduleID, unsigned channel) const
142  {
143  unsigned module = moduleID - 1;
144  if (module >= c_numModules) return false;
145  if (channel >= c_numChannels) return false;
146  return m_status[module][channel] == c_Unusable;
147  }
148 
149  private:
150 
154  enum {
155  c_numModules = 16,
156  c_numChannels = 512
157  };
158 
159  float m_rmsNoise[c_numModules][c_numChannels] = {{0}};
164  };
165 
167 } // end namespace Belle2
168 
169 
Belle2::TOPCalChannelNoise::c_Calibrated
@ c_Calibrated
good calibrated value
Definition: TOPCalChannelNoise.h:44
Belle2::TOPCalChannelNoise::ClassDef
ClassDef(TOPCalChannelNoise, 2)
ClassDef.
Belle2::TOPCalChannelNoise::m_rmsNoise
float m_rmsNoise[c_numModules][c_numChannels]
noise [ADC counts]
Definition: TOPCalChannelNoise.h:167
Belle2::TOPCalChannelNoise::setNoise
void setNoise(int moduleID, unsigned channel, double rmsNoise)
Sets the noise r.m.s for a single channel and switches status to calibrated.
Definition: TOPCalChannelNoise.h:61
Belle2::TOPCalChannelNoise::getNoise
double getNoise(int moduleID, unsigned channel) const
Returns the noise r.m.s of a single channel (0 or negative: data not available)
Definition: TOPCalChannelNoise.h:101
Belle2::TOPCalChannelNoise::m_status
EStatus m_status[c_numModules][c_numChannels]
calibration status
Definition: TOPCalChannelNoise.h:168
Belle2::TOPCalChannelNoise::c_numModules
@ c_numModules
number of modules
Definition: TOPCalChannelNoise.h:163
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPCalChannelNoise::EStatus
EStatus
Calibration status of a constant.
Definition: TOPCalChannelNoise.h:42
Belle2::TOPCalChannelNoise::isUnusable
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelNoise.h:149
Belle2::TOPCalChannelNoise::c_numChannels
@ c_numChannels
number of channels per module
Definition: TOPCalChannelNoise.h:164
Belle2::TOPCalChannelNoise::c_Unusable
@ c_Unusable
bad calibrated value
Definition: TOPCalChannelNoise.h:45
Belle2::TOPCalChannelNoise::setUnusable
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
Definition: TOPCalChannelNoise.h:81
Belle2::TOPCalChannelNoise::isDefault
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelNoise.h:135
Belle2::TOPCalChannelNoise::isCalibrated
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelNoise.h:121
Belle2::TOPCalChannelNoise::TOPCalChannelNoise
TOPCalChannelNoise()
Default constructor.
Definition: TOPCalChannelNoise.h:52
Belle2::TOPCalChannelNoise::c_Default
@ c_Default
uncalibrated default value
Definition: TOPCalChannelNoise.h:43