DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPRequestHandler.cpp
Go to the documentation of this file.
4
5#include "rcif/cmd/Nljs.hpp"
6
7namespace dunedaq {
8namespace trigger {
9
10void
12
13 for (auto output : conf->get_outputs()) {
14 if (output->get_data_type() == "TPSet") {
15 try {
17 } catch (const ers::Issue& excpt) {
18 throw datahandlinglibs::ResourceQueueError(ERS_HERE, "tp queue", "DefaultRequestHandlerModel", excpt);
19 }
20 }
21 }
23}
24
25void
26TPRequestHandler::scrap(const appfwk::DAQModule::CommandData_t& args)
27{
28 m_tpset_sink.reset();
30}
31
32void
33TPRequestHandler::start(const appfwk::DAQModule::CommandData_t& args)
34{
35
40 m_first_cycle = true;
41
43 rcif::cmd::StartParams start_params = args.get<rcif::cmd::StartParams>();
44 m_run_number = start_params.run;
45
46}
47
48void
50
51 if (m_tpset_sink == nullptr) return;
52
54
55 {
56 std::unique_lock<std::mutex> lock(m_cv_mutex);
57 m_cv.wait(lock, [&] { return !m_cleanup_requested; });
59 }
60 m_cv.notify_all();
61 if(m_latency_buffer->occupancy() != 0) {
62 // Prepare response
63 RequestResult rres(ResultCode::kUnknown, dr);
64 std::vector<std::pair<void*, size_t>> frag_pieces;
65
66 // Get the newest TP
67 SkipListAcc acc(inherited2::m_latency_buffer->get_skip_list());
68 auto tail = acc.last();
69 auto head = acc.first();
70 m_newest_ts = (*tail).get_timestamp();
71 m_oldest_ts = (*head).get_timestamp();
72
73 if (m_first_cycle) {
75 m_first_cycle = false;
76 }
80 auto num_tps = frag_pieces.size();
81 trigger::TPSet tpset;
84 tpset.origin = m_sourceid;
85 tpset.start_time = m_start_win_ts; // provisory timestamp, will be filled with first TP
86 tpset.end_time = m_end_win_ts; // provisory timestamp, will be filled with last TP
87 tpset.seqno = m_next_tpset_seqno++; // NOLINT(runtime/increment_decrement)
88 // reserve the space for efficiency
89 if (num_tps > 0) {
90 tpset.objects.reserve(frag_pieces.size());
91 bool first_tp = true;
92 for( auto f : frag_pieces) {
94
95 if(first_tp) {
96 tpset.start_time = tp.time_start;
97 first_tp = false;
98 }
99 tpset.end_time = tp.time_start;
100 tpset.objects.emplace_back(std::move(tp));
101 }
102 }
103 if(!m_tpset_sink->try_send(std::move(tpset), iomanager::Sender::s_no_block)) {
106 }
108
109 //remember what we sent for the next loop
111 }
112 }
113 {
114 std::lock_guard<std::mutex> lock(m_cv_mutex);
116 }
117 m_cv.notify_all();
118 return;
119}
120
121} // namespace fdreadoutlibs
122} // namespace dunedaq
#define ERS_HERE
typename folly::ConcurrentSkipList< TriggerPrimitiveTypeAdapter >::Accessor SkipListAcc
static std::shared_ptr< IOManager > get()
Definition IOManager.hpp:40
static constexpr timeout_t s_no_block
Definition Sender.hpp:26
A set of TPs or TAs in a given time window, defined by its start and end times.
Definition Set.hpp:26
std::vector< T > objects
Definition Set.hpp:61
daqdataformats::run_number_t run_number
Definition Set.hpp:45
timestamp_t start_time
Definition Set.hpp:55
origin_t origin
Definition Set.hpp:48
timestamp_t end_time
Definition Set.hpp:58
void scrap(const appfwk::DAQModule::CommandData_t &args) override
std::shared_ptr< iomanager::SenderConcept< dunedaq::trigger::TPSet > > m_tpset_sink
void conf(const appmodel::DataHandlerModule *conf) override
void periodic_data_transmission() override
Periodic data transmission - relevant for trigger in particular.
void start(const appfwk::DAQModule::CommandData_t &args) override
Base class for any user define issue.
Definition Issue.hpp:69
The DUNE-DAQ namespace.
void warning(const Issue &issue)
Definition ers.hpp:115
This message represents a request for data sent to a single component of the DAQ.
A single energy deposition on a TPC or PDS channel.