DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPCEthFrameProcessor.hpp
Go to the documentation of this file.
1
8#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TPCETHFRAMEPROCESSOR_HPP_
9#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TPCETHFRAMEPROCESSOR_HPP_
10
12
18
19#include "confmodel/GeoId.hpp"
20
26
28
30
31#include "iomanager/Sender.hpp"
32#include "logging/Logging.hpp"
33
37
38#include <algorithm>
39#include <atomic>
40#include <chrono>
41#include <cmath>
42#include <cstdint>
43#include <functional>
44#include <map>
45#include <memory>
46#include <set>
47#include <string>
48#include <tuple>
49#include <unordered_map>
50#include <utility>
51#include <vector>
52
53namespace dunedaq {
54namespace fdreadoutlibs {
55
56template <class ReadoutTypeAdapter>
58{
59
60public:
62 using frameptr = ReadoutTypeAdapter*;
63 using constframeptr = const ReadoutTypeAdapter*;
64 using tpcframeptr = ReadoutTypeAdapter::FrameType*;
65
66 explicit TPCEthFrameProcessor(std::unique_ptr<datahandlinglibs::FrameErrorRegistry>& error_registry, bool processing_enabled);
67
68 void start(const appfwk::DAQModule::CommandData_t& args) override;
69
70 void stop(const appfwk::DAQModule::CommandData_t& args) override;
71
72 void conf(const appmodel::DataHandlerModule* conf) override;
73
74 void scrap(const appfwk::DAQModule::CommandData_t& cfg) override;
75
76protected:
77 void generate_opmon_data() override;
78
80
82
84
86
88
90
92
94
96
98
103
108
113 std::map<int16_t, std::map<std::string, std::tuple<float, int16_t, int16_t, float, dunedaq::trgdataformats::channel_t, dunedaq::trgdataformats::channel_t>>>
114 calculate_all_metric_summaries_across_planes(const std::unordered_map<dunedaq::trgdataformats::channel_t, std::vector<std::pair<std::string, int16_t>>>& metrics);
119 void sequence_check(frameptr fp);
120
125 void timestamp_check(frameptr fp);
126
131 void find_tps(constframeptr fp);
132
133 bool m_emulator_mode = false;
134 bool m_first_frame = true;
135
136 // Timestamp related variables.
137 dunedaq::daqdataformats::timestamp_t m_previous_ts = 0;
138 dunedaq::daqdataformats::timestamp_t m_current_ts = 0;
139
140 dunedaq::daqdataformats::timestamp_t m_pattern_generator_previous_ts = 0;
141 dunedaq::daqdataformats::timestamp_t m_pattern_generator_current_ts = 0;
142
145 bool m_ts_error_state = false;
146 std::atomic<uint64_t> m_ts_error_ctr{ 0 };
147
148 // Sequence ID related variables.
149 uint16_t m_previous_seq_id = 0;
150 uint16_t m_current_seq_id = 0;
151
155 std::atomic<uint64_t> m_seq_id_error_ctr{ 0 };
156 std::atomic<int16_t> m_seq_id_min_jump{ 0 };
157 std::atomic<int16_t> m_seq_id_max_jump{ 0 };
158
159 // TPG related variables.
160 std::unique_ptr<tpglibs::TPGenerator> m_tp_generator;
161 std::vector<std::pair<std::string, nlohmann::json>> m_tpg_configs;
162
163 std::unordered_map<unsigned int, std::vector<trigger::TriggerPrimitiveTypeAdapter>> m_plane_to_tpa_vector_map;
164 std::unordered_map<unsigned int, std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter>>>> m_plane_to_tp_sink_map;
165
166 uint32_t m_tp_count_limit = 0;
168 uint32_t m_current_tp_count = 0;
170
171 bool m_tp_limit_enabled = false;
173
174 // TPG: channel variables.
175 std::set<unsigned int> m_channel_mask_set;
176 std::set<unsigned int> m_plane_numbers_set;
177 std::vector<std::pair<trgdataformats::channel_t, int16_t>> m_channel_plane_numbers;
178 std::unordered_map<trgdataformats::channel_t, unsigned int> m_channel_plane_map;
179
180 // OpMon related variables.
183
184 std::map<uint, std::atomic<int>> m_tp_channel_rate_map;
185
186 std::atomic<uint64_t> m_num_new_tps{ 0 }; // NOLINT(build/unsigned)
187 std::atomic<uint64_t> m_tps_suppressed_too_long{ 0 };
188 std::atomic<uint64_t> m_tps_send_failed{ 0 };
189
190 std::chrono::time_point<std::chrono::high_resolution_clock> m_t0;
191
192 std::atomic<uint64_t> m_frame_counter{ 0 };
193
194 // Source & Geo ID related variables.
195 uint32_t m_det_id; // NOLINT(build/unsigned)
196 uint32_t m_crate_id; // NOLINT(build/unsigned)
197 uint32_t m_slot_id; // NOLINT(build/unsigned)
198 uint32_t m_stream_id; // NOLINT(build/unsigned)
199
201};
202
203} // namespace fdreadoutlibs
204} // namespace dunedaq
205
207
208#endif // FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TPCETHFRAMEPROCESSOR_HPP_
void configure_postprocessing(const appmodel::DataHandlerModule *conf)
void configure_channel_plane_numbers(const appmodel::TPCRawDataProcessor *proc_conf)
void stop(const appfwk::DAQModule::CommandData_t &args) override
Stop operation.
std::vector< std::pair< std::string, nlohmann::json > > m_tpg_configs
std::unordered_map< unsigned int, std::vector< trigger::TriggerPrimitiveTypeAdapter > > m_plane_to_tpa_vector_map
void configure_find_tps(const appmodel::DataHandlerModule *conf, const appmodel::TPCRawDataProcessor *proc_conf)
void scrap(const appfwk::DAQModule::CommandData_t &cfg) override
Unconfigure.
std::unique_ptr< tpglibs::TPGenerator > m_tp_generator
dunedaq::daqdataformats::timestamp_t m_previous_ts
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
std::unordered_map< unsigned int, std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > > m_plane_to_tp_sink_map
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
void configure_source_and_geo_ids(const appmodel::DataHandlerModule *conf)
std::map< int16_t, std::map< std::string, std::tuple< float, int16_t, int16_t, float, dunedaq::trgdataformats::channel_t, dunedaq::trgdataformats::channel_t > > > calculate_all_metric_summaries_across_planes(const std::unordered_map< dunedaq::trgdataformats::channel_t, std::vector< std::pair< std::string, int16_t > > > &metrics)
std::unordered_map< trgdataformats::channel_t, unsigned int > m_channel_plane_map
void start(const appfwk::DAQModule::CommandData_t &args) override
Start operation.
void configure_preprocessing(const appmodel::DataHandlerModule *conf)
void conf(const appmodel::DataHandlerModule *conf) override
Set the emulator mode, if active, timestamps of processed packets are overwritten with new ones.
TPCEthFrameProcessor(std::unique_ptr< datahandlinglibs::FrameErrorRegistry > &error_registry, bool processing_enabled)
dunedaq::daqdataformats::timestamp_t m_pattern_generator_current_ts
dunedaq::daqdataformats::timestamp_t m_pattern_generator_previous_ts
dunedaq::daqdataformats::timestamp_t m_current_ts
The DUNE-DAQ namespace.
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32