11 #include <top/dbobjects/TOPCalChannelT0.h>
12 #include <framework/logging/Logger.h>
22 void TOPCalChannelT0::setT0(
int moduleID,
unsigned channel,
double T0,
double errT0)
24 unsigned module = moduleID - 1;
25 if (module >= c_numModules) {
26 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
29 if (channel >= c_numChannels) {
30 B2ERROR(
"Invalid channel number, constant not set (" << ClassName() <<
")");
33 m_T0[module][channel] = T0;
34 m_errT0[module][channel] = errT0;
35 m_status[module][channel] = c_Calibrated;
39 void TOPCalChannelT0::setUnusable(
int moduleID,
unsigned channel)
41 unsigned module = moduleID - 1;
42 if (module >= c_numModules) {
43 B2ERROR(
"Invalid module number, status not set (" << ClassName() <<
")");
46 if (channel >= c_numChannels) {
47 B2ERROR(
"Invalid channel number, status not set (" << ClassName() <<
")");
50 m_status[module][channel] = c_Unusable;
54 void TOPCalChannelT0::suppressAverage()
56 for (
int m = 0; m < c_numModules; m++) {
59 for (
int i = 0; i < c_numChannels; i++) {
60 if (m_status[m][i] == c_Calibrated) {
67 for (
int i = 0; i < c_numChannels; i++) {
68 if (m_status[m][i] != c_Default) m_T0[m][i] -= s;
70 B2INFO(
"Slot " << m + 1 <<
": average of " << s <<
" ns subtracted.");
75 double TOPCalChannelT0::getT0(
int moduleID,
unsigned channel)
const
77 unsigned module = moduleID - 1;
78 if (module >= c_numModules) {
79 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
82 if (channel >= c_numChannels) {
83 B2WARNING(
"Invalid channel number, returning 0 (" << ClassName() <<
")");
86 return m_T0[module][channel];
90 double TOPCalChannelT0::getT0Error(
int moduleID,
unsigned channel)
const
92 unsigned module = moduleID - 1;
93 if (module >= c_numModules) {
94 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
97 if (channel >= c_numChannels) {
98 B2WARNING(
"Invalid channel number, returning 0 (" << ClassName() <<
")");
101 return m_errT0[module][channel];
105 bool TOPCalChannelT0::isCalibrated(
int moduleID,
unsigned channel)
const
107 unsigned module = moduleID - 1;
108 if (module >= c_numModules)
return false;
109 if (channel >= c_numChannels)
return false;
110 return m_status[module][channel] == c_Calibrated;
114 bool TOPCalChannelT0::isDefault(
int moduleID,
unsigned channel)
const
116 unsigned module = moduleID - 1;
117 if (module >= c_numModules)
return false;
118 if (channel >= c_numChannels)
return false;
119 return m_status[module][channel] == c_Default;
123 bool TOPCalChannelT0::isUnusable(
int moduleID,
unsigned channel)
const
125 unsigned module = moduleID - 1;
126 if (module >= c_numModules)
return false;
127 if (channel >= c_numChannels)
return false;
128 return m_status[module][channel] == c_Unusable;