DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
src
TAWindow.cpp
Go to the documentation of this file.
1
#include "
triggeralgs/TAWindow.hpp
"
2
3
#include <vector>
4
5
#include <chrono>
6
#include <map>
7
#include <memory>
8
#include <string>
9
#include <unordered_set>
10
#include <utility>
11
12
namespace
triggeralgs
{
13
14
//---
15
void
16
TAWindow::add
(
const
TriggerActivity
& input_ta)
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
}
32
33
//---
34
void
35
TAWindow::clear
()
36
{
37
inputs
.clear();
38
channel_states
.clear();
39
time_start
= 0;
40
adc_integral
= 0;
41
};
42
43
//---
44
void
45
TAWindow::move
(
TriggerActivity
const
& input_ta,
timestamp_t
const
& window_length)
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
}
76
77
//---
78
void
79
TAWindow::reset
(
TriggerActivity
const
& input_ta)
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
}
96
97
std::ostream&
98
operator<<
(std::ostream& os,
const
TAWindow
& window)
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
};
109
110
//---
111
//---
112
//---
113
//---
114
//---
115
//---
116
117
}
// namespace triggeralgs
TAWindow.hpp
triggeralgs::TAWindow
Definition
TAWindow.hpp:20
triggeralgs::TAWindow::adc_integral
uint64_t adc_integral
Definition
TAWindow.hpp:53
triggeralgs::TAWindow::time_start
timestamp_t time_start
Definition
TAWindow.hpp:52
triggeralgs::TAWindow::clear
void clear()
Clear all inputs.
Definition
TAWindow.cpp:35
triggeralgs::TAWindow::add
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
triggeralgs::TAWindow::inputs
std::vector< TriggerActivity > inputs
Definition
TAWindow.hpp:55
triggeralgs::TAWindow::channel_states
std::unordered_map< channel_t, uint16_t > channel_states
Definition
TAWindow.hpp:54
triggeralgs::TAWindow::is_empty
bool is_empty() const
Definition
TAWindow.hpp:22
triggeralgs::TAWindow::reset
void reset(TriggerActivity const &input_ta)
Reset window content on the input.
Definition
TAWindow.cpp:79
triggeralgs::TAWindow::move
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...
Definition
TAWindow.cpp:45
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
dunedaq::trgdataformats::TriggerActivityData::adc_integral
uint64_t adc_integral
Definition
TriggerActivityData.hpp:53
dunedaq::trgdataformats::TriggerActivityData::time_start
timestamp_t time_start
Definition
TriggerActivityData.hpp:46
dunedaq::trgdataformats::TriggerPrimitive::channel
uint64_t channel
Definition
TriggerPrimitive.hpp:36
triggeralgs::TriggerActivity
Definition
TriggerActivity.hpp:20
triggeralgs::TriggerActivity::inputs
std::vector< TriggerPrimitive > inputs
Definition
TriggerActivity.hpp:33
Generated on
for DUNE-DAQ by
1.17.0