Belle II Software development
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
12using namespace std;
13
14namespace 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
unsigned short m_gains[c_WindowSize]
gains (in fixed point format)
Definition: TOPASICGains.h:98
@ c_WindowSize
number of samples
Definition: TOPASICGains.h:28
unsigned short m_gainError
gain error (fixed point format)
Definition: TOPASICGains.h:97
unsigned short m_unit
unit of fixed point number
Definition: TOPASICGains.h:96
bool setGains(const std::vector< float > &gains, float error=0)
Set gains.
Definition: TOPASICGains.cc:20
Abstract base class for different kinds of events.
STL namespace.