DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDEEthFrameProcessor.hpp
Go to the documentation of this file.
1
8#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHFRAMEPROCESSOR_HPP_
9#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHFRAMEPROCESSOR_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
53{
54
55public:
60 // Channel map function type
61 //typedef int (*chan_map_fn_t)(int);
62
63 explicit TDEEthFrameProcessor(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
74 // Internals
77
78 uint16_t m_previous_seq_id = 0;
79 uint16_t m_current_seq_id = 0;
80
83
86 bool m_ts_error_state = false;
87 std::atomic<uint64_t> m_ts_error_ctr{ 0 };
88
92 std::atomic<uint64_t> m_seq_id_error_ctr{ 0 };
93 std::atomic<int16_t> m_seq_id_min_jump{ 0 };
94 std::atomic<int16_t> m_seq_id_max_jump{ 0 };
95
100
105 void sequence_check(frameptr fp);
106
111 void timestamp_check(frameptr fp);
112
117 void find_hits(constframeptr fp);
118 //void find_hits(constframeptr fp);
119
120
121private:
122 bool m_first_hit = true;
123 std::unique_ptr<tpglibs::TPGenerator> m_tp_generator;
124 std::vector<std::pair<std::string, nlohmann::json>> m_tpg_configs;
126 std::set<unsigned int> m_channel_mask_set;
128
129 std::map<uint, std::atomic<int>> m_tp_channel_rate_map;
130
131 size_t m_num_msg = 0;
132 size_t m_num_push_fail = 0;
133
134 std::atomic<int> m_tpg_hits_count{ 0 };
135
136 uint32_t m_det_id; // NOLINT(build/unsigned)
137 uint32_t m_crate_id; // NOLINT(build/unsigned)
138 uint32_t m_slot_id; // NOLINT(build/unsigned)
139 uint32_t m_stream_id; // NOLINT(build/unsigned)
140 bool m_emulator_mode = false;
141
142 std::shared_ptr<detchannelmaps::TPCChannelMap> m_channel_map;
143
144 // Mapping from expanded AVX register position to offline channel number
145 //std::array<uint, swtpg_wibeth::NUM_REGISTERS_PER_FRAME * swtpg_wibeth::SAMPLES_PER_REGISTER> m_register_channels;
146 std::vector<std::pair<trgdataformats::channel_t, int16_t>> m_channel_plane_numbers;
147 std::vector<trigger::TriggerPrimitiveTypeAdapter> m_tpa_vectors[3];
148
149 std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter>>> m_tp_sink[3];
150 std::shared_ptr<iomanager::SenderConcept<fddetdataformats::TDEEthFrame>> m_err_frame_sink;
151
152 //std::thread m_add_hits_tphandler_thread;
153
155
156 std::atomic<uint64_t> m_new_hits{ 0 }; // NOLINT(build/unsigned)
157 std::atomic<uint64_t> m_new_tps{ 0 }; // NOLINT(build/unsigned)
158 std::atomic<uint64_t> m_tps_suppressed_too_long{ 0 };
159 std::atomic<uint64_t> m_tps_send_failed{ 0 };
160 std::atomic<uint64_t> m_frame_counter{ 0 };
161
162 std::chrono::time_point<std::chrono::high_resolution_clock> m_t0;
163};
164
165} // namespace fdreadoutlibs
166} // namespace dunedaq
167
168#endif // FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHFRAMEPROCESSOR_HPP_
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
dunedaq::daqdataformats::timestamp_t m_pattern_generator_current_ts
TDEEthFrameProcessor(std::unique_ptr< datahandlinglibs::FrameErrorRegistry > &error_registry, bool processing_enabled)
std::vector< std::pair< std::string, nlohmann::json > > m_tpg_configs
void conf(const appmodel::DataHandlerModule *conf) override
Set the emulator mode, if active, timestamps of processed packets are overwritten with new ones.
std::unique_ptr< tpglibs::TPGenerator > m_tp_generator
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
std::shared_ptr< detchannelmaps::TPCChannelMap > m_channel_map
dunedaq::daqdataformats::timestamp_t m_current_ts
dunedaq::daqdataformats::timestamp_t m_pattern_generator_previous_ts
void stop(const nlohmann::json &args) override
Stop operation.
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
dunedaq::daqdataformats::timestamp_t m_previous_ts
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
std::shared_ptr< iomanager::SenderConcept< fddetdataformats::TDEEthFrame > > m_err_frame_sink
void start(const nlohmann::json &args) override
Start operation.
std::vector< trigger::TriggerPrimitiveTypeAdapter > m_tpa_vectors[3]
std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > m_tp_sink[3]
uint64_t timestamp_t
Type used to represent DUNE timing system timestamps.
Definition Types.hpp:36
Including Qt Headers.
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32