Belle II Software  release-05-01-25
TOPCalChannelT0.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - 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 #include <top/dbobjects/TOPCalChannelT0.h>
12 #include <framework/logging/Logger.h>
13 
14 using namespace std;
15 
16 namespace Belle2 {
22  void TOPCalChannelT0::setT0(int moduleID, unsigned channel, double T0, double errT0)
23  {
24  unsigned module = moduleID - 1;
25  if (module >= c_numModules) {
26  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
27  return;
28  }
29  if (channel >= c_numChannels) {
30  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
31  return;
32  }
33  m_T0[module][channel] = T0;
34  m_errT0[module][channel] = errT0;
35  m_status[module][channel] = c_Calibrated;
36  }
37 
38 
39  void TOPCalChannelT0::setUnusable(int moduleID, unsigned channel)
40  {
41  unsigned module = moduleID - 1;
42  if (module >= c_numModules) {
43  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
44  return;
45  }
46  if (channel >= c_numChannels) {
47  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
48  return;
49  }
50  m_status[module][channel] = c_Unusable;
51  }
52 
53 
54  void TOPCalChannelT0::suppressAverage()
55  {
56  for (int m = 0; m < c_numModules; m++) {
57  float s = 0;
58  int n = 0;
59  for (int i = 0; i < c_numChannels; i++) {
60  if (m_status[m][i] == c_Calibrated) {
61  s += m_T0[m][i];
62  n++;
63  }
64  }
65  if (n == 0) continue;
66  s /= n;
67  for (int i = 0; i < c_numChannels; i++) {
68  if (m_status[m][i] != c_Default) m_T0[m][i] -= s;
69  }
70  B2INFO("Slot " << m + 1 << ": average of " << s << " ns subtracted.");
71  }
72  }
73 
74 
75  double TOPCalChannelT0::getT0(int moduleID, unsigned channel) const
76  {
77  unsigned module = moduleID - 1;
78  if (module >= c_numModules) {
79  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
80  return 0;
81  }
82  if (channel >= c_numChannels) {
83  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
84  return 0;
85  }
86  return m_T0[module][channel];
87  }
88 
89 
90  double TOPCalChannelT0::getT0Error(int moduleID, unsigned channel) const
91  {
92  unsigned module = moduleID - 1;
93  if (module >= c_numModules) {
94  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
95  return 0;
96  }
97  if (channel >= c_numChannels) {
98  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
99  return 0;
100  }
101  return m_errT0[module][channel];
102  }
103 
104 
105  bool TOPCalChannelT0::isCalibrated(int moduleID, unsigned channel) const
106  {
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;
111  }
112 
113 
114  bool TOPCalChannelT0::isDefault(int moduleID, unsigned channel) const
115  {
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;
120  }
121 
122 
123  bool TOPCalChannelT0::isUnusable(int moduleID, unsigned channel) const
124  {
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;
129  }
130 
131 
133 } // end Belle2 namespace
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19