DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TAMakerSupernovaAlgorithm.cpp
Go to the documentation of this file.
1
10
11#include "TRACE/trace.h"
12#define TRACE_NAME "TAMakerSupernovaAlgorithm"
13
14#include <chrono>
15#include <vector>
16
17using pd_clock = std::chrono::duration<double, std::ratio<1, 62500000>>;
18using namespace triggeralgs;
19
20void
21TAMakerSupernovaAlgorithm::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 timestamp_t tend = input_tp.time_start + input_tp.samples_over_threshold * 32; // FIXME: Replace the hard-coded SOT to TOT scaling.
28
29 if (m_time_start == 0) {
30 m_tp_list.erase(m_tp_list.begin(), m_tp_list.end());
31 m_tp_list.push_back(input_tp);
32 m_time_start = input_tp.time_start;
33 m_time_end = tend;
34 m_time_peak = input_tp.samples_to_peak * 32 + input_tp.time_start; // FIXME: Replace STP to `time_peak` conversion.
35 m_channel_start = input_tp.channel;
36 m_channel_end = input_tp.channel;
37 m_channel_peak = input_tp.channel;
39 m_adc_peak = input_tp.adc_peak;
40 m_detid = input_tp.detid;
41 return;
42 }
43
44 bool time_ok = is_time_consistent(input_tp);
45 bool channel_ok = is_channel_consistent(input_tp);
46
47 if (!time_ok && !channel_ok) {
48 output_ta.push_back(MakeTriggerActivity());
49 m_tp_list.erase(m_tp_list.begin(), m_tp_list.end());
50 m_tp_list.push_back(input_tp);
51 m_time_start = input_tp.time_start;
52 m_time_end = tend;
53 m_time_peak = input_tp.samples_to_peak * 32 + input_tp.time_start; // FIXME: Replace STP to `time_peak` conversion.
54 m_channel_start = input_tp.channel;
55 m_channel_end = input_tp.channel;
56 m_channel_peak = input_tp.channel;
58 m_adc_peak = input_tp.adc_peak;
59 m_detid = input_tp.detid;
60 return;
61 }
62
63 if (input_tp.time_start < m_time_start)
64 m_time_start = input_tp.time_start;
65
66 if (tend > m_time_end)
67 m_time_end = tend;
68
69 if (input_tp.adc_peak > m_adc_peak) {
70 m_time_peak = input_tp.samples_to_peak * 32 + input_tp.time_start; // FIXME: Replace STP to `time_peak` conversion.
71 m_adc_peak = input_tp.adc_peak;
72 m_channel_peak = input_tp.channel;
73 }
74
75 if (input_tp.channel > m_channel_end)
76 m_channel_end = input_tp.channel;
77
78 if (input_tp.channel < m_channel_start)
79 m_channel_start = input_tp.channel;
80
81 m_tp_list.push_back(input_tp);
82 m_adc_integral += input_tp.adc_integral;
83 m_detid |= input_tp.detid;
84}
85
86// Register algo in TA Factory
std::chrono::duration< double, std::ratio< 1, 62500000 > > pd_clock
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
bool is_channel_consistent(const TriggerPrimitive &input_tp) const
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta) override
TP processing function that creates & fills TAs.
bool is_time_consistent(const TriggerPrimitive &input_tp) const
This activity maker makes an activity with all the trigger primitives.
TriggerActivity MakeTriggerActivity() const
Maximum tolerated channel number difference between two primitives to form an activity.
dunedaq::trgdataformats::timestamp_t timestamp_t
Definition Types.hpp:16
#define TRACE_NAME
A single energy deposition on a TPC or PDS channel.