Belle II Software  release-05-02-19
TOPCalChannelThreshold.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Umberto Tamponi (tamponi@to.infn.it), 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 {
27  class TOPCalChannelThreshold: public TObject {
28  public:
29 
33  enum EStatus {
34  c_Default = 0,
36  c_Unusable = 2
37  };
38 
43 
50  void setThr(int moduleID, unsigned channel, short Thr)
51  {
52  unsigned module = moduleID - 1;
53  if (module >= c_numModules) {
54  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
55  return;
56  }
57  if (channel >= c_numChannels) {
58  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
59  return;
60  }
61  m_Thr[module][channel] = Thr;
62  m_status[module][channel] = c_Calibrated;
63  }
64 
70  void setUnusable(int moduleID, unsigned channel)
71  {
72  unsigned module = moduleID - 1;
73  if (module >= c_numModules) {
74  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
75  return;
76  }
77  if (channel >= c_numChannels) {
78  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
79  return;
80  }
81  m_status[module][channel] = c_Unusable;
82  }
83 
90  short getThr(int moduleID, unsigned channel) const
91  {
92  unsigned module = moduleID - 1;
93  if (module >= c_numModules) {
94  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
95  return 0;
96  }
97  if (channel >= c_numChannels) {
98  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
99  return 0;
100  }
101  return m_Thr[module][channel];
102  }
103 
110  bool isCalibrated(int moduleID, unsigned channel) const
111  {
112  unsigned module = moduleID - 1;
113  if (module >= c_numModules) return false;
114  if (channel >= c_numChannels) return false;
115  return m_status[module][channel] == c_Calibrated;
116  }
117 
124  bool isDefault(int moduleID, unsigned channel) const
125  {
126  unsigned module = moduleID - 1;
127  if (module >= c_numModules) return false;
128  if (channel >= c_numChannels) return false;
129  return m_status[module][channel] == c_Default;
130  }
131 
138  bool isUnusable(int moduleID, unsigned channel) const
139  {
140  unsigned module = moduleID - 1;
141  if (module >= c_numModules) return false;
142  if (channel >= c_numChannels) return false;
143  return m_status[module][channel] == c_Unusable;
144  }
145 
146  private:
147 
151  enum {c_numModules = 16,
152  c_numChannels = 512
153  };
154 
155  short m_Thr[c_numModules][c_numChannels] = {{0}};
160  };
161 
163 } // end namespace Belle2
164 
Belle2::TOPCalChannelThreshold::isDefault
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelThreshold.h:132
Belle2::TOPCalChannelThreshold::setUnusable
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
Definition: TOPCalChannelThreshold.h:78
Belle2::TOPCalChannelThreshold::isUnusable
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelThreshold.h:146
Belle2::TOPCalChannelThreshold::isCalibrated
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelThreshold.h:118
Belle2::TOPCalChannelThreshold::EStatus
EStatus
Calibration status of a constant.
Definition: TOPCalChannelThreshold.h:41
Belle2::TOPCalChannelThreshold::c_numModules
@ c_numModules
number of modules
Definition: TOPCalChannelThreshold.h:159
Belle2::TOPCalChannelThreshold::m_status
EStatus m_status[c_numModules][c_numChannels]
calibration status
Definition: TOPCalChannelThreshold.h:164
Belle2::TOPCalChannelThreshold::getThr
short getThr(int moduleID, unsigned channel) const
Returns the threshold (in ADC counts) of a single channel.
Definition: TOPCalChannelThreshold.h:98
Belle2::TOPCalChannelThreshold::TOPCalChannelThreshold
TOPCalChannelThreshold()
Default constructor.
Definition: TOPCalChannelThreshold.h:50
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPCalChannelThreshold::c_Calibrated
@ c_Calibrated
good calibrated value
Definition: TOPCalChannelThreshold.h:43
Belle2::TOPCalChannelThreshold::c_Unusable
@ c_Unusable
bad calibrated value
Definition: TOPCalChannelThreshold.h:44
Belle2::TOPCalChannelThreshold::setThr
void setThr(int moduleID, unsigned channel, short Thr)
Sets the threshold (in ADC counts) for a single channel and switches status to calibrated.
Definition: TOPCalChannelThreshold.h:58
Belle2::TOPCalChannelThreshold::c_numChannels
@ c_numChannels
number of channels per module
Definition: TOPCalChannelThreshold.h:160
Belle2::TOPCalChannelThreshold::c_Default
@ c_Default
uncalibrated default value
Definition: TOPCalChannelThreshold.h:42
Belle2::TOPCalChannelThreshold::m_Thr
short m_Thr[c_numModules][c_numChannels]
threshold value in ADC counts.
Definition: TOPCalChannelThreshold.h:163
Belle2::TOPCalChannelThreshold::ClassDef
ClassDef(TOPCalChannelThreshold, 2)
ClassDef.