Belle II Software development
TOPCalChannelPulseHeight.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#include <top/dbobjects/TOPPulseHeightPar.h>
14
15namespace Belle2 {
26 class TOPCalChannelPulseHeight: public TObject {
27 public:
28
32 enum EStatus {
35 c_Unusable = 2
36 };
37
42 {}
43
52 void setParameters(int moduleID, unsigned channel, double x0, double p1, double p2)
53 {
54 unsigned module = moduleID - 1;
55 if (module >= c_numModules) {
56 B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
57 return;
58 }
59 if (channel >= c_numChannels) {
60 B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
61 return;
62 }
63 if (x0 <= 0) {
64 B2ERROR("Invalid parameter value x0, constant not set (" << ClassName() << ")."
65 << LogVar("x0", x0)
66 << LogVar("slot", moduleID)
67 << LogVar("channel", channel));
68 return;
69 }
70 if (p1 < 0) {
71 B2ERROR("Invalid parameter value p1, constant not set (" << ClassName() << ")."
72 << LogVar("p1", p1)
73 << LogVar("slot", moduleID)
74 << LogVar("channel", channel));
75 return;
76 }
77 if (p2 <= 0) {
78 B2ERROR("Invalid parameter value p2, constant not set (" << ClassName() << ")."
79 << LogVar("p2", p2)
80 << LogVar("slot", moduleID)
81 << LogVar("channel", channel));
82 return;
83 }
84 m_par[module][channel].x0 = x0;
85 m_par[module][channel].p1 = p1;
86 m_par[module][channel].p2 = p2;
87 m_status[module][channel] = c_Calibrated;
88 }
89
95 void setUnusable(int moduleID, unsigned channel)
96 {
97 unsigned module = moduleID - 1;
98 if (module >= c_numModules) {
99 B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
100 return;
101 }
102 if (channel >= c_numChannels) {
103 B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
104 return;
105 }
106 m_status[module][channel] = c_Unusable;
107 }
108
115 const TOPPulseHeightPar& getParameters(int moduleID, unsigned channel) const
116 {
117 unsigned module = moduleID - 1;
118 if (module >= c_numModules) {
119 B2WARNING("Invalid slot number, "
120 "returning parameters of slot 1 channel 0 (" << ClassName() << ")"
121 << LogVar("slot", moduleID));
122 return m_par[0][0];
123 }
124 if (channel >= c_numChannels) {
125 B2WARNING("Invalid channel, "
126 "returning parameters of channel 0 (" << ClassName() << ")"
127 << LogVar("channel", channel));
128 return m_par[module][0];
129 }
130 return m_par[module][channel];
131 }
132
139 bool isCalibrated(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_Calibrated;
145 }
146
153 bool isDefault(int moduleID, unsigned channel) const
154 {
155 unsigned module = moduleID - 1;
156 if (module >= c_numModules) return false;
157 if (channel >= c_numChannels) return false;
158 return m_status[module][channel] == c_Default;
159 }
160
167 bool isUnusable(int moduleID, unsigned channel) const
168 {
169 unsigned module = moduleID - 1;
170 if (module >= c_numModules) return false;
171 if (channel >= c_numChannels) return false;
172 return m_status[module][channel] == c_Unusable;
173 }
174
175
176 private:
177
181 enum {
183 c_numChannels = 512
184 };
185
191 };
192
194} // end namespace Belle2
195
Pulse height parameterizations for all 512 channels of 16 modules.
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
const TOPPulseHeightPar & getParameters(int moduleID, unsigned channel) const
Returns pulse height parameters for a given slot and channel.
TOPPulseHeightPar m_par[c_numModules][c_numChannels]
calibration constants
ClassDef(TOPCalChannelPulseHeight, 3)
ClassDef.
TOPCalChannelPulseHeight()
Default constructor.
void setParameters(int moduleID, unsigned channel, double x0, double p1, double p2)
Sets calibration for a single channel and switches status to calibrated.
EStatus m_status[c_numModules][c_numChannels]
calibration status
@ c_numChannels
number of channels per module
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
EStatus
Calibration status of a constant.
@ c_Default
uncalibrated default value
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.
Struct holding the pulse height parameterizations for the TOP counter.
float p1
distribution parameter p1
float x0
distribution parameter x0 [ADC counts]
float p2
distribution parameter p2