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