DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::fdreadoutlibs::WIBEthFrameProcessor Class Reference

#include <WIBEthFrameProcessor.hpp>

Inheritance diagram for dunedaq::fdreadoutlibs::WIBEthFrameProcessor:
[legend]
Collaboration diagram for dunedaq::fdreadoutlibs::WIBEthFrameProcessor:
[legend]

Public Types

using inherited = datahandlinglibs::TaskRawDataProcessorModel<types::DUNEWIBEthTypeAdapter>
 
using frameptr = types::DUNEWIBEthTypeAdapter*
 
using constframeptr = const types::DUNEWIBEthTypeAdapter*
 
using wibframeptr = dunedaq::fddetdataformats::WIBEthFrame*
 
- Public Types inherited from dunedaq::opmonlib::MonitorableObject
using NodePtr = std::weak_ptr<MonitorableObject>
 
using NewNodePtr = std::shared_ptr<MonitorableObject>
 
using ElementId = std::string
 

Public Member Functions

 WIBEthFrameProcessor (std::unique_ptr< datahandlinglibs::FrameErrorRegistry > &error_registry, bool processing_enabled)
 
void start (const nlohmann::json &args) override
 Start operation.
 
void stop (const nlohmann::json &args) override
 Stop operation.
 
void conf (const appmodel::DataHandlerModule *conf) override
 Set the emulator mode, if active, timestamps of processed packets are overwritten with new ones.
 
- Public Member Functions inherited from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< types::DUNEWIBEthTypeAdapter >
 TaskRawDataProcessorModel (std::unique_ptr< FrameErrorRegistry > &error_registry, bool post_processing_enabled)
 
 ~TaskRawDataProcessorModel ()
 
void scrap (const nlohmann::json &) override
 Unconfigure.
 
void reset_last_daq_time ()
 
std::uint64_t get_last_daq_time () override
 Get newest timestamp of last seen packet.
 
void preprocess_item (types::DUNEWIBEthTypeAdapter *item) override
 Preprocess one element.
 
void postprocess_item (const types::DUNEWIBEthTypeAdapter *item) override
 Postprocess one element.
 
void add_preprocess_task (Task &&task)
 
void add_postprocess_task (Task &&task)
 
void invoke_all_preprocess_functions (types::DUNEWIBEthTypeAdapter *item)
 
void launch_all_preprocess_functions (types::DUNEWIBEthTypeAdapter *item)
 
- Public Member Functions inherited from dunedaq::datahandlinglibs::RawDataProcessorConcept< types::DUNEWIBEthTypeAdapter >
 RawDataProcessorConcept ()
 
 RawDataProcessorConcept (const RawDataProcessorConcept &)=delete
 RawDataProcessorConcept is not copy-constructible.
 
 RawDataProcessorConcept (RawDataProcessorConcept &&)=delete
 RawDataProcessorConcept is not move-constructible.
 
virtual ~RawDataProcessorConcept ()
 
RawDataProcessorConceptoperator= (const RawDataProcessorConcept &)=delete
 RawDataProcessorConcept is not copy-assginable.
 
RawDataProcessorConceptoperator= (RawDataProcessorConcept &&)=delete
 RawDataProcessorConcept is not move-assignable.
 
- Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject (const MonitorableObject &)=delete
 
MonitorableObjectoperator= (const MonitorableObject &)=delete
 
 MonitorableObject (MonitorableObject &&)=delete
 
MonitorableObjectoperator= (MonitorableObject &&)=delete
 
virtual ~MonitorableObject ()=default
 
auto get_opmon_id () const noexcept
 
auto get_opmon_level () const noexcept
 

Protected Member Functions

virtual void generate_opmon_data () override
 
void use_pattern_generator (frameptr fp)
 
void sequence_check (frameptr fp)
 
void timestamp_check (frameptr fp)
 
void find_hits (constframeptr fp)
 
- Protected Member Functions inherited from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< types::DUNEWIBEthTypeAdapter >
void run_post_processing_thread (std::function< void(const types::DUNEWIBEthTypeAdapter *)> &function, folly::ProducerConsumerQueue< const types::DUNEWIBEthTypeAdapter * > &queue)
 
- Protected Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject ()=default
 
void register_node (ElementId name, NewNodePtr)
 
void publish (google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
 

Protected Attributes

dunedaq::daqdataformats::timestamp_t m_previous_ts = 0
 
dunedaq::daqdataformats::timestamp_t m_current_ts = 0
 
uint16_t m_previous_seq_id = 0
 
uint16_t m_current_seq_id = 0
 
dunedaq::daqdataformats::timestamp_t m_pattern_generator_previous_ts = 0
 
dunedaq::daqdataformats::timestamp_t m_pattern_generator_current_ts = 0
 
bool m_first_ts_missmatch = true
 
bool m_ts_problem_reported = false
 
bool m_ts_error_state = false
 
std::atomic< uint64_t > m_ts_error_ctr { 0 }
 
bool m_first_seq_id_mismatch = true
 
bool m_seq_id_problem_reported = false
 
bool m_seq_id_error_state = false
 
std::atomic< uint64_t > m_seq_id_error_ctr { 0 }
 
std::atomic< int16_t > m_seq_id_min_jump { 0 }
 
std::atomic< int16_t > m_seq_id_max_jump { 0 }
 
- Protected Attributes inherited from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< types::DUNEWIBEthTypeAdapter >
std::vector< std::function< void(types::DUNEWIBEthTypeAdapter *)> > m_preprocess_functions
 
std::unique_ptr< FrameErrorRegistry > & m_error_registry
 
bool m_post_processing_enabled
 
std::atomic< bool > m_run_marker
 
std::vector< std::function< void(const types::DUNEWIBEthTypeAdapter *)> > m_post_process_functions
 
std::vector< std::unique_ptr< folly::ProducerConsumerQueue< const types::DUNEWIBEthTypeAdapter * > > > m_items_to_postprocess_queues
 
std::vector< std::unique_ptr< utilities::ReusableThread > > m_post_process_threads
 
size_t m_postprocess_queue_sizes
 
daqdataformats::SourceID m_sourceid
 
std::atomic< uint64_t > m_last_processed_daq_ts
 

Private Attributes

bool m_first_hit = true
 
std::unique_ptr< tpglibs::TPGeneratorm_tp_generator
 
std::vector< std::pair< std::string, nlohmann::json > > m_tpg_configs
 
uint32_t m_tp_max_width
 
std::set< unsigned int > m_channel_mask_set
 
uint16_t m_tpg_threshold_selected
 
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
 
size_t m_num_msg = 0
 
size_t m_num_push_fail = 0
 
std::atomic< int > m_tpg_hits_count { 0 }
 
uint32_t m_det_id
 
uint32_t m_crate_id
 
uint32_t m_slot_id
 
uint32_t m_stream_id
 
bool m_emulator_mode = false
 
std::shared_ptr< detchannelmaps::TPCChannelMap > m_channel_map
 
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
 
std::vector< trigger::TriggerPrimitiveTypeAdapterm_tpa_vectors [3]
 
std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > m_tp_sink [3]
 
std::shared_ptr< iomanager::SenderConcept< fddetdataformats::WIBEthFrame > > m_err_frame_sink
 
daqdataformats::SourceID m_sourceid
 
std::atomic< uint64_t > m_new_hits { 0 }
 
std::atomic< uint64_t > m_new_tps { 0 }
 
std::atomic< uint64_t > m_tps_suppressed_too_long { 0 }
 
std::atomic< uint64_t > m_tps_send_failed { 0 }
 
std::atomic< uint64_t > m_frame_counter { 0 }
 
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
 

Additional Inherited Members

- Static Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
static bool publishable_metric (OpMonLevel entry, OpMonLevel system) noexcept
 

Detailed Description

Definition at line 52 of file WIBEthFrameProcessor.hpp.

Member Typedef Documentation

◆ constframeptr

◆ frameptr

◆ inherited

◆ wibframeptr

Constructor & Destructor Documentation

◆ WIBEthFrameProcessor()

dunedaq::fdreadoutlibs::WIBEthFrameProcessor::WIBEthFrameProcessor ( std::unique_ptr< datahandlinglibs::FrameErrorRegistry > & error_registry,
bool processing_enabled )
explicit

Definition at line 31 of file WIBEthFrameProcessor.cpp.

32 : TaskRawDataProcessorModel<types::DUNEWIBEthTypeAdapter>(error_registry, processing_enabled)
33{
34}

Member Function Documentation

◆ conf()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::conf ( const appmodel::DataHandlerModule * conf)
overridevirtual

Set the emulator mode, if active, timestamps of processed packets are overwritten with new ones.

Reimplemented from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< types::DUNEWIBEthTypeAdapter >.

Definition at line 78 of file WIBEthFrameProcessor.cpp.

79{
80 size_t idx = 0;
81 for (auto output : conf->get_outputs()) {
82 try {
83 if (output->get_data_type() == "TriggerPrimitiveVector") {
85 }
86 } catch (const ers::Issue& excpt) {
87 ers::error(datahandlinglibs::ResourceQueueError(ERS_HERE, "tp", "DefaultRequestHandlerModel", excpt));
88 }
89 }
90
91 m_sourceid.id = conf->get_source_id();
93 auto geo_id = conf->get_geo_id();
94 if (geo_id != nullptr) {
95 m_det_id = geo_id->get_detector_id();
96 m_crate_id = geo_id->get_crate_id();
97 m_slot_id = geo_id->get_slot_id();
98 m_stream_id = geo_id->get_stream_id();
99 }
100 m_emulator_mode = conf->get_emulation_mode();
101
102 // Setup pre-processing pipeline
103 if (!m_emulator_mode)
104 inherited::add_preprocess_task(std::bind(&WIBEthFrameProcessor::sequence_check, this, std::placeholders::_1));
105
106 inherited::add_preprocess_task(std::bind(&WIBEthFrameProcessor::timestamp_check, this, std::placeholders::_1));
107
108 // Check it post-processing is active
109 auto dp = conf->get_module_configuration()->get_data_processor();
110 if (dp != nullptr) {
111 auto proc_conf = dp->cast<appmodel::RawDataProcessor>();
112 if (proc_conf != nullptr && m_post_processing_enabled) {
113 m_tp_generator = std::make_unique<tpglibs::TPGenerator>();
114
115 // Set the minimum TP samples over threshold.
116 auto conf_sot_minima = proc_conf->get_sot_minima();
117 std::vector<uint16_t> sot_minima{conf_sot_minima->get_sot_minimum_plane0(),
118 conf_sot_minima->get_sot_minimum_plane1(),
119 conf_sot_minima->get_sot_minimum_plane2()};
120 m_tp_generator->set_sot_minima(sot_minima);
121
122 const std::vector<unsigned int> channel_mask_vec = proc_conf->get_channel_mask();
123
124 std::vector<const appmodel::ProcessingStep*> processing_steps = proc_conf->get_processing_steps();
125 for (auto step : processing_steps) {
126 m_tpg_configs.push_back(std::make_pair(step->class_name(), step->to_json(false).back()));
127 }
128
129 // Setup post-processing pipeline
130 m_channel_map = dunedaq::detchannelmaps::make_tpc_map(proc_conf->get_channel_map());
131 for (int chan = 0; chan < 64; chan++) {
132 trgdataformats::channel_t off_channel = m_channel_map->get_offline_channel_from_det_crate_slot_stream_chan(m_det_id, m_crate_id, m_slot_id, m_stream_id, chan);
133 int16_t plane = m_channel_map->get_plane_from_offline_channel(off_channel);
134 m_channel_plane_numbers.push_back(std::make_pair(off_channel, plane));
135
136 // This processor only needs to handle some (maybe 0) of the masked channels.
137 // Only get those relevant channels for the later check.
138 if (std::find(channel_mask_vec.begin(), channel_mask_vec.end(), off_channel) != channel_mask_vec.end())
139 m_channel_mask_set.insert(off_channel);
140 }
141
143
144 inherited::add_postprocess_task(std::bind(&WIBEthFrameProcessor::find_hits, this, std::placeholders::_1));
145 }
146 }
148}
#define ERS_HERE
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::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< std::pair< std::string, nlohmann::json > > m_tpg_configs
std::shared_ptr< detchannelmaps::TPCChannelMap > m_channel_map
Base class for any user define issue.
Definition Issue.hpp:69
static std::shared_ptr< iomanager::SenderConcept< Datatype > > get_iom_sender(iomanager::ConnectionId const &id)
void error(const Issue &issue)
Definition ers.hpp:81
Subsystem subsystem
The general subsystem of the source of the data.
Definition SourceID.hpp:69
ID_t id
Unique identifier of the source of the data.
Definition SourceID.hpp:74
static const constexpr daqdataformats::SourceID::Subsystem subsystem

◆ find_hits()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::find_hits ( constframeptr fp)
protected

Pipeline Stage 2.: Do software TPG

Definition at line 343 of file WIBEthFrameProcessor.cpp.

344{
345 size_t nhits = 0;
346 if (!fp)
347 return;
348 auto wfptr = reinterpret_cast<dunedaq::fddetdataformats::WIBEthFrame*>((uint8_t*)fp); // NOLINT
349
350 // Check that the system is properly configured from the first hit.
351 if (m_first_hit) {
352 if (wfptr->daq_header.crate_id != m_crate_id || wfptr->daq_header.slot_id != m_slot_id || wfptr->daq_header.stream_id != m_stream_id) {
353 ers::error(LinkMisconfiguration(ERS_HERE, wfptr->daq_header.crate_id, wfptr->daq_header.slot_id, wfptr->daq_header.stream_id, m_crate_id, m_slot_id, m_stream_id));
354 }
355
356 m_first_hit = false;
357 }
358
359 std::vector<trgdataformats::TriggerPrimitive> tps = (*m_tp_generator)(wfptr);
361
362 for (const auto& tp : tps) {
363 // If this TP is on a masked channel, skip it.
364 if (std::binary_search(m_channel_mask_set.begin(), m_channel_mask_set.end(), tp.channel))
365 continue;
366 // Need to move into a type adapter.
367 trigger::TriggerPrimitiveTypeAdapter tpa;
368 tpa.tp = tp;
369
370 tpa.tp.detid = m_det_id; // Last missing piece.
371 m_tpa_vectors[m_channel_map->get_plane_from_offline_channel(tp.channel)].push_back(tpa);
372 m_tp_channel_rate_map[tp.channel]++;
373 }
374
375 if (m_frame_counter >= 100) { // FIXME: Hard-coding 100 for now. This should be defined elsewhere or configurable.
376 for (int i = 0; i < 3; i++) {
377 int new_tps = m_tpa_vectors[i].size();
378 if (new_tps == 0) {
379 continue;
380 }
381 const auto s_ts_begin = m_tpa_vectors[i].front().tp.time_start;
382 const auto channel_begin = m_tpa_vectors[i].front().tp.channel;
383 const auto s_ts_end = m_tpa_vectors[i].back().tp.time_start;
384 const auto channel_end = m_tpa_vectors[i].back().tp.channel;
385 if (!m_tp_sink[i]->try_send(std::move(m_tpa_vectors[i]), iomanager::Sender::s_no_block)) {
386 ers::warning(FailedToSendTPVector(ERS_HERE, s_ts_begin, channel_begin, s_ts_end, channel_end));
388 } else {
389 m_new_tps += new_tps;
390 nhits += new_tps;
391 }
392 }
393 m_frame_counter = 0;
394 }
395
396 m_tpg_hits_count += nhits;
397 return;
398}
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
std::vector< trigger::TriggerPrimitiveTypeAdapter > m_tpa_vectors[3]
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
static constexpr timeout_t s_no_block
Definition Sender.hpp:26
void warning(const Issue &issue)
Definition ers.hpp:115

◆ generate_opmon_data()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::generate_opmon_data ( )
overrideprotectedvirtual

Hook for customisable pubblication. The function can throw, exception will be caught by the monitoring thread

Reimplemented from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< types::DUNEWIBEthTypeAdapter >.

Definition at line 151 of file WIBEthFrameProcessor.cpp.

152{
153 datahandlinglibs::opmon::FixedRateDataProcessorInfo info;
154
155 info.set_num_seq_id_errors(m_seq_id_error_ctr.load());
156 info.set_min_seq_id_jump(m_seq_id_min_jump.exchange(0));
157 info.set_max_seq_id_jump(m_seq_id_max_jump.exchange(0));
158
159 info.set_num_ts_errors(m_ts_error_ctr.load());
160
161 publish(std::move(info));
162
163 m_error_registry->log_registered_errors();
164
166 auto now = std::chrono::high_resolution_clock::now();
167 int new_hits = m_tpg_hits_count.exchange(0);
168 int new_tps = m_new_tps.exchange(0);
169 int new_tps_suppressed_too_long = m_tps_suppressed_too_long.exchange(0);
170 int new_tps_send_failed = m_tps_send_failed.exchange(0);
171 double seconds = std::chrono::duration_cast<std::chrono::microseconds>(now - m_t0).count() / 1000000.;
172 TLOG_DEBUG(TLVL_BOOKKEEPING) << "Hit rate: " << std::to_string(new_hits / seconds / 1000.) << " [kHz]";
173 TLOG_DEBUG(TLVL_BOOKKEEPING) << "Total new hits: " << new_hits << " new TPs: " << new_tps;
174
175 datahandlinglibs::opmon::HitFindingInfo tp_info;
176 tp_info.set_rate_tp_hits(new_hits / seconds / 1000.);
177
178 tp_info.set_num_tps_sent(new_tps);
179 tp_info.set_num_tps_suppressed_too_long(new_tps_suppressed_too_long);
180 tp_info.set_num_tps_send_failed(new_tps_send_failed);
181
182 publish(std::move(tp_info));
183 // Find the channels with the top TP rates
184 // Create a vector of pairs to store the map elements
185 std::vector<std::pair<uint, int>> channel_tp_rate_vec(m_tp_channel_rate_map.begin(), m_tp_channel_rate_map.end());
186 // Sort the vector in descending order of the value of the pairs
187 sort(channel_tp_rate_vec.begin(), channel_tp_rate_vec.end(), [](std::pair<uint, int>& a, std::pair<uint, int>& b) { return a.second > b.second; });
188 // Add the metrics to opmon
189 // For convenience we are selecting only the top 10 elements
190 if (channel_tp_rate_vec.size() != 0) {
191 int top_highest_values = 10;
192 if (channel_tp_rate_vec.size() < 10) {
193 top_highest_values = channel_tp_rate_vec.size();
194 }
195 //datahandlinglibs::opmon::TPChannelsInfo channels_info;
196 for (int i = 0; i < top_highest_values; i++) {
197 datahandlinglibs::opmon::TPChannelInfo tpc_info;
198 tpc_info.set_number_of_tps(channel_tp_rate_vec[i].second);
199 tpc_info.set_channel_id(channel_tp_rate_vec[i].first);
200 publish(std::move(tpc_info), {{"channel", std::to_string(channel_tp_rate_vec[i].first)}});
201 }
202 }
203
204 // Reset the counter in the channel rate map
205 for (auto& el : m_tp_channel_rate_map) {
206 el.second = 0;
207 }
208 m_t0 = now;
209 }
211 }
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
void publish(google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
static int64_t now()
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ sequence_check()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::sequence_check ( frameptr fp)
protected

Pipeline Stage 1.: Check proper sequence id increments in DAQ Eth header

Pipeline Stage 1.: Check proper timestamp increments in WIB frame

Definition at line 218 of file WIBEthFrameProcessor.cpp.

219{
220 // FIXME: Make source emulator deal with this! Hard to do since source emu is templated...
221 /* If EMU data, emulate perfectly incrementing timestamp
222 if (m_emulator_mode) {
223 // uint64_t ts_next = m_previous_seq_id + 1; // NOLINT(build/unsigned)
224 auto wf = reinterpret_cast<wibframeptr>(((uint8_t*)fp)); // NOLINT
225 for (unsigned int i = 0; i < fp->get_num_frames(); ++i) { // NOLINT(build/unsigned)
226 //auto wfh = const_cast<dunedaq::fddetdataformats::WIBEthFrame*>(wf->header());
227 wf->daq_header.crate_id = m_crate_id;
228 wf->daq_header.slot_id = m_slot_id;
229 wf->daq_header.stream_id = m_stream_id;
230 wf->daq_header.seq_id = (m_previous_seq_id+i) & 0xfff;
231 wf++;
232 }
233 }
234 */
235
236 // Acquire timestamp
237 auto wfptr = reinterpret_cast<dunedaq::fddetdataformats::WIBEthFrame*>(fp); // NOLINT
239
240 // Check sequence id
241 // Calculate the next sequence id (12 bits)
242 uint16_t expected_seq_id = (m_previous_seq_id + fp->get_num_frames()) & 0xfff;
243 int16_t delta_seq_id = m_current_seq_id-expected_seq_id;
244 if ( delta_seq_id > 0x800) {
245 delta_seq_id -= 0x1000;
246 } else if ( delta_seq_id < -0x7ff) {
247 delta_seq_id += 0x1000;
248 }
249
250 if (delta_seq_id == 0) {
251 m_seq_id_error_state = false;
252 } else {
253 // uint16_t delta_seq_id = (m_current_seq_id-expected_seq_id);
255 m_seq_id_max_jump = std::max(delta_seq_id, m_seq_id_max_jump.load());
256 m_seq_id_min_jump = std::min(delta_seq_id, m_seq_id_min_jump.load());
257
258 if (m_first_seq_id_mismatch) { // log once
259 TLOG_DEBUG(TLVL_BOOKKEEPING) << "First sequence id MISMATCH! -> | previous: " << std::to_string(m_previous_seq_id) << " current: " + std::to_string(m_current_seq_id);
261 } else {
263 m_error_registry->add_error("Sequence ID jump", datahandlinglibs::FrameErrorRegistry::ErrorInterval(expected_seq_id, m_current_seq_id));
265 }
266 }
267 }
268
269 if (m_seq_id_error_ctr > 1000) {
271 TLOG() << "*** Data Integrity ERROR *** Sequence ID continuity is completely broken! "
272 << "Something is wrong with the FE source or with the configuration!";
274 }
275 }
276
278
279}
detdataformats::DAQEthHeader daq_header
#define TLOG(...)
Definition macro.hpp:22

◆ start()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::start ( const nlohmann::json & )
overridevirtual

Start operation.

Reimplemented from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< types::DUNEWIBEthTypeAdapter >.

Definition at line 37 of file WIBEthFrameProcessor.cpp.

38{
39 // Reset software TPG resources
43 }
44
45 // Reset timestamp check
46 m_previous_ts = 0;
47 m_current_ts = 0;
50 m_ts_error_state = false;
52
57
58
59 // Reset stats
60 m_t0 = std::chrono::high_resolution_clock::now();
61 m_new_hits = 0;
62 m_new_tps = 0;
63 m_tpg_hits_count.exchange(0);
64 inherited::start(args);
65}
dunedaq::daqdataformats::timestamp_t m_current_ts
dunedaq::daqdataformats::timestamp_t m_previous_ts

◆ stop()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::stop ( const nlohmann::json & )
overridevirtual

◆ timestamp_check()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::timestamp_check ( frameptr fp)
protected

Pipeline Stage 1.: Check proper timestamp increments in DAQ Eth header

Pipeline Stage 1.: Check proper timestamp increments in WIB frame

Definition at line 285 of file WIBEthFrameProcessor.cpp.

286{
287
288 uint16_t wibeth_tick_difference = types::DUNEWIBEthTypeAdapter::expected_tick_difference;
289 uint16_t wibeth_frame_tick_difference = wibeth_tick_difference * fp->get_num_frames();
290
291 // FIXME: let source emulator deal with this!
292 /* If EMU data, emulate perfectly incrementing timestamp
293 if (m_emulator_mode) { // emulate perfectly incrementing timestamp
294 uint64_t ts_next = m_previous_ts + wibeth_frame_tick_difference; // NOLINT(build/unsigned)
295 auto wf = reinterpret_cast<wibframeptr>(((uint8_t*)fp)); // NOLINT
296 for (unsigned int i = 0; i < fp->get_num_frames(); ++i) { // NOLINT(build/unsigned)
297 //auto wfh = const_cast<dunedaq::fddetdataformats::WIBEthFrame*>(wf->header());
298 wf->daq_header.crate_id = m_crate_id;
299 wf->daq_header.slot_id = m_slot_id;
300 wf->daq_header.stream_id = m_stream_id;
301 wf->set_timestamp(ts_next);
302 ts_next += wibeth_tick_difference;
303 wf++;
304 }
305 }*/
306
307 auto wfptr = reinterpret_cast<dunedaq::fddetdataformats::WIBEthFrame*>(fp); // NOLINT
308 m_current_ts = wfptr->get_timestamp();
309
310 // Check timestamp
311 if (m_previous_ts > 0 &&
312 m_current_ts - m_previous_ts != wibeth_frame_tick_difference) [[unlikely]] {
314 if (m_first_ts_missmatch) { // log once
315 TLOG_DEBUG(TLVL_BOOKKEEPING) << "First timestamp MISMATCH! -> | previous: " << std::to_string(m_previous_ts) << " current: " + std::to_string(m_current_ts);
316 m_first_ts_missmatch = false;
317 } else {
318 if (!m_ts_error_state) {
319 m_error_registry->add_error("Timestamp jump", datahandlinglibs::FrameErrorRegistry::ErrorInterval(m_previous_ts + wibeth_frame_tick_difference, m_current_ts));
320 m_ts_error_state = true;
321 }
322 }
323 } else {
324 m_ts_error_state = false;
325 }
326
327 if (m_ts_error_ctr > 1000) {
329 TLOG() << "*** Data Integrity ERROR *** Timestamp continuity is completely broken! "
330 << "Something is wrong with the FE source or with the configuration!";
332 }
333 }
334
337}
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.

◆ use_pattern_generator()

void dunedaq::fdreadoutlibs::WIBEthFrameProcessor::use_pattern_generator ( frameptr fp)
protected

Pipeline Stage 0: Pattern generator for hit finding in emulated mode

Member Data Documentation

◆ m_channel_map

std::shared_ptr<detchannelmaps::TPCChannelMap> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_channel_map
private

Definition at line 142 of file WIBEthFrameProcessor.hpp.

◆ m_channel_mask_set

std::set<unsigned int> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_channel_mask_set
private

Definition at line 126 of file WIBEthFrameProcessor.hpp.

◆ m_channel_plane_numbers

std::vector<std::pair<trgdataformats::channel_t, int16_t> > dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_channel_plane_numbers
private

Definition at line 146 of file WIBEthFrameProcessor.hpp.

◆ m_crate_id

uint32_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_crate_id
private

Definition at line 137 of file WIBEthFrameProcessor.hpp.

◆ m_current_seq_id

uint16_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_current_seq_id = 0
protected

Definition at line 79 of file WIBEthFrameProcessor.hpp.

◆ m_current_ts

dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_current_ts = 0
protected

Definition at line 76 of file WIBEthFrameProcessor.hpp.

◆ m_det_id

uint32_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_det_id
private

Definition at line 136 of file WIBEthFrameProcessor.hpp.

◆ m_emulator_mode

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_emulator_mode = false
private

Definition at line 140 of file WIBEthFrameProcessor.hpp.

◆ m_err_frame_sink

std::shared_ptr<iomanager::SenderConcept<fddetdataformats::WIBEthFrame> > dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_err_frame_sink
private

Definition at line 150 of file WIBEthFrameProcessor.hpp.

◆ m_first_hit

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_first_hit = true
private

Definition at line 122 of file WIBEthFrameProcessor.hpp.

◆ m_first_seq_id_mismatch

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_first_seq_id_mismatch = true
protected

Definition at line 89 of file WIBEthFrameProcessor.hpp.

◆ m_first_ts_missmatch

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_first_ts_missmatch = true
protected

Definition at line 84 of file WIBEthFrameProcessor.hpp.

◆ m_frame_counter

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_frame_counter { 0 }
private

Definition at line 160 of file WIBEthFrameProcessor.hpp.

160{ 0 };

◆ m_new_hits

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_new_hits { 0 }
private

Definition at line 156 of file WIBEthFrameProcessor.hpp.

156{ 0 }; // NOLINT(build/unsigned)

◆ m_new_tps

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_new_tps { 0 }
private

Definition at line 157 of file WIBEthFrameProcessor.hpp.

157{ 0 }; // NOLINT(build/unsigned)

◆ m_num_msg

size_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_num_msg = 0
private

Definition at line 131 of file WIBEthFrameProcessor.hpp.

◆ m_num_push_fail

size_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_num_push_fail = 0
private

Definition at line 132 of file WIBEthFrameProcessor.hpp.

◆ m_pattern_generator_current_ts

dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_pattern_generator_current_ts = 0
protected

Definition at line 82 of file WIBEthFrameProcessor.hpp.

◆ m_pattern_generator_previous_ts

dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_pattern_generator_previous_ts = 0
protected

Definition at line 81 of file WIBEthFrameProcessor.hpp.

◆ m_previous_seq_id

uint16_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_previous_seq_id = 0
protected

Definition at line 78 of file WIBEthFrameProcessor.hpp.

◆ m_previous_ts

dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_previous_ts = 0
protected

Definition at line 75 of file WIBEthFrameProcessor.hpp.

◆ m_seq_id_error_ctr

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_seq_id_error_ctr { 0 }
protected

Definition at line 92 of file WIBEthFrameProcessor.hpp.

92{ 0 };

◆ m_seq_id_error_state

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_seq_id_error_state = false
protected

Definition at line 91 of file WIBEthFrameProcessor.hpp.

◆ m_seq_id_max_jump

std::atomic<int16_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_seq_id_max_jump { 0 }
protected

Definition at line 94 of file WIBEthFrameProcessor.hpp.

94{ 0 };

◆ m_seq_id_min_jump

std::atomic<int16_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_seq_id_min_jump { 0 }
protected

Definition at line 93 of file WIBEthFrameProcessor.hpp.

93{ 0 };

◆ m_seq_id_problem_reported

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_seq_id_problem_reported = false
protected

Definition at line 90 of file WIBEthFrameProcessor.hpp.

◆ m_slot_id

uint32_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_slot_id
private

Definition at line 138 of file WIBEthFrameProcessor.hpp.

◆ m_sourceid

daqdataformats::SourceID dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_sourceid
private

Definition at line 154 of file WIBEthFrameProcessor.hpp.

◆ m_stream_id

uint32_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_stream_id
private

Definition at line 139 of file WIBEthFrameProcessor.hpp.

◆ m_t0

std::chrono::time_point<std::chrono::high_resolution_clock> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_t0
private

Definition at line 162 of file WIBEthFrameProcessor.hpp.

◆ m_tp_channel_rate_map

std::map<uint, std::atomic<int> > dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tp_channel_rate_map
private

Definition at line 129 of file WIBEthFrameProcessor.hpp.

◆ m_tp_generator

std::unique_ptr<tpglibs::TPGenerator> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tp_generator
private

Definition at line 123 of file WIBEthFrameProcessor.hpp.

◆ m_tp_max_width

uint32_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tp_max_width
private

Definition at line 125 of file WIBEthFrameProcessor.hpp.

◆ m_tp_sink

std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter> > > dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tp_sink[3]
private

Definition at line 149 of file WIBEthFrameProcessor.hpp.

◆ m_tpa_vectors

std::vector<trigger::TriggerPrimitiveTypeAdapter> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tpa_vectors[3]
private

Definition at line 147 of file WIBEthFrameProcessor.hpp.

◆ m_tpg_configs

std::vector<std::pair<std::string, nlohmann::json> > dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tpg_configs
private

Definition at line 124 of file WIBEthFrameProcessor.hpp.

◆ m_tpg_hits_count

std::atomic<int> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tpg_hits_count { 0 }
private

Definition at line 134 of file WIBEthFrameProcessor.hpp.

134{ 0 };

◆ m_tpg_threshold_selected

uint16_t dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tpg_threshold_selected
private

Definition at line 127 of file WIBEthFrameProcessor.hpp.

◆ m_tps_send_failed

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tps_send_failed { 0 }
private

Definition at line 159 of file WIBEthFrameProcessor.hpp.

159{ 0 };

◆ m_tps_suppressed_too_long

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_tps_suppressed_too_long { 0 }
private

Definition at line 158 of file WIBEthFrameProcessor.hpp.

158{ 0 };

◆ m_ts_error_ctr

std::atomic<uint64_t> dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_ts_error_ctr { 0 }
protected

Definition at line 87 of file WIBEthFrameProcessor.hpp.

87{ 0 };

◆ m_ts_error_state

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_ts_error_state = false
protected

Definition at line 86 of file WIBEthFrameProcessor.hpp.

◆ m_ts_problem_reported

bool dunedaq::fdreadoutlibs::WIBEthFrameProcessor::m_ts_problem_reported = false
protected

Definition at line 85 of file WIBEthFrameProcessor.hpp.


The documentation for this class was generated from the following files: