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

Public Member Functions

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

Public Attributes

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

Friends

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

Detailed Description

Definition at line 32 of file TCMakerMichelElectronAlgorithm.hpp.

Member Function Documentation

◆ add()

void triggeralgs::TCMakerMichelElectronAlgorithm::Window::add ( const TriggerActivity & input_ta)
inline

Definition at line 36 of file TCMakerMichelElectronAlgorithm.hpp.

37 {
38 // Add the input TA's contribution to the total ADC, increase the hit count
39 // of all of the channels which feature and add it to the TA list keeping the TA
40 // list time ordered by time_start. Preserving time order makes moving easier.
41 adc_integral += input_ta.adc_integral;
42 for (TriggerPrimitive tp : input_ta.inputs) {
43 channel_states[tp.channel]++;
44 }
45 // Perform binary search based on time_start.
46 uint16_t insert_at = 0;
47 for (auto ta : inputs) {
48 if (input_ta.time_start < ta.time_start)
49 break;
50 insert_at++;
51 }
52 inputs.insert(inputs.begin() + insert_at, input_ta);
53 };
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive

◆ clear()

void triggeralgs::TCMakerMichelElectronAlgorithm::Window::clear ( )
inline

Definition at line 54 of file TCMakerMichelElectronAlgorithm.hpp.

54{ inputs.clear(); };

◆ is_empty()

bool triggeralgs::TCMakerMichelElectronAlgorithm::Window::is_empty ( ) const
inline

Definition at line 35 of file TCMakerMichelElectronAlgorithm.hpp.

35{ return inputs.empty(); };

◆ move()

void triggeralgs::TCMakerMichelElectronAlgorithm::Window::move ( TriggerActivity const & input_ta,
timestamp_t const & window_length )
inline

Definition at line 56 of file TCMakerMichelElectronAlgorithm.hpp.

57 {
58 // Find all of the TAs in the window that need to be removed
59 // if the input_ta is to be added and the size of the window
60 // is to be conserved.
61 // Subtract those TAs' contribution from the total window ADC and remove their
62 // contributions to the hit counts.
63 uint32_t n_tas_to_erase = 0;
64 for (auto ta : inputs) {
65 if (!(input_ta.time_start - ta.time_start < window_length)) {
66 n_tas_to_erase++;
67 adc_integral -= ta.adc_integral;
68 for (TriggerPrimitive tp : ta.inputs) {
69 channel_states[tp.channel]--;
70 // If a TA being removed from the window results in a channel no longer having
71 // any hits, remove from the states map so map.size() can be used for number
72 // channel hits.
73 if (channel_states[tp.channel] == 0)
74 channel_states.erase(tp.channel);
75 }
76 } else
77 break;
78 }
79 // Erase the TAs from the window.
80 inputs.erase(inputs.begin(), inputs.begin() + n_tas_to_erase);
81 // Make the window start time the start time of what is now the
82 // first TA.
83 if (inputs.size() != 0) {
84 time_start = inputs.front().time_start;
85 add(input_ta);
86 } else
87 add(input_ta);
88 }

◆ n_channels_hit()

uint16_t triggeralgs::TCMakerMichelElectronAlgorithm::Window::n_channels_hit ( )
inline

Definition at line 55 of file TCMakerMichelElectronAlgorithm.hpp.

55{ return channel_states.size(); };

◆ reset()

void triggeralgs::TCMakerMichelElectronAlgorithm::Window::reset ( TriggerActivity const & input_ta)
inline

Definition at line 89 of file TCMakerMichelElectronAlgorithm.hpp.

90 {
91 // Empty the channel and TA lists.
92 channel_states.clear();
93 inputs.clear();
94 // Set the start time of the window to be the start time of the
95 // input_ta.
96 time_start = input_ta.time_start;
97 // Start the total ADC integral.
98 adc_integral = input_ta.adc_integral;
99 // Start hit count for the hit channels.
100 for (TriggerPrimitive tp : input_ta.inputs) {
101 channel_states[tp.channel]++;
102 }
103 // Add the input TA to the TA list.
104 inputs.push_back(input_ta);
105 }

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 106 of file TCMakerMichelElectronAlgorithm.hpp.

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

Member Data Documentation

◆ adc_integral

uint64_t triggeralgs::TCMakerMichelElectronAlgorithm::Window::adc_integral

Definition at line 119 of file TCMakerMichelElectronAlgorithm.hpp.

◆ channel_states

std::unordered_map<channel_t, uint16_t> triggeralgs::TCMakerMichelElectronAlgorithm::Window::channel_states

Definition at line 120 of file TCMakerMichelElectronAlgorithm.hpp.

◆ inputs

std::vector<TriggerActivity> triggeralgs::TCMakerMichelElectronAlgorithm::Window::inputs

Definition at line 121 of file TCMakerMichelElectronAlgorithm.hpp.

◆ time_start

timestamp_t triggeralgs::TCMakerMichelElectronAlgorithm::Window::time_start

Definition at line 118 of file TCMakerMichelElectronAlgorithm.hpp.


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