Belle II Software  release-08-01-10
TOPASICGains.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/TOPASICGains.h>
10 #include <framework/logging/Logger.h>
11 
12 using namespace std;
13 
14 namespace Belle2 {
20  bool TOPASICGains::setGains(const std::vector<float>& gains, float error)
21  {
22 
23  if (gains.size() != c_WindowSize) {
24  B2ERROR("TOPASICGains::setGains: vector with wrong number of elements");
25  return false;
26  }
27 
28  for (int i = 0; i < c_WindowSize; i++) {
29  float gain = gains[i] * m_unit;
30  if (gain > 0 and (gain + 0.5) < 0x10000) {
31  m_gains[i] = int(gain + 0.5);
32  } else {
33  return false;
34  }
35  }
36  error *= m_unit;
37  m_gainError = int(error + 0.5);
38  return true;
39 
40  }
41 
43 } // end Belle2 namespace
44 
Abstract base class for different kinds of events.