Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Modular tpglibs #221

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -42,6 +43,7 @@ set(FDREADOUTLIBS_DEPENDENCIES
detdataformats::detdataformats
trgdataformats::trgdataformats
fddetdataformats::fddetdataformats
tpglibs::tpglibs
trigger::trigger
appmodel::appmodel
detchannelmaps::detchannelmaps
Expand Down
1 change: 1 addition & 0 deletions cmake/fdreadoutlibsConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
58 changes: 15 additions & 43 deletions include/fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -20,9 +23,12 @@
#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"

#include <atomic>
#include <bitset>
Expand All @@ -41,35 +47,6 @@
namespace dunedaq {
namespace fdreadoutlibs {

class WIBEthFrameHandler {

public:
explicit WIBEthFrameHandler();
~WIBEthFrameHandler();
std::unique_ptr<swtpg_wibeth::ProcessingInfo<swtpg_wibeth::NUM_REGISTERS_PER_FRAME>> 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<int16_t> m_tpg_taps; // firwin_int(7, 0.1, multiplier);
int16_t* m_tpg_taps_p = nullptr;
};

class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel<types::DUNEWIBEthTypeAdapter>
{

Expand All @@ -79,12 +56,10 @@ 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<datahandlinglibs::FrameErrorRegistry>& error_registry);

~WIBEthFrameProcessor();

void start(const nlohmann::json& args) override;

void stop(const nlohmann::json& args) override;
Expand Down Expand Up @@ -135,16 +110,15 @@ 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;
// Selected TPG algorithm from configuration
std::string m_tpg_algorithm;
bool m_first_hit = true;
std::unique_ptr<tpglibs::TPGenerator> m_tp_generator;
std::vector<std::pair<std::string, nlohmann::json>> m_tpg_configs;
uint32_t m_tp_max_width;
std::vector<unsigned int> m_channel_mask_vec;
std::set<unsigned int> m_channel_mask_set;
Expand All @@ -169,13 +143,11 @@ class WIBEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel<
std::shared_ptr<detchannelmaps::TPCChannelMap> m_channel_map;

// Mapping from expanded AVX register position to offline channel number
std::array<uint, swtpg_wibeth::NUM_REGISTERS_PER_FRAME * swtpg_wibeth::SAMPLES_PER_REGISTER> m_register_channels;

std::function<void(swtpg_wibeth::ProcessingInfo<swtpg_wibeth::NUM_REGISTERS_PER_FRAME>& info)> m_assigned_tpg_algorithm_function;
//std::array<uint, swtpg_wibeth::NUM_REGISTERS_PER_FRAME * swtpg_wibeth::SAMPLES_PER_REGISTER> m_register_channels;
std::vector<std::pair<int16_t, int16_t>> m_channel_plane_numbers;

std::shared_ptr<iomanager::SenderConcept<trigger::TriggerPrimitiveTypeAdapter>> m_tp_sink;
std::shared_ptr<iomanager::SenderConcept<fddetdataformats::WIBEthFrame>> m_err_frame_sink;
std::unique_ptr<WIBEthFrameHandler> m_wibeth_frame_handler = std::make_unique<WIBEthFrameHandler>();

//std::thread m_add_hits_tphandler_thread;

Expand Down
Loading
Loading