DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter > Class Template Reference

#include <TPCEthFrameProcessor.hpp>

Inheritance diagram for dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >:
[legend]
Collaboration diagram for dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >:
[legend]

Public Types

using inherited = datahandlinglibs::TaskRawDataProcessorModel<ReadoutTypeAdapter>
using frameptr = ReadoutTypeAdapter*
using constframeptr = const ReadoutTypeAdapter*
using tpcframeptr = ReadoutTypeAdapter::FrameType*
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

 TPCEthFrameProcessor (std::unique_ptr< datahandlinglibs::FrameErrorRegistry > &error_registry, bool processing_enabled)
void start (const appfwk::DAQModule::CommandData_t &args) override
 Start operation.
void stop (const appfwk::DAQModule::CommandData_t &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.
void scrap (const appfwk::DAQModule::CommandData_t &cfg) override
 Unconfigure.
Public Member Functions inherited from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< ReadoutTypeAdapter >
 TaskRawDataProcessorModel (std::unique_ptr< FrameErrorRegistry > &error_registry, bool post_processing_enabled)
 ~TaskRawDataProcessorModel ()
void reset_last_daq_time ()
std::uint64_t get_last_daq_time () override
 Get newest timestamp of last seen packet.
void preprocess_item (ReadoutTypeAdapter *item) override
 Preprocess one element.
void postprocess_item (const ReadoutTypeAdapter *item) override
 Postprocess one element.
void invoke_postprocess_schedule_timeout_policy (std::uint64_t accumilated_timeout_ticks) override
 Handle postprocess timeout event.
void add_preprocess_task (Task &&task)
void add_postprocess_task (Task &&task)
void invoke_all_preprocess_functions (ReadoutTypeAdapter *item)
void launch_all_preprocess_functions (ReadoutTypeAdapter *item)
Public Member Functions inherited from dunedaq::datahandlinglibs::RawDataProcessorConcept< ReadoutType >
 RawDataProcessorConcept ()
virtual ~RawDataProcessorConcept ()
 RawDataProcessorConcept (const RawDataProcessorConcept &)=delete
 RawDataProcessorConcept is not copy-constructible.
RawDataProcessorConcept & operator= (const RawDataProcessorConcept &)=delete
 RawDataProcessorConcept is not copy-assginable.
 RawDataProcessorConcept (RawDataProcessorConcept &&)=delete
 RawDataProcessorConcept is not move-constructible.
RawDataProcessorConcept & operator= (RawDataProcessorConcept &&)=delete
 RawDataProcessorConcept is not move-assignable.
virtual void preprocess_item (ReadoutType *item)=0
 Preprocess one element.
virtual void postprocess_item (const ReadoutType *item)=0
 Postprocess one element.
Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject (const MonitorableObject &)=delete
MonitorableObject & operator= (const MonitorableObject &)=delete
 MonitorableObject (MonitorableObject &&)=delete
MonitorableObject & operator= (MonitorableObject &&)=delete
virtual ~MonitorableObject ()=default
auto get_opmon_id () const noexcept
auto get_opmon_level () const noexcept

Protected Member Functions

void generate_opmon_data () override
void configure_source_and_geo_ids (const appmodel::DataHandlerModule *conf)
void configure_preprocessing (const appmodel::DataHandlerModule *conf)
void configure_postprocessing (const appmodel::DataHandlerModule *conf)
void configure_channel_plane_numbers (const appmodel::TPCRawDataProcessor *proc_conf)
void configure_find_tps (const appmodel::DataHandlerModule *conf, const appmodel::TPCRawDataProcessor *proc_conf)
void scrap_source_and_geo_ids ()
void scrap_preprocessing ()
void scrap_postprocessing ()
void scrap_channel_plane_numbers ()
void scrap_find_tps ()
void sequence_check (frameptr fp)
void timestamp_check (frameptr fp)
void find_tps (constframeptr fp)
Protected Member Functions inherited from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< ReadoutTypeAdapter >
void run_post_processing_thread (std::function< void(const ReadoutTypeAdapter *)> &function, folly::ProducerConsumerQueue< const ReadoutTypeAdapter * > &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

bool m_emulator_mode = false
bool m_first_frame = true
dunedaq::daqdataformats::timestamp_t m_previous_ts = 0
dunedaq::daqdataformats::timestamp_t m_current_ts = 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 }
uint16_t m_previous_seq_id = 0
uint16_t m_current_seq_id = 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 }
std::unique_ptr< tpglibs::TPGenerator > m_tp_generator
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
std::unordered_map< unsigned int, std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > > m_plane_to_tp_sink_map
uint32_t m_tp_count_limit = 0
uint32_t m_frame_count_limit = 0
uint32_t m_current_tp_count = 0
uint32_t m_frame_count_at_last_send = 0
bool m_tp_limit_enabled = false
bool m_frame_limit_enabled = false
std::set< unsigned int > m_channel_mask_set
std::set< unsigned int > m_plane_numbers_set
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
std::unordered_map< trgdataformats::channel_t, unsigned int > m_channel_plane_map
bool m_tpg_metric_collect_enabled { false }
uint32_t m_metric_collect_opmon_period { 128 }
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
std::atomic< uint64_t > m_num_new_tps { 0 }
std::atomic< uint64_t > m_tps_suppressed_too_long { 0 }
std::atomic< uint64_t > m_tps_send_failed { 0 }
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
std::atomic< uint64_t > m_frame_counter { 0 }
uint32_t m_det_id
uint32_t m_crate_id
uint32_t m_slot_id
uint32_t m_stream_id
daqdataformats::SourceID m_sourceid
Protected Attributes inherited from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< ReadoutTypeAdapter >
std::vector< std::function< void(ReadoutTypeAdapter *)> > 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 ReadoutTypeAdapter *)> > m_post_process_functions
std::vector< std::unique_ptr< folly::ProducerConsumerQueue< const ReadoutTypeAdapter * > > > 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

Additional Inherited Members

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

Detailed Description

template<class ReadoutTypeAdapter>
class dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >

Definition at line 60 of file TPCEthFrameProcessor.hpp.

Member Typedef Documentation

◆ constframeptr

template<class ReadoutTypeAdapter>
using dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::constframeptr = const ReadoutTypeAdapter*

Definition at line 66 of file TPCEthFrameProcessor.hpp.

◆ frameptr

template<class ReadoutTypeAdapter>
using dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::frameptr = ReadoutTypeAdapter*

Definition at line 65 of file TPCEthFrameProcessor.hpp.

◆ inherited

template<class ReadoutTypeAdapter>
using dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::inherited = datahandlinglibs::TaskRawDataProcessorModel<ReadoutTypeAdapter>

Definition at line 64 of file TPCEthFrameProcessor.hpp.

◆ tpcframeptr

template<class ReadoutTypeAdapter>
using dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::tpcframeptr = ReadoutTypeAdapter::FrameType*

Definition at line 67 of file TPCEthFrameProcessor.hpp.

Constructor & Destructor Documentation

◆ TPCEthFrameProcessor()

template<class ReadoutTypeAdapter>
dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::TPCEthFrameProcessor ( std::unique_ptr< datahandlinglibs::FrameErrorRegistry > & error_registry,
bool processing_enabled )
explicit

Member Function Documentation

◆ conf()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::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< ReadoutTypeAdapter >.

Definition at line 259 of file TPCEthFrameProcessor.hxx.

260{
262
264
265 if (this->m_post_processing_enabled) {
267 }
268
270}
void conf(const appmodel::DataHandlerModule *conf) override
void configure_postprocessing(const appmodel::DataHandlerModule *conf)
void configure_source_and_geo_ids(const appmodel::DataHandlerModule *conf)
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.

◆ configure_channel_plane_numbers()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::configure_channel_plane_numbers ( const appmodel::TPCRawDataProcessor * proc_conf)
protected

Definition at line 100 of file TPCEthFrameProcessor.hxx.

102{
105 const std::vector<unsigned int> channel_mask_vec = proc_conf->get_channel_mask();
106
107 for (int chan = 0; chan < 64; chan++) {
108 trgdataformats::channel_t off_channel = channel_map->get_offline_channel_from_det_crate_slot_stream_chan(
110 int16_t plane = channel_map->get_plane_from_offline_channel(off_channel);
112
113 // This processor only needs to handle some (maybe 0) of the masked channels.
114 // Only get those relevant channels for the later check.
115 // Only get the planes for the channels that are not masked.
118 } else {
121 }
122 }
123}
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
std::unordered_map< trgdataformats::channel_t, unsigned int > m_channel_plane_map

◆ configure_find_tps()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::configure_find_tps ( const appmodel::DataHandlerModule * conf,
const appmodel::TPCRawDataProcessor * proc_conf )
protected

Definition at line 127 of file TPCEthFrameProcessor.hxx.

129{
130 // Setting TP sinks.
131 // Configurations currently have the sinks iterate in order, but there may be more sinks than planes.
132 int plane_number = 0;
133 for (auto output : conf->get_outputs()) {
134 try {
135 if (output->get_data_type() == "TriggerPrimitiveVector") {
136 if (m_plane_numbers_set.contains(plane_number)) {
139 }
140 plane_number++;
141 }
142 } catch (const ers::Issue& excpt) {
143 ers::error(datahandlinglibs::ResourceQueueError(ERS_HERE, "tp", "DefaultRequestHandlerModel", excpt));
144 }
145 }
146
147 // We do need a coverage for all planes.
148 if (m_plane_numbers_set.size() > m_plane_to_tp_sink_map.size()) {
150 }
151
153
154 // Set the minimum TP samples over threshold.
155 auto conf_sot_minima = proc_conf->get_sot_minima();
156 std::vector<uint16_t> sot_minima{ conf_sot_minima->get_sot_minimum_plane0(),
157 conf_sot_minima->get_sot_minimum_plane1(),
158 conf_sot_minima->get_sot_minimum_plane2() };
159 m_tp_generator->set_sot_minima(sot_minima);
160
162 for (auto step : processing_steps) {
163 m_tpg_configs.push_back(std::make_pair(step->class_name(), step->to_json(false).back()));
164 }
165
166 // Let the TPG generator configure
168
169 // Set the limits on when to send TPs and check that we can actually send on these limits.
170 m_frame_count_limit = proc_conf->get_frame_count_limit();
171 m_tp_count_limit = proc_conf->get_tp_count_limit();
174
177 }
178
179 m_metric_collect_opmon_period = proc_conf->get_metric_collect_opmon_period();
180
181#ifdef TPGLIBS_ENABLE_STATE_MONITORING
182 // Monitoring enabled at build time — set up harvester
183 // Still read toggle_state for backwards compat (honor it for now)
185 for (const auto& name_config : m_tpg_configs) {
186 if (name_config.second.contains("metric_collect_toggle_state") &&
187 name_config.second["metric_collect_toggle_state"] == true) {
189 break;
190 }
191 }
192
194 auto processsor_references = m_tp_generator->get_all_processor_references_with_pipeline_index();
195
197
200
201 TLOG_DEBUG(TLVL_BOOKKEEPING) << "Configuring state harvester with " << static_cast<int>(channels_per_pipeline)
202 << " channels per pipeline, " << static_cast<int>(pipelines) << " pipelines, "
203 << processsor_references.size() << " processor references";
204
206 m_state_harvester->set_processor_references(processsor_references);
207
208 m_state_harvester->start_collection_thread();
209
210 TLOG_DEBUG(TLVL_BOOKKEEPING) << "State harvester configured and started successfully";
211 }
212
213#else
214 // Monitoring disabled at build time
216
217 // Warn if per-processor monitoring params are configured but will have no effect
218 bool warned_build_off = false;
219 for (const auto& name_config : m_tpg_configs) {
220 // Check if any of the monitoring configs are not the default values: someone is requesting them.
221 const bool toggle_state_set = name_config.second.value("metric_collect_toggle_state", false) == true;
222 const bool time_sample_period_set =
223 name_config.second.value("metric_collect_time_sample_period", uint64_t{ 256 }) != 256;
225 !name_config.second.value("requested_internal_states", std::string{}).empty();
227 // warn only once.
229 warned_build_off = true;
230 }
231 }
232#endif
233
236}
std::vector< std::pair< std::string, nlohmann::json > > m_tpg_configs
std::unique_ptr< tpglibs::TPGenerator > m_tp_generator
std::unordered_map< unsigned int, std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > > m_plane_to_tp_sink_map
void warning(const Issue &issue)
Definition ers.hpp:150
void error(const Issue &issue)
Definition ers.hpp:101

◆ configure_postprocessing()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::configure_postprocessing ( const appmodel::DataHandlerModule * conf)
protected

Definition at line 240 of file TPCEthFrameProcessor.hxx.

241{
242 const appmodel::DataProcessor* dp = conf->get_module_configuration()->get_data_processor();
243 if (dp == nullptr) {
244 return;
245 }
246
248 if (proc_conf == nullptr) {
249 return;
250 }
251
252 // Need TPCRawDataProcessor configurations to configure the following.
255}
void configure_channel_plane_numbers(const appmodel::TPCRawDataProcessor *proc_conf)
void configure_find_tps(const appmodel::DataHandlerModule *conf, const appmodel::TPCRawDataProcessor *proc_conf)

◆ configure_preprocessing()

◆ configure_source_and_geo_ids()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::configure_source_and_geo_ids ( const appmodel::DataHandlerModule * conf)
protected

Definition at line 71 of file TPCEthFrameProcessor.hxx.

72{
73 m_sourceid.id = conf->get_source_id();
75 auto geo_id = conf->get_geo_id();
76 if (geo_id != nullptr) {
77 m_det_id = geo_id->get_detector_id();
78 m_crate_id = geo_id->get_crate_id();
79 m_slot_id = geo_id->get_slot_id();
80 m_stream_id = geo_id->get_stream_id();
81 }
82}

◆ find_tps()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::find_tps ( constframeptr fp)
protected

Pipeline Stage 2.: Do software TPG

Definition at line 719 of file TPCEthFrameProcessor.hxx.

720{
721 if (!fp)
722 return;
723 auto wfptr = reinterpret_cast<tpcframeptr>((uint8_t*)fp); // NOLINT
724
726
728
729#ifdef TPGLIBS_ENABLE_STATE_MONITORING
731 m_state_harvester->trigger_harvest();
732 }
733#endif
734
735 for (const auto& tp : tps) {
736 // If this TP is on a masked channel, skip it.
738 continue;
739 // Need to move into a type adapter.
741 tpa.tp = tp;
742
743 tpa.tp.detid = m_det_id; // Last missing piece.
747 }
748
749 const bool frame_limit_reached =
752
757 int num_new_tps = tpa_vector.size();
758 if (num_new_tps == 0) {
759 continue;
760 }
761 const auto ts_begin = tpa_vector.front().tp.time_start;
762 const auto channel_begin = tpa_vector.front().tp.channel;
763 const auto ts_end = tpa_vector.back().tp.time_start;
764 const auto channel_end = tpa_vector.back().tp.channel;
768 } else {
770 }
771 }
772 }
773 return;
774}
std::unordered_map< unsigned int, std::vector< trigger::TriggerPrimitiveTypeAdapter > > m_plane_to_tpa_vector_map
std::map< uint, std::atomic< int > > m_tp_channel_rate_map

◆ generate_opmon_data()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::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< ReadoutTypeAdapter >.

Definition at line 366 of file TPCEthFrameProcessor.hxx.

367{
369
370 info.set_num_seq_id_errors(m_seq_id_error_ctr.load());
371 info.set_min_seq_id_jump(m_seq_id_min_jump.exchange(0));
372 info.set_max_seq_id_jump(m_seq_id_max_jump.exchange(0));
373
374 info.set_num_ts_errors(m_ts_error_ctr.load());
375
376 this->publish(std::move(info));
377
378 this->m_error_registry->log_registered_errors();
379
380 if (this->m_post_processing_enabled) {
382 int num_new_tps = m_num_new_tps.exchange(0);
386 TLOG_DEBUG(TLVL_BOOKKEEPING) << "TP rate: " << std::to_string(num_new_tps / seconds / 1000.) << " [kHz]";
387 TLOG_DEBUG(TLVL_BOOKKEEPING) << "Total new TPs: " << num_new_tps;
388
390 tp_info.set_rate_tp_hits(num_new_tps / seconds / 1000.);
391
392 tp_info.set_num_tps_sent(num_new_tps);
393 tp_info.set_num_tps_suppressed_too_long(num_new_tps_suppressed_too_long);
394 tp_info.set_num_tps_send_failed(num_new_tps_send_failed);
395
396 this->publish(std::move(tp_info));
397 // Find the channels with the top TP rates
398 // Create a vector of pairs to store the map elements
400 // Sort the vector in descending order of the value of the pairs
402 return a.second > b.second;
403 });
404 // Add the metrics to opmon
405 // For convenience we are selecting only the top 10 elements
406 if (channel_tp_rate_vec.size() != 0) {
407 int top_highest_values = 10;
408 if (channel_tp_rate_vec.size() < 10) {
410 }
411 // datahandlinglibs::opmon::TPChannelsInfo channels_info;
412 for (int i = 0; i < top_highest_values; i++) {
414 tpc_info.set_number_of_tps(channel_tp_rate_vec[i].second);
415 tpc_info.set_channel_id(channel_tp_rate_vec[i].first);
416 this->publish(std::move(tpc_info), { { "channel", std::to_string(channel_tp_rate_vec[i].first) } });
417 }
418 }
419
420 // Reset the counter in the channel rate map
421 for (auto& el : m_tp_channel_rate_map) {
422 el.second = 0;
423 }
424 m_t0 = now;
425
426#ifdef TPGLIBS_ENABLE_STATE_MONITORING
430 }
431#endif
432 }
433
435}
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

◆ scrap()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::scrap ( const appfwk::DAQModule::CommandData_t & args)
overridevirtual

◆ scrap_channel_plane_numbers()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::scrap_channel_plane_numbers ( )
protected

◆ scrap_find_tps()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::scrap_find_tps ( )
protected

◆ scrap_postprocessing()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::scrap_postprocessing ( )
protected

Definition at line 319 of file TPCEthFrameProcessor.hxx.

320{
321 // Channel-plane variables
322 m_channel_mask_set.clear();
323 m_plane_numbers_set.clear();
325 m_channel_plane_map.clear();
326
327 // TP variables
328 m_tp_generator->reset();
329 m_tpg_configs.clear();
332
333 m_frame_limit_enabled = false;
334 m_tp_limit_enabled = false;
338
339 // OpMon variables
342 m_tp_channel_rate_map.clear();
343 m_num_new_tps.exchange(0);
344 m_tps_suppressed_too_long.exchange(0);
345 m_tps_send_failed.exchange(0);
346 m_frame_counter.exchange(0);
348}

◆ scrap_preprocessing()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::scrap_preprocessing ( )
protected

Definition at line 286 of file TPCEthFrameProcessor.hxx.

287{
288 m_emulator_mode = false;
289 m_first_frame = true;
290
291 // Timestamps.
292 m_previous_ts = 0;
293 m_current_ts = 0;
294
297
299 m_ts_problem_reported = false;
300 m_ts_error_state = false;
301 m_ts_error_ctr = 0;
302
303 // Sequence ID.
306
309 m_seq_id_error_state = false;
313
314 // The preprocessing tasks scrap is handled by inherited::scrap().
315}
dunedaq::daqdataformats::timestamp_t m_previous_ts
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

◆ scrap_source_and_geo_ids()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::scrap_source_and_geo_ids ( )
protected

Definition at line 274 of file TPCEthFrameProcessor.hxx.

275{
277
278 m_det_id = 0;
279 m_crate_id = 0;
280 m_slot_id = 0;
281 m_stream_id = 0;
282}

◆ sequence_check()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::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 TPC frame

Definition at line 605 of file TPCEthFrameProcessor.hxx.

606{
607 // Acquire timestamp
608 auto wfptr = reinterpret_cast<tpcframeptr>(fp); // NOLINT
609 m_current_seq_id = wfptr->daq_header.seq_id;
610
611 // Check that the system is properly configured from the first frame.
612 if (m_first_frame) [[unlikely]] {
613 if (wfptr->daq_header.crate_id != m_crate_id || wfptr->daq_header.slot_id != m_slot_id ||
614 wfptr->daq_header.stream_id != m_stream_id) {
616 wfptr->daq_header.crate_id,
617 wfptr->daq_header.slot_id,
618 wfptr->daq_header.stream_id,
620 m_slot_id,
621 m_stream_id));
622 }
623
624 m_first_frame = false;
625 }
626
627 // Check sequence id
628 // Calculate the next sequence id (12 bits)
629 uint16_t expected_seq_id = (m_previous_seq_id + fp->get_num_frames()) & 0xfff;
631 if (delta_seq_id > 0x800) {
632 delta_seq_id -= 0x1000;
633 } else if (delta_seq_id < -0x7ff) {
634 delta_seq_id += 0x1000;
635 }
636
637 if (delta_seq_id == 0) {
638 m_seq_id_error_state = false;
639 } else {
640 // uint16_t delta_seq_id = (m_current_seq_id-expected_seq_id);
644
645 if (m_first_seq_id_mismatch) { // log once
646 TLOG_DEBUG(TLVL_BOOKKEEPING) << "First sequence id MISMATCH! -> | previous: " << std::to_string(m_previous_seq_id)
647 << " current: " + std::to_string(m_current_seq_id);
649 } else {
651 this->m_error_registry->add_error(
654 }
655 }
656 }
657
658 if (m_seq_id_error_ctr > 1000) {
660 TLOG() << "*** Data Integrity ERROR *** Sequence ID continuity is completely broken! "
661 << "Something is wrong with the FE source or with the configuration!";
663 }
664 }
665
667}

◆ start()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::start ( const appfwk::DAQModule::CommandData_t & args)
overridevirtual

Start operation.

Reimplemented from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< ReadoutTypeAdapter >.

Definition at line 20 of file TPCEthFrameProcessor.hxx.

21{
22 // Reset software TPG resources
23 if (this->m_post_processing_enabled) {
26 }
27
28 // Reset timestamp check
29 m_previous_ts = 0;
30 m_current_ts = 0;
33 m_ts_error_state = false;
35
40
41 // Reset stats
43 m_num_new_tps.exchange(0);
44
45#ifdef TPGLIBS_ENABLE_STATE_MONITORING
47 m_state_harvester->start_collection_thread();
48 }
49#endif
51}
void start(const appfwk::DAQModule::CommandData_t &) override

◆ stop()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::stop ( const appfwk::DAQModule::CommandData_t & args)
overridevirtual

Stop operation.

Reimplemented from dunedaq::datahandlinglibs::TaskRawDataProcessorModel< ReadoutTypeAdapter >.

Definition at line 55 of file TPCEthFrameProcessor.hxx.

56{
58 if (this->m_post_processing_enabled) {
59#ifdef TPGLIBS_ENABLE_STATE_MONITORING
61 m_state_harvester->stop_collection_thread();
62 }
63#endif
64 // Clears the pipelines and resets with the given configs.
66 }
67}
void stop(const appfwk::DAQModule::CommandData_t &) override

◆ timestamp_check()

template<class ReadoutTypeAdapter>
void dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::timestamp_check ( frameptr fp)
protected

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

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

Definition at line 674 of file TPCEthFrameProcessor.hxx.

675{
676
679
680 auto wfptr = reinterpret_cast<tpcframeptr>(fp); // NOLINT
681 m_current_ts = wfptr->get_timestamp();
682
683 // Check timestamp
686 if (m_first_ts_missmatch) { // log once
687 TLOG_DEBUG(TLVL_BOOKKEEPING) << "First timestamp MISMATCH! -> | previous: " << std::to_string(m_previous_ts)
688 << " current: " + std::to_string(m_current_ts);
689 m_first_ts_missmatch = false;
690 } else {
691 if (!m_ts_error_state) {
692 this->m_error_registry->add_error("Timestamp jump",
695 m_ts_error_state = true;
696 }
697 }
698 } else {
699 m_ts_error_state = false;
700 }
701
702 if (m_ts_error_ctr > 1000) {
704 TLOG() << "*** Data Integrity ERROR *** Timestamp continuity is completely broken! "
705 << "Something is wrong with the FE source or with the configuration!";
707 }
708 }
709
712}

Member Data Documentation

◆ m_channel_mask_set

template<class ReadoutTypeAdapter>
std::set<unsigned int> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_channel_mask_set
protected

Definition at line 181 of file TPCEthFrameProcessor.hpp.

◆ m_channel_plane_map

template<class ReadoutTypeAdapter>
std::unordered_map<trgdataformats::channel_t, unsigned int> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_channel_plane_map
protected

Definition at line 184 of file TPCEthFrameProcessor.hpp.

◆ m_channel_plane_numbers

template<class ReadoutTypeAdapter>
std::vector<std::pair<trgdataformats::channel_t, int16_t> > dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_channel_plane_numbers
protected

Definition at line 183 of file TPCEthFrameProcessor.hpp.

◆ m_crate_id

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_crate_id
protected

Definition at line 202 of file TPCEthFrameProcessor.hpp.

◆ m_current_seq_id

template<class ReadoutTypeAdapter>
uint16_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_current_seq_id = 0
protected

Definition at line 151 of file TPCEthFrameProcessor.hpp.

◆ m_current_tp_count

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_current_tp_count = 0
protected

Definition at line 174 of file TPCEthFrameProcessor.hpp.

◆ m_current_ts

template<class ReadoutTypeAdapter>
dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_current_ts = 0
protected

Definition at line 139 of file TPCEthFrameProcessor.hpp.

◆ m_det_id

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_det_id
protected

Definition at line 201 of file TPCEthFrameProcessor.hpp.

◆ m_emulator_mode

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_emulator_mode = false
protected

Definition at line 134 of file TPCEthFrameProcessor.hpp.

◆ m_first_frame

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_first_frame = true
protected

Definition at line 135 of file TPCEthFrameProcessor.hpp.

◆ m_first_seq_id_mismatch

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_first_seq_id_mismatch = true
protected

Definition at line 153 of file TPCEthFrameProcessor.hpp.

◆ m_first_ts_missmatch

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_first_ts_missmatch = true
protected

Definition at line 144 of file TPCEthFrameProcessor.hpp.

◆ m_frame_count_at_last_send

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_frame_count_at_last_send = 0
protected

Definition at line 175 of file TPCEthFrameProcessor.hpp.

◆ m_frame_count_limit

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_frame_count_limit = 0
protected

Definition at line 173 of file TPCEthFrameProcessor.hpp.

◆ m_frame_counter

template<class ReadoutTypeAdapter>
std::atomic<uint64_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_frame_counter { 0 }
protected

Definition at line 198 of file TPCEthFrameProcessor.hpp.

◆ m_frame_limit_enabled

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_frame_limit_enabled = false
protected

Definition at line 178 of file TPCEthFrameProcessor.hpp.

◆ m_metric_collect_opmon_period

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_metric_collect_opmon_period { 128 }
protected

Definition at line 188 of file TPCEthFrameProcessor.hpp.

◆ m_num_new_tps

template<class ReadoutTypeAdapter>
std::atomic<uint64_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_num_new_tps { 0 }
protected

Definition at line 192 of file TPCEthFrameProcessor.hpp.

◆ m_pattern_generator_current_ts

template<class ReadoutTypeAdapter>
dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_pattern_generator_current_ts = 0
protected

Definition at line 142 of file TPCEthFrameProcessor.hpp.

◆ m_pattern_generator_previous_ts

template<class ReadoutTypeAdapter>
dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_pattern_generator_previous_ts = 0
protected

Definition at line 141 of file TPCEthFrameProcessor.hpp.

◆ m_plane_numbers_set

template<class ReadoutTypeAdapter>
std::set<unsigned int> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_plane_numbers_set
protected

Definition at line 182 of file TPCEthFrameProcessor.hpp.

◆ m_plane_to_tp_sink_map

template<class ReadoutTypeAdapter>
std::unordered_map<unsigned int, std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter> > > > dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_plane_to_tp_sink_map
protected

Definition at line 170 of file TPCEthFrameProcessor.hpp.

◆ m_plane_to_tpa_vector_map

template<class ReadoutTypeAdapter>
std::unordered_map<unsigned int, std::vector<trigger::TriggerPrimitiveTypeAdapter> > dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_plane_to_tpa_vector_map
protected

Definition at line 167 of file TPCEthFrameProcessor.hpp.

◆ m_previous_seq_id

template<class ReadoutTypeAdapter>
uint16_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_previous_seq_id = 0
protected

Definition at line 150 of file TPCEthFrameProcessor.hpp.

◆ m_previous_ts

template<class ReadoutTypeAdapter>
dunedaq::daqdataformats::timestamp_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_previous_ts = 0
protected

Definition at line 138 of file TPCEthFrameProcessor.hpp.

◆ m_seq_id_error_ctr

template<class ReadoutTypeAdapter>
std::atomic<uint64_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_seq_id_error_ctr { 0 }
protected

Definition at line 156 of file TPCEthFrameProcessor.hpp.

◆ m_seq_id_error_state

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_seq_id_error_state = false
protected

Definition at line 155 of file TPCEthFrameProcessor.hpp.

◆ m_seq_id_max_jump

template<class ReadoutTypeAdapter>
std::atomic<int16_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_seq_id_max_jump { 0 }
protected

Definition at line 158 of file TPCEthFrameProcessor.hpp.

◆ m_seq_id_min_jump

template<class ReadoutTypeAdapter>
std::atomic<int16_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_seq_id_min_jump { 0 }
protected

Definition at line 157 of file TPCEthFrameProcessor.hpp.

◆ m_seq_id_problem_reported

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_seq_id_problem_reported = false
protected

Definition at line 154 of file TPCEthFrameProcessor.hpp.

◆ m_slot_id

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_slot_id
protected

Definition at line 203 of file TPCEthFrameProcessor.hpp.

◆ m_sourceid

template<class ReadoutTypeAdapter>
daqdataformats::SourceID dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_sourceid
protected

Definition at line 206 of file TPCEthFrameProcessor.hpp.

◆ m_stream_id

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_stream_id
protected

Definition at line 204 of file TPCEthFrameProcessor.hpp.

◆ m_t0

template<class ReadoutTypeAdapter>
std::chrono::time_point<std::chrono::high_resolution_clock> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_t0
protected

Definition at line 196 of file TPCEthFrameProcessor.hpp.

◆ m_tp_channel_rate_map

template<class ReadoutTypeAdapter>
std::map<uint, std::atomic<int> > dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tp_channel_rate_map
protected

Definition at line 190 of file TPCEthFrameProcessor.hpp.

◆ m_tp_count_limit

template<class ReadoutTypeAdapter>
uint32_t dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tp_count_limit = 0
protected

Definition at line 172 of file TPCEthFrameProcessor.hpp.

◆ m_tp_generator

template<class ReadoutTypeAdapter>
std::unique_ptr<tpglibs::TPGenerator> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tp_generator
protected

Definition at line 161 of file TPCEthFrameProcessor.hpp.

◆ m_tp_limit_enabled

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tp_limit_enabled = false
protected

Definition at line 177 of file TPCEthFrameProcessor.hpp.

◆ m_tpg_configs

template<class ReadoutTypeAdapter>
std::vector<std::pair<std::string, nlohmann::json> > dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tpg_configs
protected

Definition at line 165 of file TPCEthFrameProcessor.hpp.

◆ m_tpg_metric_collect_enabled

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tpg_metric_collect_enabled { false }
protected

Definition at line 187 of file TPCEthFrameProcessor.hpp.

◆ m_tps_send_failed

template<class ReadoutTypeAdapter>
std::atomic<uint64_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tps_send_failed { 0 }
protected

Definition at line 194 of file TPCEthFrameProcessor.hpp.

◆ m_tps_suppressed_too_long

template<class ReadoutTypeAdapter>
std::atomic<uint64_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_tps_suppressed_too_long { 0 }
protected

Definition at line 193 of file TPCEthFrameProcessor.hpp.

◆ m_ts_error_ctr

template<class ReadoutTypeAdapter>
std::atomic<uint64_t> dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_ts_error_ctr { 0 }
protected

Definition at line 147 of file TPCEthFrameProcessor.hpp.

◆ m_ts_error_state

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_ts_error_state = false
protected

Definition at line 146 of file TPCEthFrameProcessor.hpp.

◆ m_ts_problem_reported

template<class ReadoutTypeAdapter>
bool dunedaq::fdreadoutlibs::TPCEthFrameProcessor< ReadoutTypeAdapter >::m_ts_problem_reported = false
protected

Definition at line 145 of file TPCEthFrameProcessor.hpp.


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