Belle II Software  release-05-02-19
TOPCalChannelThresholdEff.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  * Maeda Yosuke *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 
12 #pragma once
13 
14 #include <TObject.h>
15 #include <framework/logging/Logger.h>
16 
17 namespace Belle2 {
29  class TOPCalChannelThresholdEff: public TObject {
30  public:
31 
35  enum EStatus {
36  c_Default = 0,
37  c_Calibrated = 1,
39  };
40 
46 
55  void setThrEff(int moduleID, unsigned channel, float ThrEff, short offlineThreshold)
56  {
57  unsigned module = moduleID - 1;
58  if (module >= c_numModules) {
59  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
60  return;
61  }
62  if (channel >= c_numChannels) {
63  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
64  return;
65  }
66  m_ThrEff[module][channel] = ThrEff;
67  m_offlineThreshold[module][channel] = offlineThreshold;
68  m_status[module][channel] = c_Calibrated;
69  }
70 
76  void setUnusable(int moduleID, unsigned channel)
77  {
78  unsigned module = moduleID - 1;
79  if (module >= c_numModules) {
80  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
81  return;
82  }
83  if (channel >= c_numChannels) {
84  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
85  return;
86  }
87  m_status[module][channel] = c_Unusable;
88  }
89 
96  float getThrEff(int moduleID, unsigned channel) const
97  {
98  unsigned module = moduleID - 1;
99  if (module >= c_numModules) {
100  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
101  return 0;
102  }
103  if (channel >= c_numChannels) {
104  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
105  return 0;
106  }
107  if (m_status[module][channel] == c_Default) return 1.0;
108  return m_ThrEff[module][channel];
109  }
110 
117  bool isCalibrated(int moduleID, unsigned channel) const
118  {
119  unsigned module = moduleID - 1;
120  if (module >= c_numModules) return false;
121  if (channel >= c_numChannels) return false;
122  return m_status[module][channel] == c_Calibrated;
123  }
124 
131  bool isDefault(int moduleID, unsigned channel) const
132  {
133  unsigned module = moduleID - 1;
134  if (module >= c_numModules) return false;
135  if (channel >= c_numChannels) return false;
136  return m_status[module][channel] == c_Default;
137  }
138 
145  bool isUnusable(int moduleID, unsigned channel) const
146  {
147  unsigned module = moduleID - 1;
148  if (module >= c_numModules) return false;
149  if (channel >= c_numChannels) return false;
150  return m_status[module][channel] == c_Unusable;
151  }
152 
159  short getOfflineThreshold(int moduleID, unsigned channel) const
160  {
161  unsigned module = moduleID - 1;
162  if (module >= c_numModules) {
163  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
164  return 0;
165  }
166  if (channel >= c_numChannels) {
167  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
168  return 0;
169  }
170  return m_offlineThreshold[module][channel];
171  }
172 
173  private:
174 
178  enum {c_numModules = 16,
179  c_numChannels = 512
180  };
181 
182 
183  float m_ThrEff[c_numModules][c_numChannels] = {{0}};
189  };
190 
192 } // end namespace Belle2
193 
Belle2::TOPCalChannelThresholdEff::c_Calibrated
@ c_Calibrated
good calibrated value
Definition: TOPCalChannelThresholdEff.h:46
Belle2::TOPCalChannelThresholdEff::setThrEff
void setThrEff(int moduleID, unsigned channel, float ThrEff, short offlineThreshold)
Sets the threshold efficiency and correspolding threshold for a single channel and switches status to...
Definition: TOPCalChannelThresholdEff.h:64
Belle2::TOPCalChannelThresholdEff::ClassDef
ClassDef(TOPCalChannelThresholdEff, 3)
ClassDef.
Belle2::TOPCalChannelThresholdEff::EStatus
EStatus
Calibration status of a constant.
Definition: TOPCalChannelThresholdEff.h:44
Belle2::TOPCalChannelThresholdEff::c_numModules
@ c_numModules
number of modules
Definition: TOPCalChannelThresholdEff.h:187
Belle2::TOPCalChannelThresholdEff::c_Default
@ c_Default
uncalibrated default value
Definition: TOPCalChannelThresholdEff.h:45
Belle2::TOPCalChannelThresholdEff::m_status
EStatus m_status[c_numModules][c_numChannels]
calibration status
Definition: TOPCalChannelThresholdEff.h:193
Belle2::TOPCalChannelThresholdEff::isDefault
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelThresholdEff.h:140
Belle2::TOPCalChannelThresholdEff::getThrEff
float getThrEff(int moduleID, unsigned channel) const
Returns the threshold efficiency of a single channel (1.0 if status is c_Default)
Definition: TOPCalChannelThresholdEff.h:105
Belle2::TOPCalChannelThresholdEff::isUnusable
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelThresholdEff.h:154
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPCalChannelThresholdEff
Class to store the threshold efficiency (i.e.
Definition: TOPCalChannelThresholdEff.h:38
Belle2::TOPCalChannelThresholdEff::setUnusable
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
Definition: TOPCalChannelThresholdEff.h:85
Belle2::TOPCalChannelThresholdEff::getOfflineThreshold
short getOfflineThreshold(int moduleID, unsigned channel) const
Returns the threshold value used for efficiency evaluation.
Definition: TOPCalChannelThresholdEff.h:168
Belle2::TOPCalChannelThresholdEff::isCalibrated
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelThresholdEff.h:126
Belle2::TOPCalChannelThresholdEff::TOPCalChannelThresholdEff
TOPCalChannelThresholdEff()
Default constructor.
Definition: TOPCalChannelThresholdEff.h:54
Belle2::TOPCalChannelThresholdEff::m_offlineThreshold
short m_offlineThreshold[c_numModules][c_numChannels]
threshold value used for efficiency evaluation
Definition: TOPCalChannelThresholdEff.h:194
Belle2::TOPCalChannelThresholdEff::c_Unusable
@ c_Unusable
bad calibrated value
Definition: TOPCalChannelThresholdEff.h:47
Belle2::TOPCalChannelThresholdEff::c_numChannels
@ c_numChannels
number of channels per module
Definition: TOPCalChannelThresholdEff.h:188
Belle2::TOPCalChannelThresholdEff::m_ThrEff
float m_ThrEff[c_numModules][c_numChannels]
threshold efficiency value.
Definition: TOPCalChannelThresholdEff.h:192