28namespace fdreadoutlibs {
33 TLOG() <<
"Looking for TP sink...";
36 TLOG() <<
"On outputs... (" << output->UID() <<
"," << output->get_data_type() <<
")";
38 if (output->get_data_type() ==
"TriggerPrimitiveVector") {
39 TLOG() <<
"Found TP sink.";
40 m_tp_sink = get_iom_sender<std::vector<trigger::TriggerPrimitiveTypeAdapter>>(output->UID());
41 TLOG() <<
" SINK INITIALIZED for TriggerPrimitives with UID : " << output->UID();
44 ers::error(datahandlinglibs::ResourceQueueError(
ERS_HERE,
"tp",
"DefaultRequestHandlerModel", excpt));
48 TLOG() <<
"Registering processing tasks...";
49 inherited::add_preprocess_task(std::bind(&DAPHNEFrameProcessor::timestamp_check,
this, std::placeholders::_1));
53 TLOG()<<
" PDS Data processor does not exist.";
56 if (proc_conf ==
nullptr) {
57 TLOG()<<
"PDS RawDataProcessor does not exist.";
59 m_def_adc_intg_thresh = proc_conf-> get_default_adc_intg_thresh();
62 if (geo_id !=
nullptr) {
63 m_det_id = geo_id->get_detector_id();
64 m_crate_id = geo_id->get_crate_id();
65 m_slot_id = geo_id->get_slot_id();
66 m_stream_id = geo_id->get_stream_id();
69 m_channel_map = dunedaq::detchannelmaps::make_pds_map(proc_conf->get_channel_map());
70 const std::vector<unsigned int> channel_mask_vec = proc_conf->get_channel_mask();
72 for (
int chan = 0; chan < 48; chan++) {
73 trgdataformats::channel_t off_channel = m_channel_map->get_offline_channel_from_det_crate_slot_stream_chan(m_det_id, m_crate_id, m_slot_id, m_stream_id, chan);
74 if (std::find(channel_mask_vec.begin(), channel_mask_vec.end(), off_channel) != channel_mask_vec.end())
75 m_channel_mask_set.insert(off_channel);
78 if (m_post_processing_enabled) {
80 inherited::add_preprocess_task(std::bind(&DAPHNEFrameProcessor::extract_tps,
this, std::placeholders::_1));
85 TLOG() <<
"Calling parent conf.";
86 inherited::conf(conf);
89void DAPHNEFrameProcessor::start(
const appfwk::DAQModule::CommandData_t& args)
94 m_first_ts_missmatch =
true;
98 m_t0 = std::chrono::high_resolution_clock::now();
99 m_num_new_tps.exchange(0);
101 inherited::start(args);
104DAPHNEFrameProcessor::stop(
const appfwk::DAQModule::CommandData_t& args)
106 inherited::stop(args);
132 for (
size_t i=0; i<types::kDAPHNENumFrames; i++){
135 if(df_ptr[i].get_timestamp() > 0xFFFFFFFFFFFF0000 || df_ptr[i].get_timestamp() < 0xFFFF){
136 ers::warning(PDSUnphysicalFrameTimestamp(
ERS_HERE, df_ptr[i].get_timestamp(), df_ptr[i].get_channel(), i));
138 df_ptr[i].daq_header.timestamp_1 = df_ptr[i].daq_header.timestamp_2 = 0;
144 uint64_t k_clock_frequency = 62500000;
145 TLOG_DEBUG(TLVL_FRAME_RECEIVED) <<
"Received DAPHNE frame timestamp value of " << m_current_ts <<
" ticks (..." << std::fixed << std::setprecision(8) << (static_cast<double>(m_current_ts % (k_clock_frequency*1000)) /
static_cast<double>(k_clock_frequency)) <<
" sec)";
148 if (m_ts_error_ctr > 1000) {
149 if (!m_problem_reported) {
150 std::cout <<
"*** Data Integrity ERROR *** Timestamp continuity is completely broken! "
151 <<
"Something is wrong with the FE source or with the configuration!\n";
152 m_problem_reported =
true;
156 m_previous_ts = m_current_ts;
157 m_last_processed_daq_ts = m_current_ts;
173 if (!fp || fp==
nullptr){
178 auto nonconstframeptr =
const_cast<frameptr>(fp);
180 std::vector<trigger::TriggerPrimitiveTypeAdapter> ttpp;
182 for (
size_t i=0; i<types::kDAPHNENumFrames; i++)
184 for(
size_t j=0; j<fddetdataformats::DAPHNEFrame::PeakDescriptorData::max_peaks;j++)
186 if(df_ptr[i].peaks_data.is_found(j))
188 int ch = m_channel_map->get_offline_channel_from_det_crate_slot_stream_chan(df_ptr[i].daq_header.det_id, df_ptr[i].daq_header.crate_id, df_ptr[i].daq_header.slot_id, df_ptr[i].daq_header.link_id, df_ptr[i].get_channel());
189 if (std::binary_search(m_channel_mask_set.begin(), m_channel_mask_set.end(), ch))
continue;
190 if (df_ptr[i].peaks_data.get_adc_integral(j) < m_def_adc_intg_thresh)
continue;
194 tpa.
tp = peak_to_tp(df_ptr[i],j);
201 tpa.
tp.
detid = df_ptr->daq_header.det_id;
207 int num_new_tps = ttpp.size();
208 if (num_new_tps > 0) {
210 const auto s_ts_begin = ttpp.front().tp.time_start;
211 const auto channel_begin = ttpp.front().tp.channel;
212 const auto s_ts_end = ttpp.back().tp.time_start;
215 if (!m_tp_sink->try_send(std::move(ttpp), iomanager::Sender::s_no_block)) {
217 m_tps_send_failed += num_new_tps;
219 m_num_new_tps += num_new_tps;
245DAPHNEFrameProcessor::generate_opmon_data() {
248 if (m_post_processing_enabled) {
249 auto now = std::chrono::high_resolution_clock::now();
250 int num_new_tps = m_num_new_tps.exchange(0);
251 int new_tps_suppressed_too_long = 0;
252 int new_tps_send_failed = m_tps_send_failed.exchange(0);
253 double seconds = std::chrono::duration_cast<std::chrono::microseconds>(
now - m_t0).count() / 1000000.;
254 TLOG_DEBUG(TLVL_BOOKKEEPING) <<
"TP rate: " << std::to_string(num_new_tps / seconds / 1000.) <<
" [kHz]";
255 TLOG_DEBUG(TLVL_BOOKKEEPING) <<
"Total new TPs: " << num_new_tps;
264 publish(std::move(tp_info));
270 inherited::generate_opmon_data();
#define DUNE_DAQ_TYPESTRING(Type, typestring)
Declare the datatype_to_string method for the given type.
const dunedaq::appmodel::DataProcessor * get_data_processor() const
Get "data_processor" relationship value.
const dunedaq::appmodel::DataHandlerConf * get_module_configuration() const
Get "module_configuration" relationship value.
const dunedaq::confmodel::GeoId * get_geo_id() const
Get "geo_id" relationship value.
const std::vector< const dunedaq::confmodel::Connection * > & get_outputs() const
Get "outputs" relationship value. Output connections from this module.
void set_num_tps_send_failed(::uint64_t value)
void set_num_tps_suppressed_too_long(::uint64_t value)
void set_num_tps_sent(::uint64_t value)
void set_rate_tp_hits(float value)
Base class for any user define issue.
#define TLOG_DEBUG(lvl,...)
Both frame_count_limit and tp_count_limit were set FailedToSendTPVector
void warning(const Issue &issue)
void error(const Issue &issue)
uint64_t get_timestamp() const
trgdataformats::TriggerPrimitive tp