9 #include <top/dataobjects/TOPRawDigit.h>
11 #include <framework/logging/Logger.h>
23 bool TOPRawDigit::isPedestalJump()
const
25 if (m_sampleRise == 0) {
26 if ((m_dSampleFall + 1) % 64 == 0)
return true;
27 }
else if ((m_sampleRise + 1) % 64 == 0) {
28 if (m_dSampleFall % 64 == 0)
return true;
34 bool TOPRawDigit::isAtWindowDiscontinuity(
unsigned short storageDepth)
const
36 if (m_windows.empty())
return false;
38 unsigned size = m_windows.size();
39 unsigned i0 = getSampleRise() / c_WindowSize;
40 if (i0 >= size) i0 = size - 1;
41 unsigned i1 = (getSampleFall() + 1) / c_WindowSize;
42 if (i1 >= size) i1 = size - 1;
43 if (i0 == i1)
return false;
45 int diff = m_windows[i1] - m_windows[i0];
46 if (diff < 0) diff += storageDepth;
47 if (diff != 1)
return true;
52 bool TOPRawDigit::areWindowsInOrder(
unsigned short storageDepth)
const
54 unsigned lastSample = getSampleFall() + 1;
55 unsigned last = lastSample / c_WindowSize + 1;
56 unsigned size = m_windows.size();
57 for (
unsigned i = 1; i < std::min(last, size); i++) {
58 int diff = m_windows[i] - m_windows[i - 1];
59 if (diff < 0) diff += storageDepth;
60 if (diff != 1)
return false;
66 double TOPRawDigit::correctTime(
double time,
unsigned short storageDepth)
const
68 if (m_windows.empty())
return time;
70 unsigned last = int(time) / c_WindowSize + 1;
71 unsigned size = m_windows.size();
73 for (
unsigned i = 1; i < std::min(last, size); i++) {
74 int diff = m_windows[i] - m_windows[i - 1];
75 if (diff < 0) diff += storageDepth;
76 if (diff != 1) missing += diff - 1;
77 if (diff == 0) B2ERROR(
"TOPRawDigit: two consecutive windows with the same number");
80 return time + missing * c_WindowSize;
84 double TOPRawDigit::timeErrorCoefficient(
double y1,
double y2)
const
87 double ym = m_VPeak / 2.0;
88 double a = 1.0 / (2.0 * dy);
89 double b = (ym - y2) / (dy * dy);
90 double c = (ym - y1) / (dy * dy);
92 return sqrt(a * a + b * b + c * c);
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.