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#ifdef TPGLIBS_ENABLE_STATE_MONITORING
39#endif
40
41#include <algorithm>
42#include <atomic>
43#include <chrono>
44#include <cmath>
45#include <cstdint>
46#include <functional>
47#include <map>
48#include <memory>
49#include <set>
50#include <string>
51#include <tuple>
52#include <unordered_map>
53#include <utility>
54#include <vector>
55
56namespace dunedaq {
57namespace fdreadoutlibs {
58
59template<class ReadoutTypeAdapter>
61{
62
63public:
65 using frameptr = ReadoutTypeAdapter*;
66 using constframeptr = const ReadoutTypeAdapter*;
67 using tpcframeptr = ReadoutTypeAdapter::FrameType*;
68
69 explicit TPCEthFrameProcessor(std::unique_ptr<datahandlinglibs::FrameErrorRegistry>& error_registry,
70 bool processing_enabled);
71
72 void start(const appfwk::DAQModule::CommandData_t& args) override;
73
74 void stop(const appfwk::DAQModule::CommandData_t& args) override;
75
76 void conf(const appmodel::DataHandlerModule* conf) override;
77
78 void scrap(const appfwk::DAQModule::CommandData_t& cfg) override;
79
80protected:
81 void generate_opmon_data() override;
82
84
86
88
90
92
94
96
98
100
102
103#ifdef TPGLIBS_ENABLE_STATE_MONITORING
104 void publish_processor_metric_to_opmon();
105 void publish_processor_metric_to_opmon_with_aggregation();
106 std::map<
107 int16_t,
108 std::map<
109 std::string,
110 std::
111 tuple<float, int16_t, int16_t, float, dunedaq::trgdataformats::channel_t, dunedaq::trgdataformats::channel_t>>>
112 calculate_all_metric_summaries_across_planes(
113 const std::unordered_map<dunedaq::trgdataformats::channel_t, std::vector<std::pair<std::string, int16_t>>>&
114 metrics);
115#endif
119
120 void sequence_check(frameptr fp);
121
125
126 void timestamp_check(frameptr fp);
127
131
132 void find_tps(constframeptr fp);
133
134 bool m_emulator_mode = false;
135 bool m_first_frame = true;
136
137 // Timestamp related variables.
140
143
146 bool m_ts_error_state = false;
147 std::atomic<uint64_t> m_ts_error_ctr{ 0 };
148
149 // Sequence ID related variables.
150 uint16_t m_previous_seq_id = 0;
151 uint16_t m_current_seq_id = 0;
152
156 std::atomic<uint64_t> m_seq_id_error_ctr{ 0 };
157 std::atomic<int16_t> m_seq_id_min_jump{ 0 };
158 std::atomic<int16_t> m_seq_id_max_jump{ 0 };
159
160 // TPG related variables.
161 std::unique_ptr<tpglibs::TPGenerator> m_tp_generator;
162#ifdef TPGLIBS_ENABLE_STATE_MONITORING
163 std::unique_ptr<fdreadoutlibs::TPGInternalStateHarvester> m_state_harvester;
164#endif
165 std::vector<std::pair<std::string, nlohmann::json>> m_tpg_configs;
166
167 std::unordered_map<unsigned int, std::vector<trigger::TriggerPrimitiveTypeAdapter>> m_plane_to_tpa_vector_map;
168 std::unordered_map<unsigned int,
169 std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter>>>>
171
172 uint32_t m_tp_count_limit = 0;
174 uint32_t m_current_tp_count = 0;
176
177 bool m_tp_limit_enabled = false;
179
180 // TPG: channel variables.
181 std::set<unsigned int> m_channel_mask_set;
182 std::set<unsigned int> m_plane_numbers_set;
183 std::vector<std::pair<trgdataformats::channel_t, int16_t>> m_channel_plane_numbers;
184 std::unordered_map<trgdataformats::channel_t, unsigned int> m_channel_plane_map;
185
186 // OpMon related variables.
189
190 std::map<uint, std::atomic<int>> m_tp_channel_rate_map;
191
192 std::atomic<uint64_t> m_num_new_tps{ 0 }; // NOLINT(build/unsigned)
193 std::atomic<uint64_t> m_tps_suppressed_too_long{ 0 };
194 std::atomic<uint64_t> m_tps_send_failed{ 0 };
195
196 std::chrono::time_point<std::chrono::high_resolution_clock> m_t0;
197
198 std::atomic<uint64_t> m_frame_counter{ 0 };
199
200 // Source & Geo ID related variables.
201 uint32_t m_det_id; // NOLINT(build/unsigned)
202 uint32_t m_crate_id; // NOLINT(build/unsigned)
203 uint32_t m_slot_id; // NOLINT(build/unsigned)
204 uint32_t m_stream_id; // NOLINT(build/unsigned)
205
207};
208
209} // namespace fdreadoutlibs
210} // namespace dunedaq
211
213
214#endif // FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TPCETHFRAMEPROCESSOR_HPP_
datahandlinglibs::TaskRawDataProcessorModel< ReadoutTypeAdapter > inherited
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::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
uint64_t timestamp_t
Type used to represent DUNE timing system timestamps.
Definition Types.hpp:26
The DUNE-DAQ namespace.
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32