DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPGPipeline.hpp
Go to the documentation of this file.
1
9#ifndef TPGLIBS_TPGPIPELINE_HPP_
10#define TPGLIBS_TPGPIPELINE_HPP_
11
13
16
17#include <nlohmann/json.hpp>
18#include <vector>
19
20namespace tpglibs {
21
27template <typename T, typename U>
29 public:
31 using processor_t = T;
33 using signal_t = U;
34
35 virtual ~TPGPipeline() = default;
36
43 virtual void configure(const std::vector<std::pair<std::string, nlohmann::json>> configs, const std::vector<std::pair<dunedaq::trgdataformats::channel_t, int16_t>> channel_plane_numbers) {
44 std::shared_ptr<processor_t> prev_processor = nullptr;
45
46 for (int i = 0; i < 16; i++) {
47 m_channels[i] = channel_plane_numbers[i].first;
48 m_plane_numbers[i] = channel_plane_numbers[i].second;
49 }
50
51 for (const auto& name_config : configs) {
52 // Get the requested processor.
53 std::shared_ptr<processor_t> processor = m_factory->create_processor(name_config.first);
54
55 // Configure it.
56 processor->configure(name_config.second, m_plane_numbers);
57
58 // If it's the first one, make it the head.
59 if (!prev_processor) {
60 m_processor_head = processor;
61 prev_processor = processor;
62 continue;
63 }
64
65 // Otherwise, start linking the chain.
66 prev_processor->set_next_processor(processor);
67 prev_processor = processor;
68 }
69 }
70
74 virtual std::vector<dunedaq::trgdataformats::TriggerPrimitive> process(const signal_t& signal) {
75 signal_t tp_mask = save_state(m_processor_head->process(signal));
76
77 std::vector<dunedaq::trgdataformats::TriggerPrimitive> tps;
78 if (check_for_tps(tp_mask))
79 tps = generate_tps(tp_mask);
80
81 return tps;
82 }
83
85 virtual bool check_for_tps(const signal_t& tp_mask) = 0;
86
88 virtual signal_t save_state(const signal_t& processed_signal) = 0;
89
91 virtual std::vector<dunedaq::trgdataformats::TriggerPrimitive> generate_tps(const signal_t& tp_mask) = 0;
92
94 virtual void set_sot_minima(const std::vector<uint16_t>& sot_minima) {
95 int idx = 0;
96 for (auto sot_minimum : sot_minima) {
97 m_sot_minima[idx++] = sot_minimum;
98 }
99 }
100
101 protected:
114 int16_t m_plane_numbers[16];
116 uint16_t m_sot_minima[3];
118 std::shared_ptr<AbstractFactory<processor_t>> m_factory = AbstractFactory<processor_t>::get_instance();
120 std::shared_ptr<processor_t> m_processor_head;
121};
122
123} // namespace tpglibs
124
125#endif // TPGLIBS_TPGPIPELINE_HPP_
static std::shared_ptr< AbstractFactory< T > > get_instance()
Singleton get instance function.
Abstract class for the TPG pipeline.
virtual ~TPGPipeline()=default
int16_t m_plane_numbers[16]
Detector plane numbers for the 16 channels that are being processed.
std::shared_ptr< processor_t > m_processor_head
Processor head to start from.
signal_t m_adc_peak
The ADC peak for channels that are considered active.
std::shared_ptr< AbstractFactory< processor_t > > m_factory
Processor factory singleton.
signal_t m_adc_integral_lo
The on-going ADC integral for channels that are considered active.
virtual void set_sot_minima(const std::vector< uint16_t > &sot_minima)
Set the samples over threshold minimum values.
signal_t m_samples_over_threshold
The samples over threshold for channels that are considered active.
dunedaq::trgdataformats::channel_t m_channels[16]
Detector channel numbers for the 16 channels that are being processed.
T processor_t
Processor type to use. Generally AVX.
uint16_t m_sot_minima[3]
The samples over threshold minimum that a TP from plane i must have.
virtual bool check_for_tps(const signal_t &tp_mask)=0
Pure virtual function that will check if any TPs can be generated.
virtual void configure(const std::vector< std::pair< std::string, nlohmann::json > > configs, const std::vector< std::pair< dunedaq::trgdataformats::channel_t, int16_t > > channel_plane_numbers)
Configure the pieces to the pipeline.
U signal_t
Signal type to use. Generally __m256i.
virtual std::vector< dunedaq::trgdataformats::TriggerPrimitive > process(const signal_t &signal)
Process a signal through the pipeline.
signal_t m_samples_to_peak
The number of samples from time_start to the ADC peak.
virtual std::vector< dunedaq::trgdataformats::TriggerPrimitive > generate_tps(const signal_t &tp_mask)=0
Pure virtual function that will generate TPs given a mask to draw from.
virtual signal_t save_state(const signal_t &processed_signal)=0
Pure virtual function that will save the state of the generation.