DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
WIBEthFrameProcessor.hpp
Go to the documentation of this file.
1
8#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_WIBEth_WIBFRAMEPROCESSOR_HPP_
9#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_WIBEth_WIBFRAMEPROCESSOR_HPP_
10
12
13// #include "appfwk/DAQModuleHelper.hpp"
15#include "iomanager/Sender.hpp"
16#include "logging/Logging.hpp"
17
19
22
28
29//#include "tpg/ProcessingInfo.hpp"
30//#include "tpg/RegisterToChannelNumber.hpp"
31
33
34#include <algorithm>
35#include <atomic>
36#include <bitset>
37#include <functional>
38#include <future>
39#include <memory>
40#include <pthread.h>
41#include <queue>
42#include <string>
43#include <thread>
44#include <utility>
45#include <vector>
46#include <random>
47
48
49namespace dunedaq {
50namespace fdreadoutlibs {
51
52class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel<types::DUNEWIBEthTypeAdapter>
53{
54
55public:
60 // Channel map function type
61 //typedef int (*chan_map_fn_t)(int);
62
63 explicit WIBEthFrameProcessor(std::unique_ptr<datahandlinglibs::FrameErrorRegistry>& error_registry, bool processing_enabled);
64
65 void start(const nlohmann::json& args) override;
66
67 void stop(const nlohmann::json& args) override;
68
69 void conf(const appmodel::DataHandlerModule* conf) override;
70
71protected:
72 virtual void generate_opmon_data() override;
73
78
83
88 std::map<int16_t, std::map<std::string, std::tuple<float, int16_t, int16_t, float, dunedaq::trgdataformats::channel_t, dunedaq::trgdataformats::channel_t>>>
89 calculate_all_metric_summaries_across_planes(const std::unordered_map<dunedaq::trgdataformats::channel_t, std::vector<std::pair<std::string, int16_t>>>& metrics);
90
91// Internals
92 dunedaq::daqdataformats::timestamp_t m_previous_ts = 0;
93 dunedaq::daqdataformats::timestamp_t m_current_ts = 0;
94
95 uint16_t m_previous_seq_id = 0;
96 uint16_t m_current_seq_id = 0;
97
98 dunedaq::daqdataformats::timestamp_t m_pattern_generator_previous_ts = 0;
99 dunedaq::daqdataformats::timestamp_t m_pattern_generator_current_ts = 0;
100
103 bool m_ts_error_state = false;
104 std::atomic<uint64_t> m_ts_error_ctr{ 0 };
105
109 std::atomic<uint64_t> m_seq_id_error_ctr{ 0 };
110 std::atomic<int16_t> m_seq_id_min_jump{ 0 };
111 std::atomic<int16_t> m_seq_id_max_jump{ 0 };
112
117
122 void sequence_check(frameptr fp);
123
128 void timestamp_check(frameptr fp);
129
134 void find_hits(constframeptr fp);
135 //void find_hits(constframeptr fp);
136
137
138private:
139 bool m_first_hit = true;
142 std::unique_ptr<tpglibs::TPGenerator> m_tp_generator;
143 std::vector<std::pair<std::string, nlohmann::json>> m_tpg_configs;
145 std::set<unsigned int> m_channel_mask_set;
147
148 std::map<uint, std::atomic<int>> m_tp_channel_rate_map;
149
150 size_t m_num_msg = 0;
151 size_t m_num_push_fail = 0;
152
153 std::atomic<int> m_tpg_hits_count{ 0 };
154
155 uint32_t m_det_id; // NOLINT(build/unsigned)
156 uint32_t m_crate_id; // NOLINT(build/unsigned)
157 uint32_t m_slot_id; // NOLINT(build/unsigned)
158 uint32_t m_stream_id; // NOLINT(build/unsigned)
159 bool m_emulator_mode = false;
160
161 std::shared_ptr<detchannelmaps::TPCChannelMap> m_channel_map;
162
163 // Mapping from expanded AVX register position to offline channel number
164 //std::array<uint, swtpg_wibeth::NUM_REGISTERS_PER_FRAME * swtpg_wibeth::SAMPLES_PER_REGISTER> m_register_channels;
165 std::vector<std::pair<trgdataformats::channel_t, int16_t>> m_channel_plane_numbers;
166 std::vector<trigger::TriggerPrimitiveTypeAdapter> m_tpa_vectors[3];
167
168 std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter>>> m_tp_sink[3];
169 std::shared_ptr<iomanager::SenderConcept<fddetdataformats::WIBEthFrame>> m_err_frame_sink;
170
171 //std::thread m_add_hits_tphandler_thread;
172
174
175 std::atomic<uint64_t> m_new_hits{ 0 }; // NOLINT(build/unsigned)
176 std::atomic<uint64_t> m_new_tps{ 0 }; // NOLINT(build/unsigned)
177 std::atomic<uint64_t> m_tps_suppressed_too_long{ 0 };
178 std::atomic<uint64_t> m_tps_send_failed{ 0 };
179 std::atomic<uint64_t> m_frame_counter{ 0 };
180
181 std::chrono::time_point<std::chrono::high_resolution_clock> m_t0;
182};
183
184} // namespace fdreadoutlibs
185} // namespace dunedaq
186
187#endif // FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_WIBEth_WIBFRAMEPROCESSOR_HPP_
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
void conf(const appmodel::DataHandlerModule *conf) override
Set the emulator mode, if active, timestamps of processed packets are overwritten with new ones.
WIBEthFrameProcessor(std::unique_ptr< datahandlinglibs::FrameErrorRegistry > &error_registry, bool processing_enabled)
std::unique_ptr< tpglibs::TPGenerator > m_tp_generator
dunedaq::daqdataformats::timestamp_t m_pattern_generator_previous_ts
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > m_tp_sink[3]
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
std::vector< trigger::TriggerPrimitiveTypeAdapter > m_tpa_vectors[3]
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
std::vector< std::pair< std::string, nlohmann::json > > m_tpg_configs
dunedaq::daqdataformats::timestamp_t m_current_ts
dunedaq::daqdataformats::timestamp_t m_previous_ts
void stop(const nlohmann::json &args) override
Stop operation.
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)
dunedaq::daqdataformats::timestamp_t m_pattern_generator_current_ts
std::shared_ptr< iomanager::SenderConcept< fddetdataformats::WIBEthFrame > > m_err_frame_sink
std::shared_ptr< detchannelmaps::TPCChannelMap > m_channel_map
void start(const nlohmann::json &args) override
Start operation.
The DUNE-DAQ namespace.
Definition DataStore.hpp:57
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32