DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
AVXFrugalPedestalSubtractProcessor.cpp
Go to the documentation of this file.
1
10
11namespace tpglibs {
12
13REGISTER_AVXPROCESSOR_CREATOR("AVXFrugalPedestalSubtractProcessor", AVXFrugalPedestalSubtractProcessor)
14
15void AVXFrugalPedestalSubtractProcessor::configure(const nlohmann::json& config, const int16_t* plane_numbers) {
16 m_accum_limit = config["accum_limit"];
17}
18
19__m256i AVXFrugalPedestalSubtractProcessor::process(const __m256i& signal) {
20 // Find the channels that are above or below the pedestal.
21 __m256i is_gt = _mm256_cmpgt_epi16(signal, m_pedestal);
22 __m256i is_lt = _mm256_cmpgt_epi16(m_pedestal, signal);
23
24 // Update m_accum.
25 __m256i to_add = _mm256_setzero_si256(); // Assumes equal to pedestal.
26 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(1), is_gt); // Set the above pedestal case.
27 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(-1), is_lt); // Set the below pedestal case.
28
29 m_accum = _mm256_add_epi16(m_accum, to_add);
30
31 // Check the accum limit condition.
32 is_gt = _mm256_cmpgt_epi16(m_accum, _mm256_set1_epi16(m_accum_limit)); // m_accum > +limit.
33 is_lt = _mm256_cmpgt_epi16(_mm256_set1_epi16(-1*m_accum_limit), m_accum); // m_accum < -limit = -limit > m_accum.
34
35 to_add = _mm256_setzero_si256();
36 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(1), is_gt);
37 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(-1), is_lt);
38
39 // Update pedestal.
40 m_pedestal = _mm256_adds_epi16(m_pedestal, to_add);
41
42 // Reset too high/low m_accum channels.
43 __m256i need_reset = _mm256_or_si256(is_lt, is_gt);
44 m_accum = _mm256_blendv_epi8(m_accum, _mm256_setzero_si256(), need_reset);
45
46 return AVXProcessor::process(_mm256_sub_epi16(signal, m_pedestal));
47}
48
49} // namespace tpglibs
#define REGISTER_AVXPROCESSOR_CREATOR(processor_name, processor_class)
Factory registration macro.
AVX signal processor: Estimates the pedestal and subtracts.
__m256i process(const __m256i &signal) override
Estimate the pedestal using the given signal and subtract.
__m256i m_pedestal
Vector of estimated pedestals for each channel.
int16_t m_accum_limit
Count limit before committing to a pedestal shift.
__m256i m_accum
Vector of counts that a channel's signal was above or below m_pedestal.
virtual __m256i process(const __m256i &signal) override
Simple signal pass-through on __m256i type.