Belle II Software development
TOPCalModuleT0.cc
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#include <top/dbobjects/TOPCalModuleT0.h>
10#include <framework/logging/Logger.h>
11
12using namespace std;
13
14namespace Belle2 {
20 void TOPCalModuleT0::setT0(int moduleID, double T0, double errT0)
21 {
22 unsigned module = moduleID - 1;
23 if (module >= c_numModules) {
24 B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
25 return;
26 }
27 m_T0[module] = T0;
28 m_errT0[module] = errT0;
29 m_status[module] = c_Calibrated;
30 }
31
32
33 void TOPCalModuleT0::setUnusable(int moduleID)
34 {
35 unsigned module = moduleID - 1;
36 if (module >= c_numModules) {
37 B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
38 return;
39 }
40 m_status[module] = c_Unusable;
41 }
42
43
45 {
46 float s = 0;
47 int n = 0;
48 for (int i = 0; i < c_numModules; i++) {
49 if (m_status[i] == c_Calibrated) {
50 s += m_T0[i];
51 n++;
52 }
53 }
54 if (n == 0) return;
55 s /= n;
56 for (int i = 0; i < c_numModules; i++) {
57 if (m_status[i] != c_Default) m_T0[i] -= s;
58 }
59 B2INFO("Average of " << s << " ns subtracted.");
60 }
61
62
63 double TOPCalModuleT0::getT0(int moduleID) const
64 {
65 unsigned module = moduleID - 1;
66 if (module >= c_numModules) {
67 B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
68 return 0;
69 }
70 return m_T0[module];
71 }
72
73
74 double TOPCalModuleT0::getT0Error(int moduleID) const
75 {
76 unsigned module = moduleID - 1;
77 if (module >= c_numModules) {
78 B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
79 return 0;
80 }
81 return m_errT0[module];
82 }
83
84
85 bool TOPCalModuleT0::isCalibrated(int moduleID) const
86 {
87 unsigned module = moduleID - 1;
88 if (module >= c_numModules) return false;
89 return m_status[module] == c_Calibrated;
90 }
91
92
93 bool TOPCalModuleT0::isDefault(int moduleID) const
94 {
95 unsigned module = moduleID - 1;
96 if (module >= c_numModules) return false;
97 return m_status[module] == c_Default;
98 }
99
100
101 bool TOPCalModuleT0::isUnusable(int moduleID) const
102 {
103 unsigned module = moduleID - 1;
104 if (module >= c_numModules) return false;
105 return m_status[module] == c_Unusable;
106 }
107
108
110} // end Belle2 namespace
111
112
float m_errT0[c_numModules]
errors on constants
EStatus m_status[c_numModules]
calibration status
float m_T0[c_numModules]
calibration constants
@ c_numModules
number of modules
@ c_Calibrated
good calibrated value
@ c_Unusable
bad calibrated value
@ c_Default
uncalibrated default value
bool isCalibrated(int moduleID) const
Returns calibration status.
void suppressAverage()
Subtracts arithmetic average from constants whose status is not c_Default.
double getT0Error(int moduleID) const
Returns error on T0 of a module.
void setUnusable(int moduleID)
Switches calibration status to unusable to flag badly calibrated constant.
bool isDefault(int moduleID) const
Returns calibration status.
bool isUnusable(int moduleID) const
Returns calibration status.
void setT0(int moduleID, double T0, double errT0)
Sets calibration for a single module and switches status to calibrated.
double getT0(int moduleID) const
Returns T0 of a module.
Abstract base class for different kinds of events.
STL namespace.