DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
src
TAMakerBundleNAlgorithm.cpp
Go to the documentation of this file.
1
8
9
#include "
triggeralgs/BundleN/TAMakerBundleNAlgorithm.hpp
"
10
11
#include "TRACE/trace.h"
12
#define TRACE_NAME "TAMakerBundleNAlgorithm"
13
14
namespace
triggeralgs
{
15
16
using
Logging::TLVL_IMPORTANT
;
17
using
Logging::TLVL_DEBUG_HIGH
;
18
19
void
TAMakerBundleNAlgorithm::set_ta_attributes
() {
20
// Using the first TA as reference.
21
TriggerPrimitive
first_tp =
m_current_ta
.inputs.front();
22
TriggerPrimitive
last_tp =
m_current_ta
.inputs.back();
23
24
m_current_ta
.channel_start = first_tp.
channel
;
25
m_current_ta
.channel_end = last_tp.
channel
;
26
27
m_current_ta
.time_start = first_tp.
time_start
;
28
m_current_ta
.time_end = last_tp.
time_start
;
29
30
m_current_ta
.detid = first_tp.
detid
;
31
32
m_current_ta
.algorithm =
TriggerActivity::Algorithm::kBundle
;
33
m_current_ta
.type =
TriggerActivity::Type::kTPC
;
34
35
m_current_ta
.adc_peak = 0;
36
for
(
const
TriggerPrimitive
& tp :
m_current_ta
.inputs) {
37
m_current_ta
.adc_integral += tp.
adc_integral
;
38
if
(tp.
adc_peak
<=
m_current_ta
.adc_peak)
continue
;
39
m_current_ta
.adc_peak = tp.
adc_peak
;
40
m_current_ta
.channel_peak = tp.
channel
;
41
m_current_ta
.time_peak = tp.
samples_to_peak
* 32 + tp.
time_start
;
// FIXME: Replace STP to `time_peak` conversion.
42
}
43
m_current_ta
.time_activity =
m_current_ta
.time_peak;
44
return
;
45
}
46
47
bool
TAMakerBundleNAlgorithm::bundle_condition
() {
48
return
m_current_ta
.inputs.size() ==
m_bundle_size
;
49
}
50
51
void
52
TAMakerBundleNAlgorithm::process
(
const
TriggerPrimitive
& input_tp, std::vector<TriggerActivity>& output_tas)
53
{
54
// Expect that TPs are inherently time ordered.
55
m_current_ta
.inputs.push_back(input_tp);
56
57
if
(
bundle_condition
()) {
58
TLOG_DEBUG
(
TLVL_DEBUG_HIGH
) <<
"[TA:BN] Emitting BundleN TA with "
<<
m_current_ta
.inputs.size() <<
" TPs."
;
59
set_ta_attributes
();
60
output_tas.push_back(
m_current_ta
);
61
62
// Reset the current.
63
m_current_ta
=
TriggerActivity
();
64
}
65
66
// Should never reach this step. In this case, send it out.
67
if
(
m_current_ta
.inputs.size() >
m_bundle_size
) {
68
TLOG_DEBUG
(
TLVL_IMPORTANT
) <<
"[TA:BN] Emitting large BundleN TriggerActivity with "
<<
m_current_ta
.inputs.size() <<
" TPs."
;
69
set_ta_attributes
();
70
output_tas.push_back(
m_current_ta
);
71
72
// Reset the current.
73
m_current_ta
=
TriggerActivity
();
74
}
75
}
76
77
void
78
TAMakerBundleNAlgorithm::configure
(
const
nlohmann::json& config)
79
{
80
if
(config.is_object() && config.contains(
"bundle_size"
)) {
81
m_bundle_size
= config[
"bundle_size"
];
82
}
83
}
84
85
REGISTER_TRIGGER_ACTIVITY_MAKER
(
TRACE_NAME
,
TAMakerBundleNAlgorithm
)
86
}
// namespace triggeralgs
87
REGISTER_TRIGGER_ACTIVITY_MAKER
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
Definition
TriggerActivityFactory.hpp:14
TriggerActivity
TriggerActivity
Definition
TriggerActivity_serialization.hpp:37
triggeralgs::TAMakerBundleNAlgorithm
Definition
TAMakerBundleNAlgorithm.hpp:19
triggeralgs::TAMakerBundleNAlgorithm::m_current_ta
TriggerActivity m_current_ta
Definition
TAMakerBundleNAlgorithm.hpp:27
triggeralgs::TAMakerBundleNAlgorithm::m_bundle_size
uint64_t m_bundle_size
Definition
TAMakerBundleNAlgorithm.hpp:26
triggeralgs::TAMakerBundleNAlgorithm::set_ta_attributes
void set_ta_attributes()
Definition
TAMakerBundleNAlgorithm.cpp:19
triggeralgs::TAMakerBundleNAlgorithm::bundle_condition
bool bundle_condition()
Definition
TAMakerBundleNAlgorithm.cpp:47
triggeralgs::TAMakerBundleNAlgorithm::process
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_tas)
TP processing function that creates & fills TAs.
Definition
TAMakerBundleNAlgorithm.cpp:52
triggeralgs::TAMakerBundleNAlgorithm::configure
void configure(const nlohmann::json &config)
Definition
TAMakerBundleNAlgorithm.cpp:78
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::TLVL_IMPORTANT
@ TLVL_IMPORTANT
Definition
Logging.hpp:19
triggeralgs::TLVL_DEBUG_HIGH
@ TLVL_DEBUG_HIGH
Definition
Logging.hpp:24
triggeralgs::TriggerPrimitive
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
Definition
TriggerPrimitive.hpp:22
TRACE_NAME
#define TRACE_NAME
Definition
TimingHardwareManagerBase.cpp:30
TAMakerBundleNAlgorithm.hpp
dunedaq::trgdataformats::TriggerActivityData::Type::kTPC
@ kTPC
Definition
TriggerActivityData.hpp:22
dunedaq::trgdataformats::TriggerActivityData::Algorithm::kBundle
@ kBundle
Definition
TriggerActivityData.hpp:37
dunedaq::trgdataformats::TriggerPrimitive::detid
uint64_t detid
Definition
TriggerPrimitive.hpp:33
dunedaq::trgdataformats::TriggerPrimitive::channel
uint64_t channel
Definition
TriggerPrimitive.hpp:36
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::samples_to_peak
uint64_t samples_to_peak
Definition
TriggerPrimitive.hpp:40
dunedaq::trgdataformats::TriggerPrimitive::adc_integral
uint64_t adc_integral
Definition
TriggerPrimitive.hpp:42
Generated on
for DUNE-DAQ by
1.16.1