Line data Source code
1 : /**
2 : * @file TAMakerSupernovaAlgorithm.cpp
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "triggeralgs/Supernova/TAMakerSupernovaAlgorithm.hpp"
10 :
11 : #include "TRACE/trace.h"
12 : #define TRACE_NAME "TAMakerSupernovaAlgorithm"
13 :
14 : #include <chrono>
15 : #include <vector>
16 :
17 : using pd_clock = std::chrono::duration<double, std::ratio<1, 62500000>>;
18 : using namespace triggeralgs;
19 :
20 : void
21 0 : TAMakerSupernovaAlgorithm::process(const TriggerPrimitive& input_tp, std::vector<TriggerActivity>& output_ta)
22 : {
23 : // Time measurement
24 : // auto now = std::chrono::steady_clock::now();
25 : // m_algorithm = (uint32_t)pd_clock(now.time_since_epoch()).count();
26 :
27 0 : timestamp_t tend = input_tp.time_start + input_tp.samples_over_threshold * 32; // FIXME: Replace the hard-coded SOT to TOT scaling.
28 :
29 0 : if (m_time_start == 0) {
30 0 : m_tp_list.erase(m_tp_list.begin(), m_tp_list.end());
31 0 : m_tp_list.push_back(input_tp);
32 0 : m_time_start = input_tp.time_start;
33 0 : m_time_end = tend;
34 0 : m_time_peak = input_tp.samples_to_peak * 32 + input_tp.time_start; // FIXME: Replace STP to `time_peak` conversion.
35 0 : m_channel_start = input_tp.channel;
36 0 : m_channel_end = input_tp.channel;
37 0 : m_channel_peak = input_tp.channel;
38 0 : m_adc_integral = input_tp.adc_integral;
39 0 : m_adc_peak = input_tp.adc_peak;
40 0 : m_detid = input_tp.detid;
41 0 : return;
42 : }
43 :
44 0 : bool time_ok = is_time_consistent(input_tp);
45 0 : bool channel_ok = is_channel_consistent(input_tp);
46 :
47 0 : if (!time_ok && !channel_ok) {
48 0 : output_ta.push_back(MakeTriggerActivity());
49 0 : m_tp_list.erase(m_tp_list.begin(), m_tp_list.end());
50 0 : m_tp_list.push_back(input_tp);
51 0 : m_time_start = input_tp.time_start;
52 0 : m_time_end = tend;
53 0 : m_time_peak = input_tp.samples_to_peak * 32 + input_tp.time_start; // FIXME: Replace STP to `time_peak` conversion.
54 0 : m_channel_start = input_tp.channel;
55 0 : m_channel_end = input_tp.channel;
56 0 : m_channel_peak = input_tp.channel;
57 0 : m_adc_integral = input_tp.adc_integral;
58 0 : m_adc_peak = input_tp.adc_peak;
59 0 : m_detid = input_tp.detid;
60 0 : return;
61 : }
62 :
63 0 : if (input_tp.time_start < m_time_start)
64 0 : m_time_start = input_tp.time_start;
65 :
66 0 : if (tend > m_time_end)
67 0 : m_time_end = tend;
68 :
69 0 : if (input_tp.adc_peak > m_adc_peak) {
70 0 : m_time_peak = input_tp.samples_to_peak * 32 + input_tp.time_start; // FIXME: Replace STP to `time_peak` conversion.
71 0 : m_adc_peak = input_tp.adc_peak;
72 0 : m_channel_peak = input_tp.channel;
73 : }
74 :
75 0 : if (input_tp.channel > m_channel_end)
76 0 : m_channel_end = input_tp.channel;
77 :
78 0 : if (input_tp.channel < m_channel_start)
79 0 : m_channel_start = input_tp.channel;
80 :
81 0 : m_tp_list.push_back(input_tp);
82 0 : m_adc_integral += input_tp.adc_integral;
83 0 : m_detid |= input_tp.detid;
84 : }
85 :
86 : // Register algo in TA Factory
87 12 : REGISTER_TRIGGER_ACTIVITY_MAKER(TRACE_NAME, TAMakerSupernovaAlgorithm)
|