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, int num_time_bins, timestamp_t time_bin_width, int num_chan_bins, channel_t n_channels_on_plane, 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)

Public Attributes

timestamp_t time_start
uint32_t adc_integral
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
15 // ADC and add it to the TP list.
16 adc_integral += input_tp.adc_integral;
17 tp_list.push_back(input_tp);
18};
std::vector< TriggerPrimitive > tp_list

◆ bin_window()

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

Definition at line 60 of file ProtoDUNEBSMWindow.cpp.

65 {
66
67 std::fill(input.begin(), input.end(), 0.0f);
68
69 const float inv_time_bin_width = 1.0f / time_bin_width;
70
71 for (const TriggerPrimitive& tp : tp_list) {
72 channel_t temp_tp_channel = tp.channel;
73 // If in PD-VD convert to effective channel here
74 if (effective_channel_mapper && use_pdvd_map) {
75 temp_tp_channel = effective_channel_mapper->remapCollectionPlaneChannel(temp_tp_channel);
76 }
77 size_t time_bin = static_cast<size_t>((tp.time_start - time_start) * inv_time_bin_width);
78 // Channel bin calculation matches model training - remainder channels are appended to 10th channel bin
79 size_t channel_bin = static_cast<size_t>(((temp_tp_channel - first_channel) * num_chan_bins) / n_channels_on_plane);
80
81 if (time_bin < num_time_bins && channel_bin < num_chan_bins) {
82 size_t index = channel_bin * num_time_bins + time_bin;
83 input[index] += tp.adc_integral;
84 }
85 }
86 input[num_time_bins * num_chan_bins] = adc_integral;
87};
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
dunedaq::trgdataformats::channel_t channel_t
Definition Types.hpp:20

◆ clear()

void triggeralgs::ProtoDUNEBSMWindow::clear ( )

Definition at line 20 of file ProtoDUNEBSMWindow.cpp.

20 {
21 tp_list.clear();
22};

◆ fill_entry_window()

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

Definition at line 89 of file ProtoDUNEBSMWindow.cpp.

89 {
90 for (size_t i = 0; i < input.size(); i++) {
91 entry_input[i].fvalue = input[i];
92 }
93}

◆ is_empty()

bool triggeralgs::ProtoDUNEBSMWindow::is_empty ( ) const

Definition at line 9 of file ProtoDUNEBSMWindow.cpp.

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

◆ move()

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

Definition at line 24 of file ProtoDUNEBSMWindow.cpp.

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

◆ reset()

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

Definition at line 48 of file ProtoDUNEBSMWindow.cpp.

48 {
49 // Empty the TP list.
50 tp_list.clear();
51 // Set the start time of the window to be the start time of the
52 // input_tp.
53 time_start = input_tp.time_start;
54 // Start the total ADC integral.
55 adc_integral = input_tp.adc_integral;
56 // Add the input TP to the TP list.
57 tp_list.push_back(input_tp);
58};

◆ operator<<

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

Definition at line 95 of file ProtoDUNEBSMWindow.cpp.

95 {
96 if(window.is_empty()) os << "Window is empty!\n";
97 else{
98 os << "Window start: " << window.time_start << ", end: " << window.tp_list.back().time_start;
99 os << ". Total of: " << window.adc_integral << " ADC counts with " << window.tp_list.size() << " TPs.\n";
100 }
101 return os;
102};

Member Data Documentation

◆ adc_integral

uint32_t triggeralgs::ProtoDUNEBSMWindow::adc_integral

Definition at line 41 of file ProtoDUNEBSMWindow.hpp.

◆ time_start

timestamp_t triggeralgs::ProtoDUNEBSMWindow::time_start

Definition at line 40 of file ProtoDUNEBSMWindow.hpp.

◆ tp_list

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

Definition at line 42 of file ProtoDUNEBSMWindow.hpp.


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