29namespace fdreadoutlibs {
31TDEEthFrameProcessor::TDEEthFrameProcessor(std::unique_ptr<datahandlinglibs::FrameErrorRegistry>& error_registry,
bool processing_enabled)
32 : TaskRawDataProcessorModel<types::TDEEthTypeAdapter>(error_registry, processing_enabled)
60 m_t0 = std::chrono::high_resolution_clock::now();
81 for (
auto output :
conf->get_outputs()) {
83 if (output->get_data_type() ==
"TriggerPrimitiveVector") {
87 ers::error(datahandlinglibs::ResourceQueueError(
ERS_HERE,
"tp",
"DefaultRequestHandlerModel", excpt));
93 auto geo_id =
conf->get_geo_id();
94 if (geo_id !=
nullptr) {
95 m_det_id = geo_id->get_detector_id();
109 auto dp =
conf->get_module_configuration()->get_data_processor();
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()};
122 const std::vector<unsigned int> channel_mask_vec = proc_conf->get_channel_mask();
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()));
130 m_channel_map = dunedaq::detchannelmaps::make_tpc_map(proc_conf->get_channel_map());
131 for (
int chan = 0; chan < 64; chan++) {
133 int16_t plane =
m_channel_map->get_plane_from_offline_channel(off_channel);
138 if (std::find(channel_mask_vec.begin(), channel_mask_vec.end(), off_channel) != channel_mask_vec.end())
166 auto now = std::chrono::high_resolution_clock::now();
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;
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; });
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();
196 for (
int i = 0; i < top_highest_values; i++) {
200 publish(std::move(tpc_info), {{
"channel", std::to_string(channel_tp_rate_vec[i].first)}});
244 if ( delta_seq_id > 0x800) {
245 delta_seq_id -= 0x1000;
246 }
else if ( delta_seq_id < -0x7ff) {
247 delta_seq_id += 0x1000;
250 if (delta_seq_id == 0) {
271 TLOG() <<
"*** Data Integrity ERROR *** Sequence ID continuity is completely broken! "
272 <<
"Something is wrong with the FE source or with the configuration!";
289 uint16_t tdeeth_frame_tick_difference = tdeeth_tick_difference * fp->
get_num_frames();
329 TLOG() <<
"*** Data Integrity ERROR *** Timestamp continuity is completely broken! "
330 <<
"Something is wrong with the FE source or with the configuration!";
359 std::vector<trgdataformats::TriggerPrimitive> tps = (*m_tp_generator)(wfptr);
362 for (
const auto& tp : tps) {
376 for (
int i = 0; i < 3; i++) {
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;
#define DUNE_DAQ_TYPESTRING(Type, typestring)
void start(const nlohmann::json &) override
void add_preprocess_task(Task &&task)
void add_postprocess_task(Task &&task)
void conf(const appmodel::DataHandlerModule *conf) override
bool m_post_processing_enabled
void stop(const nlohmann::json &) override
virtual void generate_opmon_data() override
std::atomic< uint64_t > m_last_processed_daq_ts
std::unique_ptr< FrameErrorRegistry > & m_error_registry
void set_num_tps_send_failed(::uint64_t value)
void set_num_tps_suppressed_too_long(::uint64_t value)
void set_num_tps_sent(::uint64_t value)
void set_rate_tp_hits(float value)
void set_channel_id(::uint64_t value)
void set_number_of_tps(::uint64_t value)
std::atomic< int16_t > m_seq_id_max_jump
std::atomic< uint64_t > m_ts_error_ctr
uint16_t m_current_seq_id
std::atomic< uint64_t > m_tps_send_failed
virtual void generate_opmon_data() override
bool m_ts_problem_reported
std::set< unsigned int > m_channel_mask_set
void timestamp_check(frameptr fp)
std::vector< std::pair< std::string, nlohmann::json > > m_tpg_configs
std::atomic< int16_t > m_seq_id_min_jump
void conf(const appmodel::DataHandlerModule *conf) override
Set the emulator mode, if active, timestamps of processed packets are overwritten with new ones.
std::atomic< uint64_t > m_seq_id_error_ctr
std::unique_ptr< tpglibs::TPGenerator > m_tp_generator
std::atomic< uint64_t > m_frame_counter
void sequence_check(frameptr fp)
bool m_seq_id_problem_reported
std::vector< std::pair< trgdataformats::channel_t, int16_t > > m_channel_plane_numbers
std::shared_ptr< detchannelmaps::TPCChannelMap > m_channel_map
dunedaq::daqdataformats::timestamp_t m_current_ts
bool m_seq_id_error_state
void stop(const nlohmann::json &args) override
Stop operation.
bool m_first_seq_id_mismatch
std::chrono::time_point< std::chrono::high_resolution_clock > m_t0
dunedaq::daqdataformats::timestamp_t m_previous_ts
std::map< uint, std::atomic< int > > m_tp_channel_rate_map
std::atomic< uint64_t > m_tps_suppressed_too_long
daqdataformats::SourceID m_sourceid
std::atomic< uint64_t > m_new_hits
std::atomic< uint64_t > m_new_tps
void start(const nlohmann::json &args) override
Start operation.
std::vector< trigger::TriggerPrimitiveTypeAdapter > m_tpa_vectors[3]
uint16_t m_previous_seq_id
void find_hits(constframeptr fp)
std::atomic< int > m_tpg_hits_count
bool m_first_ts_missmatch
std::shared_ptr< iomanager::SenderConcept< std::vector< trigger::TriggerPrimitiveTypeAdapter > > > m_tp_sink[3]
static constexpr timeout_t s_no_block
void publish(google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
Base class for any user define issue.
#define TLOG_DEBUG(lvl,...)
static std::shared_ptr< iomanager::SenderConcept< Datatype > > get_iom_sender(iomanager::ConnectionId const &id)
void warning(const Issue &issue)
void error(const Issue &issue)
static const constexpr uint64_t samples_tick_difference
static const constexpr daqdataformats::SourceID::Subsystem subsystem
static const constexpr uint64_t expected_tick_difference
trgdataformats::TriggerPrimitive tp