9 #include <top/dataobjects/TOPRawWaveform.h>
19 int TOPRawWaveform::getIntegral(
int sampleRise,
int samplePeak,
int sampleFall)
const
21 sampleRise -= m_startSample;
22 samplePeak -= m_startSample;
23 sampleFall -= m_startSample;
25 return Integral(sampleRise, samplePeak, sampleFall);
28 int TOPRawWaveform::Integral(
int sampleRise,
int samplePeak,
int sampleFall)
const
30 int min = samplePeak - 3 * (samplePeak - sampleRise);
32 int max = samplePeak + 4 * (sampleFall + 1 - samplePeak);
33 int size = m_data.size();
34 if (max > size) max = size;
37 integral += m_data[min];
44 int TOPRawWaveform::featureExtraction(
int threshold,
int hysteresis,
45 int thresholdCount)
const
50 int currentThr = threshold;
51 bool lastState =
false;
53 int size = m_data.size();
55 for (
int i = 0; i < size; i++) {
56 const auto& adc = m_data[i];
57 if (adc > currentThr and i < size - 1) {
58 currentThr = threshold - hysteresis;
59 if (!lastState or adc > m_data[samplePeak]) samplePeak = i;
63 currentThr = threshold;
64 if (lastState and aboveThr >= thresholdCount) {
65 auto halfValue = m_data[samplePeak] / 2;
66 auto sampleRise = samplePeak;
67 while (sampleRise > 0 and m_data[sampleRise] > halfValue) sampleRise--;
68 if (sampleRise == 0 and m_data[sampleRise] > halfValue)
continue;
69 auto sampleFall = samplePeak;
70 while (sampleFall < size - 1 and m_data[sampleFall] > halfValue) sampleFall++;
71 if (sampleFall == size - 1 and m_data[sampleFall] > halfValue)
continue;
74 feature.
sampleRise = sampleRise + m_startSample;
75 feature.
samplePeak = samplePeak + m_startSample;
76 feature.
sampleFall = sampleFall + m_startSample;
77 feature.
vRise0 = m_data[sampleRise];
78 feature.
vRise1 = m_data[sampleRise + 1];
79 feature.
vPeak = m_data[samplePeak];
80 feature.
vFall0 = m_data[sampleFall];
81 feature.
vFall1 = m_data[sampleFall + 1];
82 feature.
integral = Integral(sampleRise, samplePeak, sampleFall);
83 m_features.push_back(feature);
90 return m_features.size();
Abstract base class for different kinds of events.