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

#include <TAWindow.hpp>

Public Member Functions

bool is_empty () const
 
void add (const TriggerActivity &input_ta)
 Add the input TA's contribution to the total ADC, increase the hit count of all of the channels which feature and add it to the TA list keeping the TA list time ordered by time_start. Preserving time order makes moving easier.
 
void clear ()
 Clear all inputs.
 
uint16_t n_channels_hit ()
 
void move (TriggerActivity const &input_ta, timestamp_t const &window_length)
 Find all of the TAs in the window that need to be removed if the input_ta is to be added and the size of the window is to be conserved. Subtract those TAs' contribution from the total window ADC and remove their contributions to the hit counts.
 
void reset (TriggerActivity const &input_ta)
 Reset window content on the input.
 

Public Attributes

timestamp_t time_start = 0
 
uint64_t adc_integral = 0
 
std::unordered_map< channel_t, uint16_t > channel_states
 
std::vector< TriggerActivityinputs
 

Friends

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

Detailed Description

Definition at line 19 of file TAWindow.hpp.

Member Function Documentation

◆ add()

void triggeralgs::TAWindow::add ( const TriggerActivity & input_ta)

Add the input TA's contribution to the total ADC, increase the hit count of all of the channels which feature and add it to the TA list keeping the TA list time ordered by time_start. Preserving time order makes moving easier.

Parameters
input_ta

Definition at line 16 of file TAWindow.cpp.

17{
18
19 adc_integral += input_ta.adc_integral;
20 for (TriggerPrimitive tp : input_ta.inputs) {
21 channel_states[tp.channel]++;
22 }
23 // Perform binary search based on time_start.
24 uint16_t insert_at = 0;
25 for (auto ta : inputs) {
26 if (input_ta.time_start < ta.time_start)
27 break;
28 insert_at++;
29 }
30 inputs.insert(inputs.begin() + insert_at, input_ta);
31}
std::vector< TriggerActivity > inputs
Definition TAWindow.hpp:55
std::unordered_map< channel_t, uint16_t > channel_states
Definition TAWindow.hpp:54
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive

◆ clear()

void triggeralgs::TAWindow::clear ( )

Clear all inputs.

Definition at line 35 of file TAWindow.cpp.

36{
37 inputs.clear();
38 channel_states.clear();
39 time_start = 0;
40 adc_integral = 0;
41};
timestamp_t time_start
Definition TAWindow.hpp:52

◆ is_empty()

bool triggeralgs::TAWindow::is_empty ( ) const
inline

Definition at line 22 of file TAWindow.hpp.

22{ return inputs.empty(); };

◆ move()

void triggeralgs::TAWindow::move ( TriggerActivity const & input_ta,
timestamp_t const & window_length )

Find all of the TAs in the window that need to be removed if the input_ta is to be added and the size of the window is to be conserved. Subtract those TAs' contribution from the total window ADC and remove their contributions to the hit counts.

Parameters
input_ta
window_length

Definition at line 45 of file TAWindow.cpp.

46{
47 uint32_t n_tas_to_erase = 0;
48 for (auto ta : inputs) {
49 if (!(input_ta.time_start - ta.time_start < window_length)) {
50 n_tas_to_erase++;
51 adc_integral -= ta.adc_integral;
52 for (TriggerPrimitive tp : ta.inputs) {
53 channel_states[tp.channel]--;
54 // If a TA being removed from the window results in a channel no longer having
55 // any hits, remove from the states map so map.size() can be used for number
56 // channel hits.
57 if (channel_states[tp.channel] == 0)
58 channel_states.erase(tp.channel);
59 }
60 } else
61 break;
62 }
63 // Erase the TAs from the window.
64 inputs.erase(inputs.begin(), inputs.begin() + n_tas_to_erase);
65 // Make the window start time the start time of what is now the
66 // first TA.
67 if (inputs.size() != 0) {
68 time_start = inputs.front().time_start;
69 add(input_ta);
70 } else {
71 reset(input_ta);
72 }
73 // add(input_ta);
74 // time_start = inputs.front().time_start;
75}
void add(const TriggerActivity &input_ta)
Add the input TA's contribution to the total ADC, increase the hit count of all of the channels which...
Definition TAWindow.cpp:16
void reset(TriggerActivity const &input_ta)
Reset window content on the input.
Definition TAWindow.cpp:79

◆ n_channels_hit()

uint16_t triggeralgs::TAWindow::n_channels_hit ( )
inline

Definition at line 34 of file TAWindow.hpp.

34{ return channel_states.size(); };

◆ reset()

void triggeralgs::TAWindow::reset ( TriggerActivity const & input_ta)

Reset window content on the input.

Parameters
input_ta

Definition at line 79 of file TAWindow.cpp.

80{
81 // Empty the channel and TA lists.
82 channel_states.clear();
83 inputs.clear();
84 // Set the start time of the window to be the start time of the
85 // input_ta.
86 time_start = input_ta.time_start;
87 // Start the total ADC integral.
88 adc_integral = input_ta.adc_integral;
89 // Start hit count for the hit channels.
90 for (TriggerPrimitive tp : input_ta.inputs) {
91 channel_states[tp.channel]++;
92 }
93 // Add the input TA to the TA list.
94 inputs.push_back(input_ta);
95}

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 97 of file TAWindow.cpp.

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

Member Data Documentation

◆ adc_integral

uint64_t triggeralgs::TAWindow::adc_integral = 0

Definition at line 53 of file TAWindow.hpp.

◆ channel_states

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

Definition at line 54 of file TAWindow.hpp.

◆ inputs

std::vector<TriggerActivity> triggeralgs::TAWindow::inputs

Definition at line 55 of file TAWindow.hpp.

◆ time_start

timestamp_t triggeralgs::TAWindow::time_start = 0

Definition at line 52 of file TAWindow.hpp.


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