Psyllid  v1.12.4
Project 8 Data Acquisisition Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
frequency_mask_trigger Class Reference

A basic FMT. More...

#include <frequency_mask_trigger.hh>

Inheritance diagram for frequency_mask_trigger:
Inheritance graph

Classes

struct  exe_func_context
 

Public Types

enum  status_t { mask_update, triggering }
 
enum  trigger_mode_t { single_level, two_level }
 
enum  threshold_t : uint32_t { snr, sigma }
 

Public Member Functions

 frequency_mask_trigger ()
 
virtual ~frequency_mask_trigger ()
 
void set_n_packets_for_mask (unsigned a_n_pkts)
 
void set_threshold_ampl_snr (double a_ampl_snr)
 
void set_threshold_power_snr (double a_power_snr)
 
void set_threshold_power_snr_high (double a_power_snr)
 
void set_threshold_power_sigma (double a_power_sigma)
 
void set_threshold_power_sigma_high (double a_power_sigma)
 
void set_threshold_dB (double a_dB)
 
void set_trigger_mode (const std::string &a_trigger_mode)
 
void set_threshold_type (const std::string &a_threshold_type)
 
std::string get_trigger_mode_str () const
 
std::string get_threshold_type_str () const
 
void calculate_snr_mask_spline_points (std::vector< double > &t_x_vals, std::vector< double > &t_y_vals, double threshold)
 
void calculate_sigma_mask_spline_points (std::vector< double > &t_x_vals, std::vector< double > &t_y_vals, double threshold)
 
void set_mask_parameters_from_node (const scarab::param_node &a_mask_and_data_values)
 
 snake_case_mv_accessible (uint64_t, length)
 
 snake_case_mv_accessible_noset (unsigned, n_packets_for_mask)
 
 snake_case_mv_accessible (double, threshold_snr)
 
 snake_case_mv_accessible (double, threshold_snr_high)
 
 snake_case_mv_accessible (double, threshold_sigma)
 
 snake_case_mv_accessible (double, threshold_sigma_high)
 
 snake_case_mv_accessible (threshold_t, threshold_type)
 
 snake_case_mv_accessible (unsigned, n_spline_points)
 
 snake_case_mv_accessible_noset (status_t, status)
 
 snake_case_mv_accessible (trigger_mode_t, trigger_mode)
 
 snake_case_mv_accessible (unsigned, n_excluded_bins)
 
void switch_to_update_mask ()
 
void switch_to_apply_trigger ()
 
void write_mask (const std::string &a_filename)
 
void initialize ()
 
void execute (midge::diptera *a_midge=nullptr)
 
void finalize ()
 

Static Public Member Functions

static uint32_t trigger_mode_to_uint (trigger_mode_t a_trigger_mode)
 
static trigger_mode_t uint_to_trigger_mode (uint32_t a_trigger_mode_uint)
 
static std::string trigger_mode_to_string (trigger_mode_t a_trigger_mode)
 
static trigger_mode_t string_to_trigger_mode (const std::string &a_trigger_mode)
 
static uint32_t threshold_to_uint (threshold_t a_threshold)
 
static threshold_t uint_to_threshold (uint32_t a_threshold_uint)
 
static std::string threshold_to_string (threshold_t a_threshold)
 
static threshold_t string_to_threshold (const std::string &a_threshold_string)
 

Private Member Functions

void exe_apply_threshold (exe_func_context &a_ctx)
 
void exe_apply_two_thresholds (exe_func_context &a_ctx)
 
void exe_add_to_mask (exe_func_context &a_ctx)
 

Private Attributes

void(frequency_mask_trigger::* f_exe_func )(exe_func_context &a_ctx)
 
std::mutex f_exe_func_mutex
 
std::atomic< bool > f_break_exe_func
 
std::vector< double > f_mask
 
std::vector< double > f_mask2
 
std::vector< double > f_average_data
 
std::vector< double > f_variance_data
 
unsigned f_n_summed
 
std::mutex f_mask_mutex
 

Detailed Description

A basic FMT.

Author
N. S. Oblath

The FMT has two modes of operation: updating the mask, and triggering.

When switched to the "updating" mode, the existing mask is erased, and the subsequent spectra that are passed to the FMT are used to calculate the new mask. The number of spectra used for the mask is configurable. Those spectra are summed together as they arrive. Once the appropriate number of spectra have been used, the average value is calculated, and the mask is multiplied by the threshold SNR (assuming the data are amplitude values, not power).

In triggering mode, each arriving spectrum is compared to the mask bin-by-bin. If a bin crosses the threshold, the spectrum passes the trigger and the bin-by-bin comparison is stopped.

It is possible to set a second threshold (threshold-power-snr-high). A second mask is calculated for this threshold and the incoming spectra are compared to both masks. The output trigger flag has an additional variable "high_threshold" which is set true if the higher threshold led to a trigger. It is always set to true if only one trigger level is used.

The mask can be written to a JSON file via the write_mask() function. The format for the file is: { "timestamp": "[timestamp]", "n-packets": [number of packets averaged], "mask": [value_0, value_1, . . . .] }

Parameter setting is not thread-safe. Executing (including switching modes) is thread-safe.

Node type: "frequency-mask-trigger"

Available configuration values:

Available DAQ commands:

Input Streams:

Output Streams:

Definition at line 83 of file frequency_mask_trigger.hh.

Member Enumeration Documentation

◆ status_t

enum status_t
strong
Enumerator
mask_update 
triggering 

Definition at line 87 of file frequency_mask_trigger.hh.

◆ threshold_t

enum threshold_t : uint32_t
strong
Enumerator
snr 
sigma 

Definition at line 103 of file frequency_mask_trigger.hh.

◆ trigger_mode_t

enum trigger_mode_t
strong
Enumerator
single_level 
two_level 

Definition at line 93 of file frequency_mask_trigger.hh.

Constructor & Destructor Documentation

◆ frequency_mask_trigger()

Definition at line 62 of file frequency_mask_trigger.cc.

◆ ~frequency_mask_trigger()

~frequency_mask_trigger ( )
virtual

Definition at line 84 of file frequency_mask_trigger.cc.

Member Function Documentation

◆ calculate_sigma_mask_spline_points()

void calculate_sigma_mask_spline_points ( std::vector< double > &  t_x_vals,
std::vector< double > &  t_y_vals,
double  threshold 
)

Definition at line 112 of file frequency_mask_trigger.cc.

◆ calculate_snr_mask_spline_points()

void calculate_snr_mask_spline_points ( std::vector< double > &  t_x_vals,
std::vector< double > &  t_y_vals,
double  threshold 
)

Definition at line 130 of file frequency_mask_trigger.cc.

◆ exe_add_to_mask()

void exe_add_to_mask ( exe_func_context a_ctx)
private

Definition at line 318 of file frequency_mask_trigger.cc.

◆ exe_apply_threshold()

void exe_apply_threshold ( exe_func_context a_ctx)
private

Definition at line 534 of file frequency_mask_trigger.cc.

◆ exe_apply_two_thresholds()

void exe_apply_two_thresholds ( exe_func_context a_ctx)
private

Definition at line 686 of file frequency_mask_trigger.cc.

◆ execute()

void execute ( midge::diptera *  a_midge = nullptr)

Definition at line 292 of file frequency_mask_trigger.cc.

◆ finalize()

void finalize ( )

Definition at line 857 of file frequency_mask_trigger.cc.

◆ get_threshold_type_str()

std::string get_threshold_type_str ( ) const
inline

Definition at line 218 of file frequency_mask_trigger.hh.

◆ get_trigger_mode_str()

std::string get_trigger_mode_str ( ) const
inline

Definition at line 213 of file frequency_mask_trigger.hh.

◆ initialize()

void initialize ( )

Definition at line 286 of file frequency_mask_trigger.cc.

◆ set_mask_parameters_from_node()

void set_mask_parameters_from_node ( const scarab::param_node &  a_mask_and_data_values)

Definition at line 148 of file frequency_mask_trigger.cc.

◆ set_n_packets_for_mask()

void set_n_packets_for_mask ( unsigned  a_n_pkts)

Definition at line 88 of file frequency_mask_trigger.cc.

◆ set_threshold_ampl_snr()

void set_threshold_ampl_snr ( double  a_ampl_snr)

Definition at line 98 of file frequency_mask_trigger.cc.

◆ set_threshold_dB()

void set_threshold_dB ( double  a_dB)

Definition at line 105 of file frequency_mask_trigger.cc.

◆ set_threshold_power_sigma()

void set_threshold_power_sigma ( double  a_power_sigma)

◆ set_threshold_power_sigma_high()

void set_threshold_power_sigma_high ( double  a_power_sigma)

◆ set_threshold_power_snr()

void set_threshold_power_snr ( double  a_power_snr)

◆ set_threshold_power_snr_high()

void set_threshold_power_snr_high ( double  a_power_snr)

◆ set_threshold_type()

void set_threshold_type ( const std::string &  a_threshold_type)
inline

Definition at line 208 of file frequency_mask_trigger.hh.

◆ set_trigger_mode()

void set_trigger_mode ( const std::string &  a_trigger_mode)
inline

Definition at line 203 of file frequency_mask_trigger.hh.

◆ snake_case_mv_accessible() [1/9]

snake_case_mv_accessible ( uint64_t  ,
length   
)

◆ snake_case_mv_accessible() [2/9]

snake_case_mv_accessible ( double  ,
threshold_snr   
)

◆ snake_case_mv_accessible() [3/9]

snake_case_mv_accessible ( double  ,
threshold_snr_high   
)

◆ snake_case_mv_accessible() [4/9]

snake_case_mv_accessible ( double  ,
threshold_sigma   
)

◆ snake_case_mv_accessible() [5/9]

snake_case_mv_accessible ( double  ,
threshold_sigma_high   
)

◆ snake_case_mv_accessible() [6/9]

snake_case_mv_accessible ( threshold_t  ,
threshold_type   
)

◆ snake_case_mv_accessible() [7/9]

snake_case_mv_accessible ( unsigned  ,
n_spline_points   
)

◆ snake_case_mv_accessible() [8/9]

snake_case_mv_accessible ( trigger_mode_t  ,
trigger_mode   
)

◆ snake_case_mv_accessible() [9/9]

snake_case_mv_accessible ( unsigned  ,
n_excluded_bins   
)

◆ snake_case_mv_accessible_noset() [1/2]

snake_case_mv_accessible_noset ( unsigned  ,
n_packets_for_mask   
)

◆ snake_case_mv_accessible_noset() [2/2]

snake_case_mv_accessible_noset ( status_t  ,
status   
)

◆ string_to_threshold()

frequency_mask_trigger::threshold_t string_to_threshold ( const std::string &  a_threshold_string)
static

Definition at line 55 of file frequency_mask_trigger.cc.

◆ string_to_trigger_mode()

frequency_mask_trigger::trigger_mode_t string_to_trigger_mode ( const std::string &  a_trigger_mode)
static

Definition at line 39 of file frequency_mask_trigger.cc.

◆ switch_to_apply_trigger()

void switch_to_apply_trigger ( )

Definition at line 202 of file frequency_mask_trigger.cc.

◆ switch_to_update_mask()

void switch_to_update_mask ( )

Definition at line 188 of file frequency_mask_trigger.cc.

◆ threshold_to_string()

std::string threshold_to_string ( frequency_mask_trigger::threshold_t  a_threshold)
static

Definition at line 47 of file frequency_mask_trigger.cc.

◆ threshold_to_uint()

uint32_t threshold_to_uint ( frequency_mask_trigger::threshold_t  a_threshold)
inlinestatic

Definition at line 194 of file frequency_mask_trigger.hh.

◆ trigger_mode_to_string()

std::string trigger_mode_to_string ( frequency_mask_trigger::trigger_mode_t  a_trigger_mode)
static

Definition at line 30 of file frequency_mask_trigger.cc.

◆ trigger_mode_to_uint()

uint32_t trigger_mode_to_uint ( frequency_mask_trigger::trigger_mode_t  a_trigger_mode)
inlinestatic

Definition at line 185 of file frequency_mask_trigger.hh.

◆ uint_to_threshold()

frequency_mask_trigger::threshold_t uint_to_threshold ( uint32_t  a_threshold_uint)
inlinestatic

Definition at line 198 of file frequency_mask_trigger.hh.

◆ uint_to_trigger_mode()

frequency_mask_trigger::trigger_mode_t uint_to_trigger_mode ( uint32_t  a_trigger_mode_uint)
inlinestatic

Definition at line 189 of file frequency_mask_trigger.hh.

◆ write_mask()

void write_mask ( const std::string &  a_filename)

Definition at line 230 of file frequency_mask_trigger.cc.

Member Data Documentation

◆ f_average_data

std::vector< double > f_average_data
private

Definition at line 177 of file frequency_mask_trigger.hh.

◆ f_break_exe_func

std::atomic< bool > f_break_exe_func
private

Definition at line 172 of file frequency_mask_trigger.hh.

◆ f_exe_func

void(frequency_mask_trigger::* f_exe_func) (exe_func_context &a_ctx)
private

Definition at line 170 of file frequency_mask_trigger.hh.

◆ f_exe_func_mutex

std::mutex f_exe_func_mutex
private

Definition at line 171 of file frequency_mask_trigger.hh.

◆ f_mask

std::vector< double > f_mask
private

Definition at line 175 of file frequency_mask_trigger.hh.

◆ f_mask2

std::vector< double > f_mask2
private

Definition at line 176 of file frequency_mask_trigger.hh.

◆ f_mask_mutex

std::mutex f_mask_mutex
private

Definition at line 181 of file frequency_mask_trigger.hh.

◆ f_n_summed

unsigned f_n_summed
private

Definition at line 179 of file frequency_mask_trigger.hh.

◆ f_variance_data

std::vector< double > f_variance_data
private

Definition at line 178 of file frequency_mask_trigger.hh.


The documentation for this class was generated from the following files: