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

#include <TDEEthFrameProcessor.hpp>

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

Public Types

using inherited = datahandlinglibs::TaskRawDataProcessorModel<types::TDEEthTypeAdapter>
 
using frameptr = types::TDEEthTypeAdapter*
 
using constframeptr = const types::TDEEthTypeAdapter*
 
using wibframeptr = dunedaq::fddetdataformats::TDEEthFrame*
 
- 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

 TDEEthFrameProcessor (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::TDEEthTypeAdapter >
 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::TDEEthTypeAdapter *item) override
 Preprocess one element.
 
void postprocess_item (const types::TDEEthTypeAdapter *item) override
 Postprocess one element.
 
void add_preprocess_task (Task &&task)
 
void add_postprocess_task (Task &&task)
 
void invoke_all_preprocess_functions (types::TDEEthTypeAdapter *item)
 
void launch_all_preprocess_functions (types::TDEEthTypeAdapter *item)
 
- Public Member Functions inherited from dunedaq::datahandlinglibs::RawDataProcessorConcept< types::TDEEthTypeAdapter >
 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::TDEEthTypeAdapter >
void run_post_processing_thread (std::function< void(const types::TDEEthTypeAdapter *)> &function, folly::ProducerConsumerQueue< const types::TDEEthTypeAdapter * > &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::TDEEthTypeAdapter >
std::vector< std::function< void(types::TDEEthTypeAdapter *)> > m_preprocess_functions
 
std::unique_ptr< FrameErrorRegistry > & m_error_registry
 
bool m_post_processing_enabled
 
std::atomic< boolm_run_marker
 
std::vector< std::function< void(const types::TDEEthTypeAdapter *)> > m_post_process_functions
 
std::vector< std::unique_ptr< folly::ProducerConsumerQueue< const types::TDEEthTypeAdapter * > > > 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::TDEEthFrame > > 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 TDEEthFrameProcessor.hpp.

Member Typedef Documentation

◆ constframeptr

◆ frameptr

◆ inherited

◆ wibframeptr

Constructor & Destructor Documentation

◆ TDEEthFrameProcessor()

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

Definition at line 32 of file TDEEthFrameProcessor.cpp.

33 : TaskRawDataProcessorModel<types::TDEEthTypeAdapter>(error_registry, processing_enabled)
34{
35}

Member Function Documentation

◆ conf()

void dunedaq::fdreadoutlibs::TDEEthFrameProcessor::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::TDEEthTypeAdapter >.

Definition at line 79 of file TDEEthFrameProcessor.cpp.

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

◆ find_hits()

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

Pipeline Stage 2.: Do software TPG

Definition at line 344 of file TDEEthFrameProcessor.cpp.

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

Definition at line 152 of file TDEEthFrameProcessor.cpp.

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

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

◆ start()

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

Start operation.

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

Definition at line 38 of file TDEEthFrameProcessor.cpp.

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

◆ stop()

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

◆ timestamp_check()

void dunedaq::fdreadoutlibs::TDEEthFrameProcessor::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 286 of file TDEEthFrameProcessor.cpp.

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

◆ use_pattern_generator()

void dunedaq::fdreadoutlibs::TDEEthFrameProcessor::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::TDEEthFrameProcessor::m_channel_map
private

Definition at line 142 of file TDEEthFrameProcessor.hpp.

◆ m_channel_mask_set

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

Definition at line 126 of file TDEEthFrameProcessor.hpp.

◆ m_channel_plane_numbers

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

Definition at line 146 of file TDEEthFrameProcessor.hpp.

◆ m_crate_id

uint32_t dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_crate_id
private

Definition at line 137 of file TDEEthFrameProcessor.hpp.

◆ m_current_seq_id

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

Definition at line 79 of file TDEEthFrameProcessor.hpp.

◆ m_current_ts

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

Definition at line 76 of file TDEEthFrameProcessor.hpp.

◆ m_det_id

uint32_t dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_det_id
private

Definition at line 136 of file TDEEthFrameProcessor.hpp.

◆ m_emulator_mode

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

Definition at line 140 of file TDEEthFrameProcessor.hpp.

◆ m_err_frame_sink

std::shared_ptr<iomanager::SenderConcept<fddetdataformats::TDEEthFrame> > dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_err_frame_sink
private

Definition at line 150 of file TDEEthFrameProcessor.hpp.

◆ m_first_hit

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

Definition at line 122 of file TDEEthFrameProcessor.hpp.

◆ m_first_seq_id_mismatch

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

Definition at line 89 of file TDEEthFrameProcessor.hpp.

◆ m_first_ts_missmatch

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

Definition at line 84 of file TDEEthFrameProcessor.hpp.

◆ m_frame_counter

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

Definition at line 160 of file TDEEthFrameProcessor.hpp.

160{ 0 };

◆ m_new_hits

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

Definition at line 156 of file TDEEthFrameProcessor.hpp.

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

◆ m_new_tps

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

Definition at line 157 of file TDEEthFrameProcessor.hpp.

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

◆ m_num_msg

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

Definition at line 131 of file TDEEthFrameProcessor.hpp.

◆ m_num_push_fail

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

Definition at line 132 of file TDEEthFrameProcessor.hpp.

◆ m_pattern_generator_current_ts

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

Definition at line 82 of file TDEEthFrameProcessor.hpp.

◆ m_pattern_generator_previous_ts

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

Definition at line 81 of file TDEEthFrameProcessor.hpp.

◆ m_previous_seq_id

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

Definition at line 78 of file TDEEthFrameProcessor.hpp.

◆ m_previous_ts

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

Definition at line 75 of file TDEEthFrameProcessor.hpp.

◆ m_seq_id_error_ctr

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

Definition at line 92 of file TDEEthFrameProcessor.hpp.

92{ 0 };

◆ m_seq_id_error_state

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

Definition at line 91 of file TDEEthFrameProcessor.hpp.

◆ m_seq_id_max_jump

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

Definition at line 94 of file TDEEthFrameProcessor.hpp.

94{ 0 };

◆ m_seq_id_min_jump

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

Definition at line 93 of file TDEEthFrameProcessor.hpp.

93{ 0 };

◆ m_seq_id_problem_reported

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

Definition at line 90 of file TDEEthFrameProcessor.hpp.

◆ m_slot_id

uint32_t dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_slot_id
private

Definition at line 138 of file TDEEthFrameProcessor.hpp.

◆ m_sourceid

daqdataformats::SourceID dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_sourceid
private

Definition at line 154 of file TDEEthFrameProcessor.hpp.

◆ m_stream_id

uint32_t dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_stream_id
private

Definition at line 139 of file TDEEthFrameProcessor.hpp.

◆ m_t0

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

Definition at line 162 of file TDEEthFrameProcessor.hpp.

◆ m_tp_channel_rate_map

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

Definition at line 129 of file TDEEthFrameProcessor.hpp.

◆ m_tp_generator

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

Definition at line 123 of file TDEEthFrameProcessor.hpp.

◆ m_tp_max_width

uint32_t dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_tp_max_width
private

Definition at line 125 of file TDEEthFrameProcessor.hpp.

◆ m_tp_sink

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

Definition at line 149 of file TDEEthFrameProcessor.hpp.

◆ m_tpa_vectors

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

Definition at line 147 of file TDEEthFrameProcessor.hpp.

◆ m_tpg_configs

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

Definition at line 124 of file TDEEthFrameProcessor.hpp.

◆ m_tpg_hits_count

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

Definition at line 134 of file TDEEthFrameProcessor.hpp.

134{ 0 };

◆ m_tpg_threshold_selected

uint16_t dunedaq::fdreadoutlibs::TDEEthFrameProcessor::m_tpg_threshold_selected
private

Definition at line 127 of file TDEEthFrameProcessor.hpp.

◆ m_tps_send_failed

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

Definition at line 159 of file TDEEthFrameProcessor.hpp.

159{ 0 };

◆ m_tps_suppressed_too_long

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

Definition at line 158 of file TDEEthFrameProcessor.hpp.

158{ 0 };

◆ m_ts_error_ctr

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

Definition at line 87 of file TDEEthFrameProcessor.hpp.

87{ 0 };

◆ m_ts_error_state

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

Definition at line 86 of file TDEEthFrameProcessor.hpp.

◆ m_ts_problem_reported

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

Definition at line 85 of file TDEEthFrameProcessor.hpp.


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