From 3c7d0b412acba561d9c02fe74758607274ff70dc Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Mon, 19 Aug 2024 08:04:25 +0200 Subject: [PATCH 1/5] Use tpglibs. --- CMakeLists.txt | 2 + cmake/fdreadoutlibsConfig.cmake.in | 1 + .../wibeth/WIBEthFrameProcessor.hpp | 9 +- src/wibeth/WIBEthFrameProcessor.cpp | 179 +++--------------- 4 files changed, 37 insertions(+), 154 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f4b56a..9660f52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ find_package(detchannelmaps REQUIRED) find_package(trgdataformats REQUIRED) find_package(detdataformats REQUIRED) find_package(fddetdataformats REQUIRED) +find_package(tpglibs REQUIRED) find_package(trigger REQUIRED) find_package(hdf5libs REQUIRED) find_package(appmodel REQUIRED) @@ -42,6 +43,7 @@ set(FDREADOUTLIBS_DEPENDENCIES detdataformats::detdataformats trgdataformats::trgdataformats fddetdataformats::fddetdataformats + tpglibs::tpglibs trigger::trigger appmodel::appmodel detchannelmaps::detchannelmaps diff --git a/cmake/fdreadoutlibsConfig.cmake.in b/cmake/fdreadoutlibsConfig.cmake.in index 35c3d1f..a22ce07 100644 --- a/cmake/fdreadoutlibsConfig.cmake.in +++ b/cmake/fdreadoutlibsConfig.cmake.in @@ -12,6 +12,7 @@ find_dependency(daqdataformats) find_dependency(detdataformats) find_dependency(trgdataformats) find_dependency(fddetdataformats) +find_dependency(tpglibs) find_dependency(detchannelmaps) find_dependency(trigger) find_dependency(hdf5libs) diff --git a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp index 2201308..783afa6 100644 --- a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp +++ b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp @@ -24,6 +24,8 @@ #include "tpg/ProcessingInfo.hpp" #include "tpg/RegisterToChannelNumber.hpp" +#include "tpglibs/TPGenerator.hpp" + #include #include #include @@ -143,7 +145,9 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< private: bool m_tpg_enabled; - std::string m_tpg_algorithm; + bool m_first_hit = true; + std::unique_ptr m_tp_generator; + nlohmann::json m_tpg_configs; uint32_t m_tp_max_width; std::vector m_channel_mask_vec; std::set m_channel_mask_set; @@ -166,8 +170,7 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< // Mapping from expanded AVX register position to offline channel number std::array m_register_channels; - - std::function& info)> m_assigned_tpg_algorithm_function; + std::vector> m_channel_plane_numbers; std::shared_ptr> m_tp_sink; std::shared_ptr> m_err_frame_sink; diff --git a/src/wibeth/WIBEthFrameProcessor.cpp b/src/wibeth/WIBEthFrameProcessor.cpp index 18470ea..d207f09 100644 --- a/src/wibeth/WIBEthFrameProcessor.cpp +++ b/src/wibeth/WIBEthFrameProcessor.cpp @@ -136,8 +136,7 @@ WIBEthFrameProcessor::start(const nlohmann::json& args) if (m_tpg_enabled) { m_tps_suppressed_too_long = 0; m_tps_send_failed = 0; - - m_wibeth_frame_handler->initialize(m_tpg_threshold_selected); + m_tp_generator = std::make_unique(); } // end if(m_tpg_enabled) // Reset timestamp check @@ -165,8 +164,8 @@ WIBEthFrameProcessor::stop(const nlohmann::json& args) { inherited::stop(args); if (m_tpg_enabled) { - // Make temp. buffers reusable on next start. - m_wibeth_frame_handler->reset(); + // Clears the pipelines and resets with the given configs. + m_tp_generator->configure(m_tpg_configs, m_channel_plane_numbers, types::DUNEWIBEthTypeAdapter::samples_tick_difference); } } @@ -207,19 +206,6 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) auto proc_conf = dp->cast(); if (proc_conf != nullptr && proc_conf->get_mask_processing() == false && proc_conf->get_tpg_enabled()) { m_tpg_enabled = true; - m_tpg_algorithm = proc_conf->get_algorithm(); - TLOG() << "Selected software TPG algorithm: " << m_tpg_algorithm; - if (m_tpg_algorithm == "SimpleThreshold") { - m_assigned_tpg_algorithm_function = &swtpg_wibeth::process_window_avx2; - } else if (m_tpg_algorithm == "AbsRS") { - m_assigned_tpg_algorithm_function = - &swtpg_wibeth::process_window_rs_avx2; - } else if (m_tpg_algorithm == "StandardRS") { - m_assigned_tpg_algorithm_function = - &swtpg_wibeth::process_window_standard_rs_avx2; - } else { - throw TPGAlgorithmInexistent(ERS_HERE, m_tpg_algorithm); - } m_tp_max_width = proc_conf->get_max_ticks_tot(); @@ -232,6 +218,13 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) // Setup post-processing pipeline m_channel_map = dunedaq::detchannelmaps::make_map(proc_conf->get_channel_map()); + for (int chan = 0; chan < 64; chan++) { + int16_t off_channel = m_channel_map->get_offline_channel_from_crate_slot_stream_chan(m_crate_id, m_slot_id, m_stream_id, chan); + int16_t plane = m_channel_map->get_plane_from_offline_channel(off_channel); + m_channel_plane_numbers.push_back({off_channel, plane}); + } + + m_tp_generator->configure(m_tpg_configs, m_channel_plane_numbers, types::DUNEWIBEthTypeAdapter::samples_tick_difference); inherited::add_postprocess_task(std::bind(&WIBEthFrameProcessor::find_hits, this, std::placeholders::_1, m_wibeth_frame_handler.get())); } @@ -420,149 +413,33 @@ WIBEthFrameProcessor::timestamp_check(frameptr fp) void WIBEthFrameProcessor::find_hits(constframeptr fp, WIBEthFrameHandler* frame_handler) { + size_t nhits = 0; if (!fp) return; auto wfptr = reinterpret_cast((uint8_t*)fp); // NOLINT - uint64_t timestamp = wfptr->get_timestamp(); // NOLINT(build/unsigned) - - // Frame expansion - swtpg_wibeth::MessageRegisters registers_array; - expand_wibeth_adcs(fp, ®isters_array); - - // For debugging purposes you can check the single ADCs - //parse_wibeth_adcs(®isters_array); - - // Only for the first WIBEth frame, create an offline register map - if (frame_handler->first_hit) { - frame_handler->register_channel_map = swtpg_wibeth::get_register_to_offline_channel_map_wibeth(wfptr, m_channel_map); - - frame_handler->m_tpg_processing_info->setState(registers_array); - m_det_id = wfptr->daq_header.det_id; + // Check that the system is properly configured from the first hit. + if (m_first_hit) { 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) { 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)); } - // Add WIBEthFrameHandler channel map to the common m_register_channels. - // Populate the array - for (size_t i = 0; i < swtpg_wibeth::NUM_REGISTERS_PER_FRAME * swtpg_wibeth::SAMPLES_PER_REGISTER; ++i) { - m_register_channels[i] = frame_handler->register_channel_map.channel[i]; - - //TLOG () << "Index number " << i << " offline channel " << frame_handler->register_channel_map.channel[i]; - - // Set up a map of channels and number of TPs for monitoring/debug - m_tp_channel_rate_map[frame_handler->register_channel_map.channel[i]] = 0; - } - - //TLOG() << "Processed the first frame "; - - // Set first hit bool to false so that registration of channel map is not executed twice - frame_handler->first_hit = false; - - } // end if (frame_handler->first_hit) - - - // Execute the SWTPG algorithm - frame_handler->m_tpg_processing_info->input = ®isters_array; - // Set the first word to "magic" indicating there is no hit, initially - frame_handler->m_tpg_processing_info->output[0] = swtpg_wibeth::MAGIC; - m_assigned_tpg_algorithm_function(*frame_handler->m_tpg_processing_info); - - //GLM: avoid the tp_handler queue/thread - process_swtpg_hits(frame_handler->m_tpg_processing_info->output, timestamp); - -} - -void -WIBEthFrameProcessor::process_swtpg_hits(uint16_t* primfind_it, dunedaq::daqdataformats::timestamp_t timestamp) -{ - - constexpr int clocksPerTPCTick = types::DUNEWIBEthTypeAdapter::samples_tick_difference; - - uint16_t chan[16], hit_end[16], hit_charge[16], hit_tover[16], hit_peak_time[16], hit_peak_adc[16], left[16]; // NOLINT(build/unsigned) - unsigned int nhits = 0; + m_first_hit = false; + } - while (*primfind_it != swtpg_wibeth::MAGIC) { - // First, get all of the register values (including those with no hit) into local variables - for (int i = 0; i < 16; ++i) { - chan[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - } - for (int i = 0; i < 16; ++i) { - hit_end[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - } - for (int i = 0; i < 16; ++i) { - hit_charge[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - // TLOG() << "hit_charge:" << hit_charge[i]; - } - for (int i = 0; i < 16; ++i) { - // hit_tover[i] = static_cast(*primfind_it++); // NOLINT(runtime/increment_decrement) - hit_tover[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - } - for (int i = 0; i < 16; ++i) { - hit_peak_adc[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - } - for (int i = 0; i < 16; ++i) { - hit_peak_time[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - } - for (int i = 0; i < 16; ++i) { - left[i] = *primfind_it++; // NOLINT(runtime/increment_decrement) - } - - // Now that we have all the register values in local - // variables, loop over the register index (ie, channel) and - // find the channels which actually had a hit, as indicated by - // nonzero value of hit_charge - for (int i = 0; i < 16; ++i) { - // AAA: condition on the left hits makes sure to count hits - // correctly when they are spread across multiple channels - if (hit_charge[i] && left[i] == swtpg_wibeth::MAGIC - && chan[i] != swtpg_wibeth::MAGIC) { - - uint64_t tp_t_begin = timestamp + clocksPerTPCTick * ((int64_t)hit_end[i] - (int64_t)hit_tover[i]); - uint64_t tp_t_peak = tp_t_begin + clocksPerTPCTick * hit_peak_time[i]; - - // This channel had a hit ending here, so we can create and output the hit here - const uint16_t offline_channel = m_register_channels[chan[i]]; - if (m_channel_mask_set.find(offline_channel) == m_channel_mask_set.end()) { - // May be needed for TPSet: - // uint64_t tspan = clocksPerTPCTick * hit_tover[i]; // is/will be this needed? - // - - // For quick n' dirty debugging: print out time/channel of hits. - // Can then make a text file suitable for numpy plotting with, eg: - // - // sed -n -e 's/.*Hit: \(.*\) \(.*\).*/\1 \2/p' log.txt > hits.txt - // - - trigger::TriggerPrimitiveTypeAdapter tp; - tp.tp.time_start = tp_t_begin; - tp.tp.time_peak = tp_t_peak; - tp.tp.time_over_threshold = uint64_t((hit_tover[i]) * clocksPerTPCTick); - tp.tp.channel = offline_channel; - tp.tp.adc_integral = hit_charge[i]; - tp.tp.adc_peak = hit_peak_adc[i]; - tp.tp.detid = m_det_id; // TODO: convert crate/slot/link to SourceID Roland Sipos rsipos@cern.ch July-22-2021 - tp.tp.type = trgdataformats::TriggerPrimitive::Type::kTPC; - tp.tp.algorithm = trgdataformats::TriggerPrimitive::Algorithm::kTPCDefault; - tp.tp.version = 1; // FIXME!!!! - if(tp.tp.time_over_threshold > m_tp_max_width) { - ers::warning(TPTooLong(ERS_HERE, tp.tp.time_over_threshold, tp.tp.channel)); - m_tps_suppressed_too_long++; - } - //Send the TP to the TP handler module - else if(!m_tp_sink->try_send(std::move(tp), iomanager::Sender::s_no_block)) { - ers::warning(FailedToSendTP(ERS_HERE, tp.tp.time_start, tp.tp.channel)); - m_tps_send_failed++; - } - else { - m_new_tps++; - ++nhits; - } - - // Update the channel/rate map. Increment the value associated with the TP channel - m_tp_channel_rate_map[offline_channel]++; - } - } + std::vector tps = (*m_tp_generator)(wfptr); + + for (auto tp : tps) { + // Need to move into a type adapter. + trigger::TriggerPrimitiveTypeAdapter tpa; + tpa.tp = tp; + tpa.tp.detid = m_det_id; // Last missing piece. + if(!m_tp_sink->try_send(std::move(tpa), iomanager::Sender::s_no_block)) { + ers::warning(FailedToSendTP(ERS_HERE, tp.time_start, tp.channel)); + m_tps_send_failed++; + } else { + m_new_tps++; + ++nhits; } } m_tpg_hits_count += nhits; From 39688c955836d7f9d570a25c47886b1a58167f72 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Mon, 19 Aug 2024 08:07:37 +0200 Subject: [PATCH 2/5] Remove WIBEthFrameHandler. --- .../wibeth/WIBEthFrameProcessor.hpp | 36 +--------- src/wibeth/WIBEthFrameProcessor.cpp | 71 +------------------ 2 files changed, 3 insertions(+), 104 deletions(-) diff --git a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp index 783afa6..d24ffa2 100644 --- a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp +++ b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp @@ -43,35 +43,6 @@ namespace dunedaq { namespace fdreadoutlibs { -class WIBEthFrameHandler { - -public: - explicit WIBEthFrameHandler(); - ~WIBEthFrameHandler(); - std::unique_ptr> m_tpg_processing_info; - - // Map from expanded AVX register position to offline channel number - swtpg_wibeth::RegisterChannelMap register_channel_map; - - bool first_hit = true; - - int get_registers_selector(); - - void reset(); - - void initialize(int threshold_value); - - uint16_t* get_hits_dest(); -private: - int m_register_selector; - uint16_t* m_hits_dest; - uint16_t m_tpg_threshold; // units of sigma // NOLINT(build/unsigned) - const uint8_t m_tpg_tap_exponent = 6; // NOLINT(build/unsigned) - const int m_tpg_multiplier = 1 << m_tpg_tap_exponent; // 64 - std::vector m_tpg_taps; // firwin_int(7, 0.1, multiplier); - int16_t* m_tpg_taps_p = nullptr; -}; - class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel { @@ -85,8 +56,6 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< explicit WIBEthFrameProcessor(std::unique_ptr& error_registry); - ~WIBEthFrameProcessor(); - void start(const nlohmann::json& args) override; void stop(const nlohmann::json& args) override; @@ -137,12 +106,10 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< * Pipeline Stage 2.: Do software TPG * */ - void find_hits(constframeptr fp, WIBEthFrameHandler* frame_handler); + void find_hits(constframeptr fp); //void find_hits(constframeptr fp); - void process_swtpg_hits(uint16_t* primfind_it, dunedaq::daqdataformats::timestamp_t timestamp); - private: bool m_tpg_enabled; bool m_first_hit = true; @@ -174,7 +141,6 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< std::shared_ptr> m_tp_sink; std::shared_ptr> m_err_frame_sink; - std::unique_ptr m_wibeth_frame_handler = std::make_unique(); //std::thread m_add_hits_tphandler_thread; diff --git a/src/wibeth/WIBEthFrameProcessor.cpp b/src/wibeth/WIBEthFrameProcessor.cpp index d207f09..8826903 100644 --- a/src/wibeth/WIBEthFrameProcessor.cpp +++ b/src/wibeth/WIBEthFrameProcessor.cpp @@ -56,79 +56,12 @@ DUNE_DAQ_TYPESTRING(dunedaq::trigger::TriggerPrimitiveTypeAdapter, "TriggerPrimi namespace dunedaq { namespace fdreadoutlibs { - -WIBEthFrameHandler::WIBEthFrameHandler() - : m_hits_dest(nullptr) - , m_tpg_taps_p(nullptr) -{} - -WIBEthFrameHandler::~WIBEthFrameHandler() -{ - if (m_tpg_taps_p) { - delete[] m_tpg_taps_p; - } - if (m_hits_dest) delete[] m_hits_dest; -} - -void -WIBEthFrameHandler::reset() -{ - if (m_tpg_taps_p) - delete[] m_tpg_taps_p; - m_tpg_taps_p = nullptr; - if (m_hits_dest) { delete[] m_hits_dest; } m_hits_dest = nullptr; - - first_hit = true; -} - -void -WIBEthFrameHandler::initialize(int threshold_value) -{ - m_tpg_taps = swtpg_wibeth::firwin_int(7, 0.1, m_tpg_multiplier); - m_tpg_taps.push_back(0); - - m_tpg_threshold = threshold_value; - - if (m_tpg_taps_p == nullptr) { - m_tpg_taps_p = new int16_t[m_tpg_taps.size()]; - } - for (size_t i = 0; i < m_tpg_taps.size(); ++i) { - m_tpg_taps_p[i] = m_tpg_taps[i]; - } - - if(m_hits_dest == nullptr) {m_hits_dest = new uint16_t[100000];} - - m_tpg_processing_info = std::make_unique>(nullptr, - swtpg_wibeth::FRAMES_PER_MSG, - 0, - swtpg_wibeth::NUM_REGISTERS_PER_FRAME, - m_hits_dest, - m_tpg_taps_p, - (uint8_t)m_tpg_taps.size(), // NOLINT(build/unsigned) - m_tpg_tap_exponent, - m_tpg_threshold, - 0, - 0); -} - -// Get destination ptr for the frame handler -uint16_t* -WIBEthFrameHandler::get_hits_dest() -{ - return m_hits_dest; -} - WIBEthFrameProcessor::WIBEthFrameProcessor(std::unique_ptr& error_registry) : TaskRawDataProcessorModel(error_registry) , m_tpg_enabled(false) { } -WIBEthFrameProcessor::~WIBEthFrameProcessor() -{ - m_wibeth_frame_handler->reset(); -} - void WIBEthFrameProcessor::start(const nlohmann::json& args) { @@ -226,7 +159,7 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) m_tp_generator->configure(m_tpg_configs, m_channel_plane_numbers, types::DUNEWIBEthTypeAdapter::samples_tick_difference); - inherited::add_postprocess_task(std::bind(&WIBEthFrameProcessor::find_hits, this, std::placeholders::_1, m_wibeth_frame_handler.get())); + inherited::add_postprocess_task(std::bind(&WIBEthFrameProcessor::find_hits, this, std::placeholders::_1)); } } inherited::conf(conf); @@ -411,7 +344,7 @@ WIBEthFrameProcessor::timestamp_check(frameptr fp) * Pipeline Stage 2.: Do software TPG * */ void -WIBEthFrameProcessor::find_hits(constframeptr fp, WIBEthFrameHandler* frame_handler) +WIBEthFrameProcessor::find_hits(constframeptr fp) { size_t nhits = 0; if (!fp) From 2bc6f9d4f41f00af12eb84179fecea53d913a919 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Mon, 19 Aug 2024 14:15:58 +0200 Subject: [PATCH 3/5] Comment Redundant Includes. These preambles should really be restructured. --- .../wibeth/WIBEthFrameProcessor.hpp | 12 +++-- src/wibeth/WIBEthFrameProcessor.cpp | 52 +++++++++---------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp index d24ffa2..93827e4 100644 --- a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp +++ b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp @@ -8,6 +8,9 @@ #ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_WIBEth_WIBFRAMEPROCESSOR_HPP_ #define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_WIBEth_WIBFRAMEPROCESSOR_HPP_ +#include "fdreadoutlibs/DUNEWIBEthTypeAdapter.hpp" + +// #include "appfwk/DAQModuleHelper.hpp" #include "iomanager/IOManager.hpp" #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" @@ -20,9 +23,10 @@ #include "appmodel/DataHandlerModule.hpp" #include "confmodel/Connection.hpp" #include "daqdataformats/Types.hpp" +#include "detchannelmaps/TPCChannelMap.hpp" -#include "tpg/ProcessingInfo.hpp" -#include "tpg/RegisterToChannelNumber.hpp" +//#include "tpg/ProcessingInfo.hpp" +//#include "tpg/RegisterToChannelNumber.hpp" #include "tpglibs/TPGenerator.hpp" @@ -52,7 +56,7 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< using constframeptr = const types::DUNEWIBEthTypeAdapter*; using wibframeptr = dunedaq::fddetdataformats::WIBEthFrame*; // Channel map function type - typedef int (*chan_map_fn_t)(int); + //typedef int (*chan_map_fn_t)(int); explicit WIBEthFrameProcessor(std::unique_ptr& error_registry); @@ -136,7 +140,7 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< std::shared_ptr m_channel_map; // Mapping from expanded AVX register position to offline channel number - std::array m_register_channels; + //std::array m_register_channels; std::vector> m_channel_plane_numbers; std::shared_ptr> m_tp_sink; diff --git a/src/wibeth/WIBEthFrameProcessor.cpp b/src/wibeth/WIBEthFrameProcessor.cpp index 8826903..3209176 100644 --- a/src/wibeth/WIBEthFrameProcessor.cpp +++ b/src/wibeth/WIBEthFrameProcessor.cpp @@ -10,8 +10,8 @@ #include "appmodel/RawDataProcessor.hpp" //#include "appfwk/DAQModuleHelper.hpp" -#include "iomanager/Sender.hpp" -#include "logging/Logging.hpp" +//#include "iomanager/Sender.hpp" +//#include "logging/Logging.hpp" #include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" @@ -21,30 +21,30 @@ #include "datahandlinglibs/opmon/datahandling_info.pb.h" -#include "detchannelmaps/TPCChannelMap.hpp" -#include "fddetdataformats/WIBEthFrame.hpp" - - -#include "fdreadoutlibs/DUNEWIBEthTypeAdapter.hpp" -#include "trigger/TriggerPrimitiveTypeAdapter.hpp" - -#include "fdreadoutlibs/wibeth/tpg/DesignFIR.hpp" -#include "fdreadoutlibs/wibeth/tpg/FrameExpand.hpp" -#include "fdreadoutlibs/wibeth/tpg/ProcessAVX2.hpp" -#include "fdreadoutlibs/wibeth/tpg/ProcessAbsRSAVX2.hpp" -#include "fdreadoutlibs/wibeth/tpg/ProcessStandardRSAVX2.hpp" -#include "fdreadoutlibs/wibeth/tpg/TPGConstants_wibeth.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +//#include "detchannelmaps/TPCChannelMap.hpp" +//#include "fddetdataformats/WIBEthFrame.hpp" + + +//#include "fdreadoutlibs/DUNEWIBEthTypeAdapter.hpp" +//#include "trigger/TriggerPrimitiveTypeAdapter.hpp" + +//#include "fdreadoutlibs/wibeth/tpg/DesignFIR.hpp" +//#include "fdreadoutlibs/wibeth/tpg/FrameExpand.hpp" +//#include "fdreadoutlibs/wibeth/tpg/ProcessAVX2.hpp" +//#include "fdreadoutlibs/wibeth/tpg/ProcessAbsRSAVX2.hpp" +//#include "fdreadoutlibs/wibeth/tpg/ProcessStandardRSAVX2.hpp" +//#include "fdreadoutlibs/wibeth/tpg/TPGConstants_wibeth.hpp" + +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include using dunedaq::datahandlinglibs::logging::TLVL_BOOKKEEPING; using dunedaq::datahandlinglibs::logging::TLVL_TAKE_NOTE; From 5300afad085c76c592176dcc0b5716fe9f928dc4 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Mon, 19 Aug 2024 14:18:52 +0200 Subject: [PATCH 4/5] Complete TPG Config Implementation. --- include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp | 2 +- src/wibeth/WIBEthFrameProcessor.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp index 93827e4..502403d 100644 --- a/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp +++ b/include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp @@ -118,7 +118,7 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< bool m_tpg_enabled; bool m_first_hit = true; std::unique_ptr m_tp_generator; - nlohmann::json m_tpg_configs; + std::vector> m_tpg_configs; uint32_t m_tp_max_width; std::vector m_channel_mask_vec; std::set m_channel_mask_set; diff --git a/src/wibeth/WIBEthFrameProcessor.cpp b/src/wibeth/WIBEthFrameProcessor.cpp index 3209176..ef5b758 100644 --- a/src/wibeth/WIBEthFrameProcessor.cpp +++ b/src/wibeth/WIBEthFrameProcessor.cpp @@ -8,6 +8,7 @@ #include "fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp" // NOLINT(build/include) #include "confmodel/GeoId.hpp" #include "appmodel/RawDataProcessor.hpp" +#include "appmodel/ProcessingStep.hpp" //#include "appfwk/DAQModuleHelper.hpp" //#include "iomanager/Sender.hpp" @@ -137,17 +138,20 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) auto dp = conf->get_module_configuration()->get_data_processor(); if (dp != nullptr) { auto proc_conf = dp->cast(); - if (proc_conf != nullptr && proc_conf->get_mask_processing() == false && proc_conf->get_tpg_enabled()) { + if (proc_conf != nullptr && proc_conf->get_mask_processing() == false) { m_tpg_enabled = true; - m_tp_max_width = proc_conf->get_max_ticks_tot(); + //m_tp_max_width = proc_conf->get_max_ticks_tot(); m_channel_mask_vec = proc_conf->get_channel_mask(); // Converting the input vector of channels masks into an std::set // AAA: The set provides faster look up than a std::vector m_channel_mask_set.insert(m_channel_mask_vec.begin(), m_channel_mask_vec.end()); - m_tpg_threshold_selected = proc_conf->get_threshold(); + std::vector processing_steps = proc_conf->get_processing_steps(); + for (auto step : processing_steps) { + m_tpg_configs.push_back(std::make_pair(step->class_name(), step->to_json(true))); + } // Setup post-processing pipeline m_channel_map = dunedaq::detchannelmaps::make_map(proc_conf->get_channel_map()); From 39ef415217103ba5e1eff949caaad2ef7c0687e7 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Fri, 23 Aug 2024 17:14:16 +0200 Subject: [PATCH 5/5] Move TPGen Init and Correct Config Getting. --- src/wibeth/WIBEthFrameProcessor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wibeth/WIBEthFrameProcessor.cpp b/src/wibeth/WIBEthFrameProcessor.cpp index ef5b758..24d6521 100644 --- a/src/wibeth/WIBEthFrameProcessor.cpp +++ b/src/wibeth/WIBEthFrameProcessor.cpp @@ -70,7 +70,6 @@ WIBEthFrameProcessor::start(const nlohmann::json& args) if (m_tpg_enabled) { m_tps_suppressed_too_long = 0; m_tps_send_failed = 0; - m_tp_generator = std::make_unique(); } // end if(m_tpg_enabled) // Reset timestamp check @@ -140,6 +139,7 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) auto proc_conf = dp->cast(); if (proc_conf != nullptr && proc_conf->get_mask_processing() == false) { m_tpg_enabled = true; + m_tp_generator = std::make_unique(); //m_tp_max_width = proc_conf->get_max_ticks_tot(); @@ -150,7 +150,7 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) std::vector processing_steps = proc_conf->get_processing_steps(); for (auto step : processing_steps) { - m_tpg_configs.push_back(std::make_pair(step->class_name(), step->to_json(true))); + m_tpg_configs.push_back(std::make_pair(step->class_name(), step->to_json(false).back())); } // Setup post-processing pipeline @@ -158,7 +158,7 @@ WIBEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) for (int chan = 0; chan < 64; chan++) { int16_t off_channel = m_channel_map->get_offline_channel_from_crate_slot_stream_chan(m_crate_id, m_slot_id, m_stream_id, chan); int16_t plane = m_channel_map->get_plane_from_offline_channel(off_channel); - m_channel_plane_numbers.push_back({off_channel, plane}); + m_channel_plane_numbers.push_back(std::make_pair(off_channel, plane)); } m_tp_generator->configure(m_tpg_configs, m_channel_plane_numbers, types::DUNEWIBEthTypeAdapter::samples_tick_difference);