DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEFrameProcessor.hpp
Go to the documentation of this file.
1
8#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNE_DAPHNEFRAMEPROCESSOR_HPP_
9#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNE_DAPHNEFRAMEPROCESSOR_HPP_
10
11#include "logging/Logging.hpp"
12
16
18#include "iomanager/Sender.hpp"
19
23
27
30
31
33
34
37
38#include <atomic>
39#include <functional>
40#include <memory>
41#include <string>
42
44
45namespace dunedaq {
46
47ERS_DECLARE_ISSUE(fdreadoutlibs,
48 PDSPeakIgnored,
49 "Ignoring PDS Peak with ts=" << timestamp << ", ch=" << channel << ", sc_iframe=" << superchunk_iframe << ", ipeak=" << ipeak,
50 ((uint64_t)timestamp) ((uint64_t)channel) ((size_t)superchunk_iframe) ((size_t)ipeak))
51
52ERS_DECLARE_ISSUE(fdreadoutlibs,
54 "PDS Frame with unphysical timestamp detected with ts=" << timestamp << ", ch=" << channel << ", sc_iframe=" << superchunk_iframe,
55 ((uint64_t)timestamp) ((uint64_t)channel) ((size_t)superchunk_iframe))
56
57
58namespace fdreadoutlibs {
59
60class DAPHNEFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel<types::DAPHNESuperChunkTypeAdapter>
61{
62
63public:
65 using frameptr = types::DAPHNESuperChunkTypeAdapter*;
66 using daphneframeptr = dunedaq::fddetdataformats::DAPHNEFrame*;
67 using timestamp_t = std::uint64_t; // NOLINT(build/unsigned)
68 using constframeptr = const types::DAPHNESuperChunkTypeAdapter*;
69
70 // Constructor
71 explicit DAPHNEFrameProcessor(std::unique_ptr<datahandlinglibs::FrameErrorRegistry>& error_registry, bool post_processing_enabled)
73 {}
74
75
76
77 // Override config for pipeline setup
78 void conf(const appmodel::DataHandlerModule* conf) override;
79
80 void start(const nlohmann::json& args) override;
81 void stop(const nlohmann::json& args) override;
82
83protected:
84 virtual void generate_opmon_data() override;
85
89 void timestamp_check(frameptr /*fp*/);
90
94 void frame_error_check(frameptr /*fp*/);
95
96 // Internals
97 timestamp_t m_previous_ts = 0;
98 timestamp_t m_current_ts = 0;
99 bool m_first_ts_fake = true;
100 bool m_first_ts_missmatch = true;
101 bool m_problem_reported = false;
102 std::atomic<int> m_ts_error_ctr{ 0 };
103
104 void extract_tps( constframeptr fp);
106
107private:
108
109 //PDSChannelMap
110 std::shared_ptr<detchannelmaps::PDSChannelMap> m_channel_map;
111 std::vector<std::pair<trgdataformats::channel_t, int16_t>> m_channel_plane_numbers;
112
113 uint32_t m_det_id; // NOLINT(build/unsigned)
114 uint32_t m_crate_id; // NOLINT(build/unsigned)
115 uint32_t m_slot_id; // NOLINT(build/unsigned)
116 uint32_t m_stream_id; // NOLINT(build/unsigned)
117
118 std::set<unsigned int> m_channel_mask_set;
119 uint32_t m_def_adc_intg_thresh = 0;
120
121
122
123 std::shared_ptr<iomanager::SenderConcept<std::vector<trigger::TriggerPrimitiveTypeAdapter>>> m_tp_sink;
124
125 std::atomic<uint64_t> m_new_hits{ 0 }; // NOLINT(build/unsigned)
126 std::atomic<uint64_t> m_new_tps{ 0 }; // NOLINT(build/unsigned)
127 std::atomic<uint64_t> m_tps_suppressed_too_long{ 0 };
128 std::atomic<uint64_t> m_tps_send_failed{ 0 };
129 std::atomic<uint64_t> m_frame_counter{ 0 };
130
131 std::chrono::time_point<std::chrono::high_resolution_clock> m_t0;
132
133
134};
135
136} // namespace fdreadoutlibs
137} // namespace dunedaq
138
139#endif // FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNE_DAPHNEFRAMEPROCESSOR_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
The DUNE-DAQ namespace.
Definition DataStore.hpp:57
A single energy deposition on a TPC or PDS channel.