Belle II Software  release-08-01-10
TOPTemplateFitResult.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/dataobjects/TOPTemplateFitResult.h>
10 #include <math.h>
11 
12 using namespace std;
13 
14 namespace Belle2 {
20  TOPTemplateFitResult::TOPTemplateFitResult() {}
21 
22  TOPTemplateFitResult::TOPTemplateFitResult(short risingEdge, short backgroundOffset,
23  short amplitude, short chisquare)
24  {
25  m_risingEdgeRaw = risingEdge;
26  m_risingEdge = risingEdgeShortToRisingEdgeDouble(risingEdge);
27  m_backgroundOffset = backgroundOffset;
28  m_amplitude = amplitude;
29  m_chisquare = chisquare;
30  m_risingEdgeTime = -1.;
31  }
32 
33  TOPTemplateFitResult::TOPTemplateFitResult(double risingEdge, double risingEdgeTime, double backgroundOffset,
34  double amplitude, double chisquare)
35  : m_risingEdge(risingEdge), m_risingEdgeTime(risingEdgeTime), m_backgroundOffset(backgroundOffset), m_amplitude(amplitude),
36  m_chisquare(chisquare)
37  {
38  m_risingEdgeRaw = -1;
39  }
40 
41  void TOPTemplateFitResult::setRisingEdgeAndConvert(unsigned short risingEdge)
42  {
43  m_risingEdgeRaw = risingEdge;
45  }
46 
47  double TOPTemplateFitResult::risingEdgeShortToRisingEdgeDouble(unsigned short risingEdgeS) const
48  {
49  double risingEdgeD = (risingEdgeS & 0xff00) >> 8;
50  int mask = 0x80;
51  for (int i = 0; i < 8; i++) {
52  int b = (risingEdgeS & mask);
53  if (b != 0) risingEdgeD += 1. / (pow(2, i + 1));
54  mask = mask >> 1;
55  }
56  return risingEdgeD;
57  }
58 
60 } // end Belle2 namespace
double m_risingEdge
template fit rising edge position
unsigned m_risingEdgeRaw
template fit rising edge position received from FEE
double risingEdgeShortToRisingEdgeDouble(unsigned short risingEdgeS) const
Convert rising edge saved in short to double.
void setRisingEdgeAndConvert(unsigned short risingEdge)
Sets rising edge from Zynq and converts to double This does not convert from sample to time space.
Abstract base class for different kinds of events.