DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TAMakerADCSimpleWindowAlgorithm.hpp
Go to the documentation of this file.
1
9#ifndef TRIGGERALGS_ADCSIMPLEWINDOW_TRIGGERACTIVITYMAKERADCSIMPLEWINDOW_HPP_
10#define TRIGGERALGS_ADCSIMPLEWINDOW_TRIGGERACTIVITYMAKERADCSIMPLEWINDOW_HPP_
11
13#include "triggeralgs/Types.hpp"
14
15#include <vector>
16
17namespace triggeralgs {
19{
20
21public:
22 void process(const TriggerPrimitive& input_tp, std::vector<TriggerActivity>& output_ta);
23
24 void configure(const nlohmann::json &config);
25
26private:
27 class Window {
28 public:
29 bool is_empty() const{
30 return tp_list.empty();
31 };
32 void add(TriggerPrimitive const &input_tp){
33 // Add the input TP's contribution to the total ADC and add it to
34 // the TP list.
35 adc_integral += input_tp.adc_integral;
36 tp_list.push_back(input_tp);
37 };
38 void clear(){
39 tp_list.clear();
40 };
41 void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length){
42 // Find all of the TPs in the window that need to be removed
43 // if the input_tp is to be added and the size of the window
44 // is to be conserved.
45 // Substract those TPs' contribution from the total window ADC.
46 uint32_t n_tps_to_erase = 0;
47 for(auto tp : tp_list){
48 if(!(input_tp.time_start-tp.time_start < window_length)){
49 n_tps_to_erase++;
50 adc_integral -= tp.adc_integral;
51 }
52 else break;
53 }
54 // Erase the TPs from the window.
55 tp_list.erase(tp_list.begin(), tp_list.begin()+n_tps_to_erase);
56 // Make the window start time the start time of what is now the
57 // first TP.
58 if(tp_list.size()!=0){
59 time_start = tp_list.front().time_start;
60 add(input_tp);
61 }
62 else reset(input_tp);
63 };
64 void reset(TriggerPrimitive const &input_tp){
65 // Empty the TP list.
66 tp_list.clear();
67 // Set the start time of the window to be the start time of the
68 // input_tp.
69 time_start = input_tp.time_start;
70 // Start the total ADC integral.
71 adc_integral = input_tp.adc_integral;
72 // Add the input TP to the TP list.
73 tp_list.push_back(input_tp);
74 };
75 friend std::ostream& operator<<(std::ostream& os, const Window& window){
76 if(window.is_empty()) os << "Window is empty!\n";
77 else{
78 os << "Window start: " << window.time_start << ", end: " << window.tp_list.back().time_start;
79 os << ". Total of: " << window.adc_integral << " ADC counts with " << window.tp_list.size() << " TPs.\n";
80 }
81 return os;
82 };
83
85 uint32_t adc_integral;
86 std::vector<TriggerPrimitive> tp_list;
87 };
88
90
92 uint64_t m_primitive_count = 0;
93
94 // Configurable parameters.
95 uint32_t m_adc_threshold = 1200000;
97};
98} // namespace triggeralgs
99
100#endif // TRIGGERALGS_ADCSIMPLEWINDOW_TRIGGERACTIVITYMAKERADCSIMPLEWINDOW_HPP_
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
friend std::ostream & operator<<(std::ostream &os, const Window &window)
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
TP processing function that creates & fills TAs.
dunedaq::trgdataformats::timestamp_t timestamp_t
Definition Types.hpp:16
A single energy deposition on a TPC or PDS channel.