DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
src
ProtoDUNEBSMWindow
ProtoDUNEBSMWindow.cpp
Go to the documentation of this file.
1
#include "
triggeralgs/ProtoDUNEBSMWindow/ProtoDUNEBSMWindow.hpp
"
2
3
#include <ostream>
4
#include <vector>
5
#include <numeric>
6
7
namespace
triggeralgs
{
8
9
bool
ProtoDUNEBSMWindow::is_empty
()
const
{
10
return
tp_list
.empty();
11
};
12
13
void
ProtoDUNEBSMWindow::add
(
TriggerPrimitive
const
&input_tp){
14
// Add the input TP's contribution to the total ADC and add it to
15
// the TP list. Also keep running sum of all the samples over threshold
16
// and the peak ADC. These are used for samples/peak ratio cut
17
adc_integral
+= input_tp.
adc_integral
;
18
adc_peak_sum
+= input_tp.
adc_peak
;
19
tot_sum
+= input_tp.
samples_over_threshold
;
20
tp_list
.push_back(input_tp);
21
};
22
23
void
ProtoDUNEBSMWindow::clear
(){
24
tp_list
.clear();
25
};
26
27
void
ProtoDUNEBSMWindow::move
(
TriggerPrimitive
const
&input_tp,
timestamp_t
const
&window_length){
28
// Find all of the TPs in the window that need to be removed
29
// if the input_tp is to be added and the size of the window
30
// is to be conserved.
31
// Substract those TPs' contribution from the total window ADC.
32
uint32_t n_tps_to_erase = 0;
33
for
(
auto
tp :
tp_list
){
34
if
(!(input_tp.
time_start
-tp.time_start < window_length)){
35
n_tps_to_erase++;
36
adc_integral
-= tp.adc_integral;
37
adc_peak_sum
-= tp.adc_peak;
38
tot_sum
-= tp.samples_over_threshold;
39
}
40
else
break
;
41
}
42
// Erase the TPs from the window.
43
tp_list
.erase(
tp_list
.begin(),
tp_list
.begin()+n_tps_to_erase);
44
// Make the window start time the start time of what is now the
45
// first TP.
46
if
(
tp_list
.size()!=0){
47
time_start
=
tp_list
.front().time_start;
48
add
(input_tp);
49
}
50
else
reset
(input_tp);
51
};
52
53
void
ProtoDUNEBSMWindow::reset
(
TriggerPrimitive
const
&input_tp){
54
// Empty the TP list.
55
tp_list
.clear();
56
// Set the start time of the window to be the start time of the
57
// input_tp.
58
time_start
= input_tp.
time_start
;
59
// Start the total ADC integral.
60
adc_integral
= input_tp.
adc_integral
;
61
// Add the input TP to the TP list.
62
tp_list
.push_back(input_tp);
63
};
64
65
void
ProtoDUNEBSMWindow::bin_window
(
66
std::vector<float> &input,
timestamp_t
time_bin_width,
67
channel_t
chan_bin_width,
int
num_time_bins,
68
int
num_chan_bins,
channel_t
first_channel,
69
std::unique_ptr<PDVDEffectiveChannelMap>
const
&effective_channel_mapper,
70
bool
use_pdvd_map) {
71
std::fill(input.begin(), input.end(), 0.0f);
72
73
const
float
inv_time_bin_width = 1.0f / time_bin_width;
74
const
float
inv_chan_bin_width = 1.0f / chan_bin_width;
75
76
for
(
const
TriggerPrimitive
& tp :
tp_list
) {
77
channel_t
temp_tp_channel = tp.channel;
78
// If in PD-VD convert to effective channel here
79
if
(effective_channel_mapper && use_pdvd_map) {
80
temp_tp_channel = effective_channel_mapper->remapCollectionPlaneChannel(temp_tp_channel);
81
}
82
size_t
time_bin =
static_cast<
size_t
>
((tp.time_start -
time_start
) * inv_time_bin_width);
83
size_t
channel_bin =
static_cast<
size_t
>
((temp_tp_channel - first_channel) * inv_chan_bin_width);
84
if
(time_bin < num_time_bins && channel_bin < num_chan_bins) {
85
size_t
index = channel_bin * num_time_bins + time_bin;
86
input[index] += tp.adc_integral;
87
}
88
}
89
input[num_time_bins * num_chan_bins] =
adc_integral
;
90
};
91
92
void
ProtoDUNEBSMWindow::fill_entry_window
(std::vector<Entry> &entry_input, std::vector<float> &input) {
93
for
(
size_t
i = 0; i < input.size(); i++) {
94
entry_input[i].fvalue = input[i];
95
}
96
}
97
98
float
ProtoDUNEBSMWindow::mean_sadc
() {
99
return
static_cast<
float
>
(
adc_integral
/
tp_list
.size());;
100
}
101
float
ProtoDUNEBSMWindow::mean_adc_peak
() {
102
return
static_cast<
float
>
(
adc_peak_sum
/
tp_list
.size());
103
}
104
float
ProtoDUNEBSMWindow::mean_tot
() {
105
return
static_cast<
float
>
(
tot_sum
/
tp_list
.size());
106
}
107
108
std::ostream&
operator<<
(std::ostream& os,
const
ProtoDUNEBSMWindow
& window){
109
if
(window.
is_empty
()) os <<
"Window is empty!\n"
;
110
else
{
111
os <<
"Window start: "
<< window.
time_start
<<
", end: "
<< window.
tp_list
.back().time_start;
112
os <<
". Total of: "
<< window.
adc_integral
<<
" ADC counts with "
<< window.
tp_list
.size() <<
" TPs.\n"
;
113
}
114
return
os;
115
};
116
117
}
ProtoDUNEBSMWindow.hpp
triggeralgs::ProtoDUNEBSMWindow
Definition
ProtoDUNEBSMWindow.hpp:20
triggeralgs::ProtoDUNEBSMWindow::adc_peak_sum
uint64_t adc_peak_sum
Definition
ProtoDUNEBSMWindow.hpp:45
triggeralgs::ProtoDUNEBSMWindow::time_start
timestamp_t time_start
Definition
ProtoDUNEBSMWindow.hpp:43
triggeralgs::ProtoDUNEBSMWindow::tp_list
std::vector< TriggerPrimitive > tp_list
Definition
ProtoDUNEBSMWindow.hpp:47
triggeralgs::ProtoDUNEBSMWindow::mean_tot
float mean_tot()
Definition
ProtoDUNEBSMWindow.cpp:104
triggeralgs::ProtoDUNEBSMWindow::mean_sadc
float mean_sadc()
Definition
ProtoDUNEBSMWindow.cpp:98
triggeralgs::ProtoDUNEBSMWindow::clear
void clear()
Definition
ProtoDUNEBSMWindow.cpp:23
triggeralgs::ProtoDUNEBSMWindow::add
void add(TriggerPrimitive const &input_tp)
Definition
ProtoDUNEBSMWindow.cpp:13
triggeralgs::ProtoDUNEBSMWindow::reset
void reset(TriggerPrimitive const &input_tp)
Definition
ProtoDUNEBSMWindow.cpp:53
triggeralgs::ProtoDUNEBSMWindow::is_empty
bool is_empty() const
Definition
ProtoDUNEBSMWindow.cpp:9
triggeralgs::ProtoDUNEBSMWindow::adc_integral
uint32_t adc_integral
Definition
ProtoDUNEBSMWindow.hpp:44
triggeralgs::ProtoDUNEBSMWindow::move
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
Definition
ProtoDUNEBSMWindow.cpp:27
triggeralgs::ProtoDUNEBSMWindow::mean_adc_peak
float mean_adc_peak()
Definition
ProtoDUNEBSMWindow.cpp:101
triggeralgs::ProtoDUNEBSMWindow::tot_sum
uint64_t tot_sum
Definition
ProtoDUNEBSMWindow.hpp:46
triggeralgs::ProtoDUNEBSMWindow::fill_entry_window
void fill_entry_window(std::vector< Entry > &entry_input, std::vector< float > &input)
Definition
ProtoDUNEBSMWindow.cpp:92
triggeralgs::ProtoDUNEBSMWindow::bin_window
void bin_window(std::vector< float > &input, timestamp_t time_bin_width, channel_t chan_bin_width, int num_time_bins, int num_chan_bins, channel_t first_channel, std::unique_ptr< PDVDEffectiveChannelMap > const &effective_channel_mapper, bool use_pdvd_map)
Definition
ProtoDUNEBSMWindow.cpp:65
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::timestamp_t
dunedaq::trgdataformats::timestamp_t timestamp_t
Definition
Types.hpp:16
triggeralgs::TriggerPrimitive
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
Definition
TriggerPrimitive.hpp:22
triggeralgs::operator<<
std::ostream & operator<<(std::ostream &os, const ProtoDUNEBSMWindow &window)
Definition
ProtoDUNEBSMWindow.cpp:108
triggeralgs::channel_t
dunedaq::trgdataformats::channel_t channel_t
Definition
Types.hpp:20
dunedaq::trgdataformats::TriggerPrimitive::samples_over_threshold
uint64_t samples_over_threshold
Definition
TriggerPrimitive.hpp:38
dunedaq::trgdataformats::TriggerPrimitive::adc_peak
uint64_t adc_peak
Definition
TriggerPrimitive.hpp:43
dunedaq::trgdataformats::TriggerPrimitive::time_start
uint64_t time_start
Definition
TriggerPrimitive.hpp:39
dunedaq::trgdataformats::TriggerPrimitive::adc_integral
uint64_t adc_integral
Definition
TriggerPrimitive.hpp:42
Generated on
for DUNE-DAQ by
1.17.0