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

#include <TPWindow.hpp>

Public Member Functions

bool is_empty () const
 
void add (TriggerPrimitive const &input_tp)
 
void clear ()
 
uint16_t n_channels_hit ()
 
void move (TriggerPrimitive const &input_tp, timestamp_t const &window_length)
 
void reset (TriggerPrimitive const &input_tp)
 

Public Attributes

timestamp_t time_start = 0
 
uint32_t adc_integral = 0
 
std::unordered_map< channel_t, uint16_t > channel_states
 
std::vector< TriggerPrimitiveinputs
 

Friends

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

Detailed Description

Definition at line 20 of file TPWindow.hpp.

Member Function Documentation

◆ add()

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

Definition at line 20 of file TPWindow.cpp.

21{
22 // Add the input TP's contribution to the total ADC, increase hit
23 // channel's hit count and add it to the TP list.
24 adc_integral += input_tp.adc_integral;
25 channel_states[input_tp.channel]++;
26 inputs.push_back(input_tp);
27}
std::unordered_map< channel_t, uint16_t > channel_states
Definition TPWindow.hpp:39
std::vector< TriggerPrimitive > inputs
Definition TPWindow.hpp:40

◆ clear()

void triggeralgs::TPWindow::clear ( )

Definition at line 30 of file TPWindow.cpp.

31{
32 inputs.clear();
33 channel_states.clear();
34 time_start = 0;
35 adc_integral = 0;
36}
timestamp_t time_start
Definition TPWindow.hpp:37

◆ is_empty()

bool triggeralgs::TPWindow::is_empty ( ) const

Definition at line 14 of file TPWindow.cpp.

15{
16 return inputs.empty();
17}

◆ move()

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

Definition at line 45 of file TPWindow.cpp.

46{
47 // Find all of the TPs in the window that need to be removed
48 // if the input_tp is to be added and the size of the window
49 // is to be conserved.
50 // Substract those TPs' contribution from the total window ADC and remove their
51 // contributions to the hit counts.
52 uint32_t n_tps_to_erase = 0;
53 for (auto tp : inputs) {
54 if (!(input_tp.time_start - tp.time_start < window_length)) {
55 n_tps_to_erase++;
56 adc_integral -= tp.adc_integral;
57 channel_states[tp.channel]--;
58 // If a TP being removed from the window results in a channel no longer having
59 // any hits, remove from the states map so map.size() can be used for number
60 // channels hit.
61 if (channel_states[tp.channel] == 0)
62 channel_states.erase(tp.channel);
63 } else
64 break;
65 }
66 // Erase the TPs from the window.
67 inputs.erase(inputs.begin(), inputs.begin() + n_tps_to_erase);
68 // Make the window start time the start time of what is now the first TP.
69
70 if (inputs.size() != 0) {
71 time_start = inputs.front().time_start;
72 add(input_tp);
73 } else {
74 reset(input_tp);
75 }
76}
void reset(TriggerPrimitive const &input_tp)
Definition TPWindow.cpp:79
void add(TriggerPrimitive const &input_tp)
Definition TPWindow.cpp:20

◆ n_channels_hit()

uint16_t triggeralgs::TPWindow::n_channels_hit ( )

Definition at line 39 of file TPWindow.cpp.

40{
41 return channel_states.size();
42}

◆ reset()

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

Definition at line 79 of file TPWindow.cpp.

80{
81
82 // Empty the channel and TP lists.
83 channel_states.clear();
84 inputs.clear();
85 // Set the start time of the window to be the start time of theinput_tp.
86 time_start = input_tp.time_start;
87 // Start the total ADC integral.
88 adc_integral = input_tp.adc_integral;
89 // Start hit count for the hit channel.
90 channel_states[input_tp.channel]++;
91 // Add the input TP to the TP list.
92 inputs.push_back(input_tp);
93 // std::cout << "Number of channels hit: " << n_channels_hit() << std::endl;
94}

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 96 of file TPWindow.cpp.

98{
99 if (window.is_empty()) {
100 os << "Window is empty!\n";
101 } else {
102 os << "Window start: " << window.time_start << ", end: " << window.inputs.back().time_start;
103 os << ". Total of: " << window.adc_integral << " ADC counts with " << window.inputs.size() << " TPs.\n";
104 os << window.channel_states.size() << " independent channels have hits.\n";
105 }
106 return os;
107}

Member Data Documentation

◆ adc_integral

uint32_t triggeralgs::TPWindow::adc_integral = 0

Definition at line 38 of file TPWindow.hpp.

◆ channel_states

std::unordered_map<channel_t, uint16_t> triggeralgs::TPWindow::channel_states

Definition at line 39 of file TPWindow.hpp.

◆ inputs

std::vector<TriggerPrimitive> triggeralgs::TPWindow::inputs

Definition at line 40 of file TPWindow.hpp.

◆ time_start

timestamp_t triggeralgs::TPWindow::time_start = 0

Definition at line 37 of file TPWindow.hpp.


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