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

Add TP Time Over Threshold Filter #11

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
17 changes: 14 additions & 3 deletions include/tpglibs/TPGPipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ class TPGPipeline {
virtual void configure(const std::vector<std::pair<std::string, nlohmann::json>> configs, const std::vector<std::pair<int16_t, int16_t>> channel_plane_numbers) {
std::shared_ptr<processor_t> prev_processor = nullptr;

int16_t plane_numbers[16];
for (int i = 0; i < 16; i++) {
m_channels[i] = channel_plane_numbers[i].first;
plane_numbers[i] = channel_plane_numbers[i].second;
m_plane_numbers[i] = channel_plane_numbers[i].second;
}

for (const auto& name_config : configs) {
// Get the requested processor.
std::shared_ptr<processor_t> processor = m_factory->create_processor(name_config.first);

// Configure it.
processor->configure(name_config.second, plane_numbers);
processor->configure(name_config.second, m_plane_numbers);

// If it's the first one, make it the head.
if (!prev_processor) {
Expand Down Expand Up @@ -90,6 +89,14 @@ class TPGPipeline {
/** @brief Pure virtual function that will generate TPs given a mask to draw from. */
virtual std::vector<dunedaq::trgdataformats::TriggerPrimitive> generate_tps(const signal_t& tp_mask) = 0;

/** @brief Set the time over threshold minimum values. */
virtual void set_tot_minima(const std::vector<uint16_t>& tot_minima) {
int idx = 0;
for (auto tot_minimum : tot_minima) {
m_tot_minima[idx++] = tot_minimum;
}
}

protected:
/** @brief The on-going ADC integral for channels that are considered active. */
signal_t m_adc_integral_lo{};
Expand All @@ -102,6 +109,10 @@ class TPGPipeline {
signal_t m_time_peak{};
/** @brief Detector channel numbers for the 16 channels that are being processed. */
int16_t m_channels[16];
/** @brief Detector plane numbers for the 16 channels that are being processed. */
int16_t m_plane_numbers[16];
/** @brief The time over threshold minimum that a TP from plane `i` must have. */
uint16_t m_tot_minima[3];
/** @brief Processor factory singleton. */
std::shared_ptr<AbstractFactory<processor_t>> m_factory = AbstractFactory<processor_t>::get_instance();
/** @brief Processor head to start from. */
Expand Down
8 changes: 8 additions & 0 deletions include/tpglibs/TPGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TPGenerator {
uint8_t m_num_pipelines = 0; // Gets set inside configure.
std::vector<AVXPipeline> m_tpg_pipelines;
int m_sample_tick_difference;
std::vector<uint16_t> m_tot_minima{1,1,1}; // Defaults to 1 for all planes.

public:
/**
Expand All @@ -40,6 +41,13 @@ class TPGenerator {
const std::vector<std::pair<int16_t, int16_t>> channel_plane_numbers,
const int sample_tick_difference);

/**
* @brief Set the minimum time over threshold for a TP according to plane.
*
* @param tot_minima TPs from plane `i` will have at least `tot_minima[i]` value for its time_over_threshold.
*/
void set_tot_minima(const std::vector<uint16_t>& tot_minima);

/**
* @brief Driving function for the TPG.
*
Expand Down
2 changes: 1 addition & 1 deletion src/AVXPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ AVXPipeline::generate_tps(const __m256i& tp_mask) {

std::vector<dunedaq::trgdataformats::TriggerPrimitive> tps;
for (int i = 0; i < 16; i++) {
if (tp_tot[i] == 0) continue; // Don't track non-TPs.
if (tp_tot[i] < m_tot_minima[m_plane_numbers[i]]) continue; // Don't track short TPs.
dunedaq::trgdataformats::TriggerPrimitive tp;
tp.adc_integral = uint32_t(tp_integral_lo[i]) + (uint32_t(tp_integral_hi[i]) << 16);
tp.adc_peak = tp_adc_peak[i];
Expand Down
6 changes: 6 additions & 0 deletions src/TPGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ TPGenerator::configure(const std::vector<std::pair<std::string, nlohmann::json>>
auto begin_channel_plane = channel_plane_numbers.begin() + p*m_num_channels_per_pipeline;
auto end_channel_plane = begin_channel_plane + m_num_channels_per_pipeline;
new_pipe.configure(configs, std::vector<std::pair<int16_t, int16_t>>(begin_channel_plane, end_channel_plane));
new_pipe.set_tot_minima(m_tot_minima);
m_tpg_pipelines.push_back(new_pipe);
}
}

void
TPGenerator::set_tot_minima(const std::vector<uint16_t>& tot_minima) {
m_tot_minima = tot_minima;
}

__m256i
TPGenerator::expand_frame(const __m256i& regi) {
// Refer to the diagram and documentation on frame expansion for details.
Expand Down
Loading