DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
triggeralgs::ProtoDUNEBSMWindow Class Reference

#include <ProtoDUNEBSMWindow.hpp>

Public Member Functions

bool is_empty () const
 
void add (TriggerPrimitive const &input_tp)
 
void clear ()
 
void move (TriggerPrimitive const &input_tp, timestamp_t const &window_length)
 
void reset (TriggerPrimitive const &input_tp)
 
void bin_window (std::vector< float > &input, timestamp_t time_bin_width, channel_t chan_bin_width, int num_time_bins, int num_chan_bins, channel_t first_channel, std::unique_ptr< PDVDEffectiveChannelMap > const &effective_channel_mapper, bool use_pdvd_map)
 
void fill_entry_window (std::vector< Entry > &entry_input, std::vector< float > &input)
 
float mean_sadc ()
 
float mean_adc_peak ()
 
float mean_tot ()
 

Public Attributes

timestamp_t time_start
 
uint32_t adc_integral
 
uint64_t adc_peak_sum
 
uint64_t tot_sum
 
std::vector< TriggerPrimitivetp_list
 

Friends

std::ostream & operator<< (std::ostream &os, const ProtoDUNEBSMWindow &window)
 

Detailed Description

Definition at line 20 of file ProtoDUNEBSMWindow.hpp.

Member Function Documentation

◆ add()

void triggeralgs::ProtoDUNEBSMWindow::add ( TriggerPrimitive const & input_tp)

Definition at line 13 of file ProtoDUNEBSMWindow.cpp.

13 {
14 // Add the input TP's contribution to the total ADC and add it to
15 // the TP list. Also keep running sum of all the samples over threshold
16 // and the peak ADC. These are used for samples/peak ratio cut
17 adc_integral += input_tp.adc_integral;
18 adc_peak_sum += input_tp.adc_peak;
19 tot_sum += input_tp.samples_over_threshold;
20 tp_list.push_back(input_tp);
21};
std::vector< TriggerPrimitive > tp_list

◆ bin_window()

void triggeralgs::ProtoDUNEBSMWindow::bin_window ( std::vector< float > & input,
timestamp_t time_bin_width,
channel_t chan_bin_width,
int num_time_bins,
int num_chan_bins,
channel_t first_channel,
std::unique_ptr< PDVDEffectiveChannelMap > const & effective_channel_mapper,
bool use_pdvd_map )

Definition at line 65 of file ProtoDUNEBSMWindow.cpp.

70 {
71 std::fill(input.begin(), input.end(), 0.0f);
72
73 const float inv_time_bin_width = 1.0f / time_bin_width;
74 const float inv_chan_bin_width = 1.0f / chan_bin_width;
75
76 for (const TriggerPrimitive& tp : tp_list) {
77 channel_t temp_tp_channel = tp.channel;
78 // If in PD-VD convert to effective channel here
79 if (effective_channel_mapper && use_pdvd_map) {
80 temp_tp_channel = effective_channel_mapper->remapCollectionPlaneChannel(temp_tp_channel);
81 }
82 size_t time_bin = static_cast<size_t>((tp.time_start - time_start) * inv_time_bin_width);
83 size_t channel_bin = static_cast<size_t>((temp_tp_channel - first_channel) * inv_chan_bin_width);
84 if (time_bin < num_time_bins && channel_bin < num_chan_bins) {
85 size_t index = channel_bin * num_time_bins + time_bin;
86 input[index] += tp.adc_integral;
87 }
88 }
89 input[num_time_bins * num_chan_bins] = adc_integral;
90};
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
dunedaq::trgdataformats::channel_t channel_t
Definition Types.hpp:20

◆ clear()

void triggeralgs::ProtoDUNEBSMWindow::clear ( )

Definition at line 23 of file ProtoDUNEBSMWindow.cpp.

23 {
24 tp_list.clear();
25};

◆ fill_entry_window()

void triggeralgs::ProtoDUNEBSMWindow::fill_entry_window ( std::vector< Entry > & entry_input,
std::vector< float > & input )

Definition at line 92 of file ProtoDUNEBSMWindow.cpp.

92 {
93 for (size_t i = 0; i < input.size(); i++) {
94 entry_input[i].fvalue = input[i];
95 }
96}

◆ is_empty()

bool triggeralgs::ProtoDUNEBSMWindow::is_empty ( ) const

Definition at line 9 of file ProtoDUNEBSMWindow.cpp.

9 {
10 return tp_list.empty();
11};

◆ mean_adc_peak()

float triggeralgs::ProtoDUNEBSMWindow::mean_adc_peak ( )

Definition at line 101 of file ProtoDUNEBSMWindow.cpp.

101 {
102 return static_cast<float>(adc_peak_sum / tp_list.size());
103}

◆ mean_sadc()

float triggeralgs::ProtoDUNEBSMWindow::mean_sadc ( )

Definition at line 98 of file ProtoDUNEBSMWindow.cpp.

98 {
99 return static_cast<float>(adc_integral / tp_list.size());;
100}

◆ mean_tot()

float triggeralgs::ProtoDUNEBSMWindow::mean_tot ( )

Definition at line 104 of file ProtoDUNEBSMWindow.cpp.

104 {
105 return static_cast<float>(tot_sum / tp_list.size());
106}

◆ move()

void triggeralgs::ProtoDUNEBSMWindow::move ( TriggerPrimitive const & input_tp,
timestamp_t const & window_length )

Definition at line 27 of file ProtoDUNEBSMWindow.cpp.

27 {
28 // Find all of the TPs in the window that need to be removed
29 // if the input_tp is to be added and the size of the window
30 // is to be conserved.
31 // Substract those TPs' contribution from the total window ADC.
32 uint32_t n_tps_to_erase = 0;
33 for(auto tp : tp_list){
34 if(!(input_tp.time_start-tp.time_start < window_length)){
35 n_tps_to_erase++;
36 adc_integral -= tp.adc_integral;
37 adc_peak_sum -= tp.adc_peak;
38 tot_sum -= tp.samples_over_threshold;
39 }
40 else break;
41 }
42 // Erase the TPs from the window.
43 tp_list.erase(tp_list.begin(), tp_list.begin()+n_tps_to_erase);
44 // Make the window start time the start time of what is now the
45 // first TP.
46 if(tp_list.size()!=0){
47 time_start = tp_list.front().time_start;
48 add(input_tp);
49 }
50 else reset(input_tp);
51};
void add(TriggerPrimitive const &input_tp)
void reset(TriggerPrimitive const &input_tp)

◆ reset()

void triggeralgs::ProtoDUNEBSMWindow::reset ( TriggerPrimitive const & input_tp)

Definition at line 53 of file ProtoDUNEBSMWindow.cpp.

53 {
54 // Empty the TP list.
55 tp_list.clear();
56 // Set the start time of the window to be the start time of the
57 // input_tp.
58 time_start = input_tp.time_start;
59 // Start the total ADC integral.
60 adc_integral = input_tp.adc_integral;
61 // Add the input TP to the TP list.
62 tp_list.push_back(input_tp);
63};

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const ProtoDUNEBSMWindow & window )
friend

Definition at line 108 of file ProtoDUNEBSMWindow.cpp.

108 {
109 if(window.is_empty()) os << "Window is empty!\n";
110 else{
111 os << "Window start: " << window.time_start << ", end: " << window.tp_list.back().time_start;
112 os << ". Total of: " << window.adc_integral << " ADC counts with " << window.tp_list.size() << " TPs.\n";
113 }
114 return os;
115};

Member Data Documentation

◆ adc_integral

uint32_t triggeralgs::ProtoDUNEBSMWindow::adc_integral

Definition at line 44 of file ProtoDUNEBSMWindow.hpp.

◆ adc_peak_sum

uint64_t triggeralgs::ProtoDUNEBSMWindow::adc_peak_sum

Definition at line 45 of file ProtoDUNEBSMWindow.hpp.

◆ time_start

timestamp_t triggeralgs::ProtoDUNEBSMWindow::time_start

Definition at line 43 of file ProtoDUNEBSMWindow.hpp.

◆ tot_sum

uint64_t triggeralgs::ProtoDUNEBSMWindow::tot_sum

Definition at line 46 of file ProtoDUNEBSMWindow.hpp.

◆ tp_list

std::vector<TriggerPrimitive> triggeralgs::ProtoDUNEBSMWindow::tp_list

Definition at line 47 of file ProtoDUNEBSMWindow.hpp.


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