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

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
 
uint32_t adc_integral
 
std::unordered_map< channel_t, uint16_t > channel_states
 
std::vector< TriggerPrimitiveinputs
 

Friends

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

Detailed Description

Definition at line 26 of file TAMakerMichelElectronAlgorithm.hpp.

Member Function Documentation

◆ add()

void triggeralgs::TAMakerMichelElectronAlgorithm::Window::add ( TriggerPrimitive const & input_tp)
inline

Definition at line 30 of file TAMakerMichelElectronAlgorithm.hpp.

31 {
32 // Add the input TP's contribution to the total ADC, increase hit channel's hit count and add it to the TP list.
33 adc_integral += input_tp.adc_integral;
34 channel_states[input_tp.channel]++;
35 inputs.push_back(input_tp);
36 };

◆ clear()

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

Definition at line 37 of file TAMakerMichelElectronAlgorithm.hpp.

37{ inputs.clear(); };

◆ is_empty()

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

Definition at line 29 of file TAMakerMichelElectronAlgorithm.hpp.

29{ return inputs.empty(); };

◆ move()

void triggeralgs::TAMakerMichelElectronAlgorithm::Window::move ( TriggerPrimitive const & input_tp,
timestamp_t const & window_length )
inline

Definition at line 39 of file TAMakerMichelElectronAlgorithm.hpp.

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

◆ n_channels_hit()

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

Definition at line 38 of file TAMakerMichelElectronAlgorithm.hpp.

38{ return channel_states.size(); };

◆ reset()

void triggeralgs::TAMakerMichelElectronAlgorithm::Window::reset ( TriggerPrimitive const & input_tp)
inline

Definition at line 72 of file TAMakerMichelElectronAlgorithm.hpp.

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

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 88 of file TAMakerMichelElectronAlgorithm.hpp.

89 {
90 if (window.is_empty())
91 os << "Window is empty!\n";
92 else {
93 os << "Window start: " << window.time_start << ", end: " << window.inputs.back().time_start;
94 os << ". Total of: " << window.adc_integral << " ADC counts with " << window.inputs.size() << " TPs.\n";
95 os << window.channel_states.size() << " independent channels have hits.\n";
96 }
97 return os;
98 };

Member Data Documentation

◆ adc_integral

uint32_t triggeralgs::TAMakerMichelElectronAlgorithm::Window::adc_integral

Definition at line 101 of file TAMakerMichelElectronAlgorithm.hpp.

◆ channel_states

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

Definition at line 102 of file TAMakerMichelElectronAlgorithm.hpp.

◆ inputs

std::vector<TriggerPrimitive> triggeralgs::TAMakerMichelElectronAlgorithm::Window::inputs

Definition at line 103 of file TAMakerMichelElectronAlgorithm.hpp.

◆ time_start

timestamp_t triggeralgs::TAMakerMichelElectronAlgorithm::Window::time_start

Definition at line 100 of file TAMakerMichelElectronAlgorithm.hpp.


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