Belle II Software  release-05-02-19
TOPCalChannelPulseHeight.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 #include <top/dbobjects/TOPPulseHeightPar.h>
16 
17 namespace Belle2 {
28  class TOPCalChannelPulseHeight: public TObject {
29  public:
30 
34  enum EStatus {
35  c_Default = 0,
37  c_Unusable = 2
38  };
39 
44  {}
45 
54  void setParameters(int moduleID, unsigned channel, double x0, double p1, double p2)
55  {
56  unsigned module = moduleID - 1;
57  if (module >= c_numModules) {
58  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
59  return;
60  }
61  if (channel >= c_numChannels) {
62  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
63  return;
64  }
65  if (x0 <= 0) {
66  B2ERROR("Invalid parameter value x0, constant not set (" << ClassName() << ")."
67  << LogVar("x0", x0)
68  << LogVar("slot", moduleID)
69  << LogVar("channel", channel));
70  return;
71  }
72  if (p1 < 0) {
73  B2ERROR("Invalid parameter value p1, constant not set (" << ClassName() << ")."
74  << LogVar("p1", p1)
75  << LogVar("slot", moduleID)
76  << LogVar("channel", channel));
77  return;
78  }
79  if (p2 <= 0) {
80  B2ERROR("Invalid parameter value p2, constant not set (" << ClassName() << ")."
81  << LogVar("p2", p2)
82  << LogVar("slot", moduleID)
83  << LogVar("channel", channel));
84  return;
85  }
86  m_par[module][channel].x0 = x0;
87  m_par[module][channel].p1 = p1;
88  m_par[module][channel].p2 = p2;
89  m_status[module][channel] = c_Calibrated;
90  }
91 
97  void setUnusable(int moduleID, unsigned channel)
98  {
99  unsigned module = moduleID - 1;
100  if (module >= c_numModules) {
101  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
102  return;
103  }
104  if (channel >= c_numChannels) {
105  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
106  return;
107  }
108  m_status[module][channel] = c_Unusable;
109  }
110 
117  const TOPPulseHeightPar& getParameters(int moduleID, unsigned channel) const
118  {
119  unsigned module = moduleID - 1;
120  if (module >= c_numModules) {
121  B2WARNING("Invalid slot number, "
122  "returning parameters of slot 1 channel 0 (" << ClassName() << ")"
123  << LogVar("slot", moduleID));
124  return m_par[0][0];
125  }
126  if (channel >= c_numChannels) {
127  B2WARNING("Invalid channel, "
128  "returning parameters of channel 0 (" << ClassName() << ")"
129  << LogVar("channel", channel));
130  return m_par[module][0];
131  }
132  return m_par[module][channel];
133  }
134 
141  bool isCalibrated(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_Calibrated;
147  }
148 
155  bool isDefault(int moduleID, unsigned channel) const
156  {
157  unsigned module = moduleID - 1;
158  if (module >= c_numModules) return false;
159  if (channel >= c_numChannels) return false;
160  return m_status[module][channel] == c_Default;
161  }
162 
169  bool isUnusable(int moduleID, unsigned channel) const
170  {
171  unsigned module = moduleID - 1;
172  if (module >= c_numModules) return false;
173  if (channel >= c_numChannels) return false;
174  return m_status[module][channel] == c_Unusable;
175  }
176 
177 
178  private:
179 
183  enum {
184  c_numModules = 16,
185  c_numChannels = 512
186  };
187 
193  };
194 
196 } // end namespace Belle2
197 
Belle2::TOPCalChannelPulseHeight::isUnusable
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelPulseHeight.h:177
Belle2::TOPCalChannelPulseHeight::m_par
TOPPulseHeightPar m_par[c_numModules][c_numChannels]
calibration constants
Definition: TOPCalChannelPulseHeight.h:196
Belle2::TOPCalChannelPulseHeight::c_numModules
@ c_numModules
number of modules
Definition: TOPCalChannelPulseHeight.h:192
Belle2::TOPCalChannelPulseHeight::TOPCalChannelPulseHeight
TOPCalChannelPulseHeight()
Default constructor.
Definition: TOPCalChannelPulseHeight.h:51
Belle2::TOPCalChannelPulseHeight::c_Default
@ c_Default
uncalibrated default value
Definition: TOPCalChannelPulseHeight.h:43
Belle2::TOPCalChannelPulseHeight::m_status
EStatus m_status[c_numModules][c_numChannels]
calibration status
Definition: TOPCalChannelPulseHeight.h:197
Belle2::TOPCalChannelPulseHeight::ClassDef
ClassDef(TOPCalChannelPulseHeight, 3)
ClassDef.
Belle2::TOPCalChannelPulseHeight::c_Calibrated
@ c_Calibrated
good calibrated value
Definition: TOPCalChannelPulseHeight.h:44
Belle2::TOPCalChannelPulseHeight::EStatus
EStatus
Calibration status of a constant.
Definition: TOPCalChannelPulseHeight.h:42
Belle2::TOPPulseHeightPar
Struct holding the pulse height parameterizations for the TOP counter.
Definition: TOPPulseHeightPar.h:31
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPCalChannelPulseHeight::setUnusable
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
Definition: TOPCalChannelPulseHeight.h:105
Belle2::TOPPulseHeightPar::p1
float p1
distribution parameter p1
Definition: TOPPulseHeightPar.h:33
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::TOPPulseHeightPar::p2
float p2
distribution parameter p2
Definition: TOPPulseHeightPar.h:34
Belle2::TOPCalChannelPulseHeight::isDefault
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelPulseHeight.h:163
Belle2::TOPCalChannelPulseHeight::isCalibrated
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalChannelPulseHeight.h:149
Belle2::TOPCalChannelPulseHeight::c_numChannels
@ c_numChannels
number of channels per module
Definition: TOPCalChannelPulseHeight.h:193
Belle2::TOPCalChannelPulseHeight::setParameters
void setParameters(int moduleID, unsigned channel, double x0, double p1, double p2)
Sets calibration for a single channel and switches status to calibrated.
Definition: TOPCalChannelPulseHeight.h:62
Belle2::TOPCalChannelPulseHeight::c_Unusable
@ c_Unusable
bad calibrated value
Definition: TOPCalChannelPulseHeight.h:45
Belle2::TOPPulseHeightPar::x0
float x0
distribution parameter x0 [ADC counts]
Definition: TOPPulseHeightPar.h:32
Belle2::TOPCalChannelPulseHeight::getParameters
const TOPPulseHeightPar & getParameters(int moduleID, unsigned channel) const
Returns pulse height parameters for a given slot and channel.
Definition: TOPCalChannelPulseHeight.h:125