Skip to content

Commit

Permalink
Merge pull request #362 from DUNE-DAQ/dte/datahandlingmodel_with_idt_…
Browse files Browse the repository at this point in the history
…tpa_vector

DataHandlingModel with IDT
  • Loading branch information
denizergonul authored Nov 21, 2024
2 parents aefe766 + 5cf1e33 commit 3cbbc8e
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 218 deletions.
46 changes: 46 additions & 0 deletions include/trigger/TriggerDataHandlingModel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @file TriggerDataHandlingModel.hpp Glue between data source, payload raw processor,
* latency buffer and request handler.
*
* This is part of the DUNE DAQ, copyright 2024.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/
#ifndef TRIGGER_INCLUDE_TRIGGER_TRIGGERDATAHANDLINGMODEL_HPP_
#define TRIGGER_INCLUDE_TRIGGER_TRIGGERDATAHANDLINGMODEL_HPP_

#include "datahandlinglibs/models/DataHandlingModel.hpp"
#include <vector>

namespace dunedaq::trigger {

template<class ReadoutType,
class RequestHandlerType,
class LatencyBufferType,
class RawDataProcessorType,
class InputDataType = ReadoutType>
class TriggerDataHandlingModel
: public datahandlinglibs::
DataHandlingModel<ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType>
{
public:
using Base = datahandlinglibs::
DataHandlingModel<ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType>;
using RDT = typename Base::RDT;
using RHT = typename Base::RHT;
using LBT = typename Base::LBT;
using RPT = typename Base::RPT;
using IDT = typename Base::IDT;

explicit TriggerDataHandlingModel(std::atomic<bool>& run_marker);

// Transform input data type to readout
std::vector<ReadoutType> transform_payload(IDT& original) const override;
};

} // namespace dunedaq::trigger

// Declarations
#include "detail/TriggerDataHandlingModel.hxx"

#endif // TRIGGER_INCLUDE_TRIGGER_TRIGGERDATAHANDLINGMODEL_HPP_
41 changes: 41 additions & 0 deletions include/trigger/detail/TriggerDataHandlingModel.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file TriggerDataHandlingModel.hxx Glue between data source, payload raw processor,
* latency buffer and request handler.
*
* This is part of the DUNE DAQ, copyright 2024.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/
#include "triggeralgs/TriggerActivity.hpp"
#include "triggeralgs/TriggerCandidate.hpp"

namespace dunedaq::trigger {

template<class RDT, class RHT, class LBT, class RPT, class IDT>
TriggerDataHandlingModel<RDT, RHT, LBT, RPT, IDT>::TriggerDataHandlingModel(std::atomic<bool>& run_marker)
: Base(run_marker)
{
}

template<class RDT, class RHT, class LBT, class RPT, class IDT>
std::vector<RDT>
TriggerDataHandlingModel<RDT, RHT, LBT, RPT, IDT>::transform_payload(IDT& original) const
{
if constexpr (std::is_same_v<IDT, trigger::TPSet>) {
std::vector<RDT> transformed(original.objects.size());
for (std::size_t i = 0; i < transformed.size(); ++i) {
transformed[i].tp = std::move(original.objects[i]);
}
return transformed;
} else if constexpr (std::is_same_v<IDT, std::vector<TriggerPrimitiveTypeAdapter>>) {
return std::move(original);
} else if constexpr (std::is_same_v<IDT, triggeralgs::TriggerActivity> ||
std::is_same_v<IDT, triggeralgs::TriggerCandidate>) {
return { RDT(std::move(original)) };

} else {
return Base::transform_payload(original);
}
}

} // namespace dunedaq::trigger
10 changes: 5 additions & 5 deletions plugins/DataSubscriberModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
#include "datahandlinglibs/DataHandlingIssues.hpp"
#include "datahandlinglibs/models/DataSubscriberModel.hpp"
#include "trigger/HSISourceModel.hpp"
#include "trigger/TPSetSourceModel.hpp"
#include "trigger/TriggerSourceModel.hpp"

#include "appmodel/DataSubscriberModule.hpp"

#include "trigger/TriggerPrimitiveTypeAdapter.hpp"
#include "trigger/TAWrapper.hpp"
#include "trigger/TCWrapper.hpp"
#include "trigger/TPSet.hpp"
#include "trgdataformats/TriggerPrimitive.hpp"
#include "triggeralgs/TriggerActivity.hpp"
#include "triggeralgs/TriggerCandidate.hpp"
Expand All @@ -31,6 +30,7 @@ namespace dunedaq {

//DUNE_DAQ_TYPESTRING(dunedaq::trigger::TPSet, "TPSet")
DUNE_DAQ_TYPESTRING(dunedaq::trigger::TriggerPrimitiveTypeAdapter, "TriggerPrimitive")
DUNE_DAQ_TYPESTRING(std::vector<dunedaq::trigger::TriggerPrimitiveTypeAdapter>, "TriggerPrimitiveVector")
DUNE_DAQ_TYPESTRING(dunedaq::trigger::TAWrapper, "TriggerActivity")
DUNE_DAQ_TYPESTRING(dunedaq::trigger::TCWrapper, "TriggerCandidate")

Expand Down Expand Up @@ -81,21 +81,21 @@ DataSubscriberModule::create_data_subscriber(const confmodel::DaqModule* cfg)
if (raw_dt == "TPSet") {
TLOG_DEBUG(1) << "Creating trigger primitives subscriber";
auto source_model =
std::make_shared<trigger::TPSetSourceModel>();
std::make_shared<datahandlinglibs::DataSubscriberModel<std::vector<TriggerPrimitiveTypeAdapter>>>();
return source_model;
}

if (raw_dt == "TriggerActivity") {
TLOG_DEBUG(1) << "Creating trigger activities subscriber";
auto source_model =
std::make_shared<trigger::TriggerSourceModel<triggeralgs::TriggerActivity, trigger::TAWrapper>>();
std::make_shared<datahandlinglibs::DataSubscriberModel<triggeralgs::TriggerActivity>>();
return source_model;
}

if (raw_dt == "TriggerCandidate") {
TLOG_DEBUG(1) << "Creating trigger candidates subscriber";
auto source_model =
std::make_shared<trigger::TriggerSourceModel<triggeralgs::TriggerCandidate, trigger::TCWrapper>>();
std::make_shared<datahandlinglibs::DataSubscriberModel<triggeralgs::TriggerCandidate>>();
return source_model;
}

Expand Down
28 changes: 23 additions & 5 deletions plugins/TriggerDataHandlerModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "datahandlinglibs/models/DefaultSkipListRequestHandler.hpp"
#include "trigger/TPRequestHandler.hpp"

#include "trigger/TriggerDataHandlingModel.hpp"
#include "trigger/TriggerPrimitiveTypeAdapter.hpp"
#include "trigger/TPProcessor.hpp"
#include "trigger/TAProcessor.hpp"
Expand All @@ -33,6 +34,7 @@ using namespace dunedaq::datahandlinglibs::logging;
namespace dunedaq {

DUNE_DAQ_TYPESTRING(dunedaq::trigger::TriggerPrimitiveTypeAdapter, "TriggerPrimitive")
DUNE_DAQ_TYPESTRING(std::vector<dunedaq::trigger::TriggerPrimitiveTypeAdapter>, "TriggerPrimitiveVector")
DUNE_DAQ_TYPESTRING(dunedaq::trigger::TAWrapper, "TriggerActivity")
DUNE_DAQ_TYPESTRING(dunedaq::trigger::TCWrapper, "TriggerCandidate")

Expand Down Expand Up @@ -69,10 +71,24 @@ TriggerDataHandlerModule::create_readout(const appmodel::DataHandlerModule* modc
std::string raw_dt = modconf->get_module_configuration()->get_input_data_type();
TLOG() << "Choosing specializations for DataHandlingModel with data_type:" << raw_dt << ']';

// IF TriggerPrimitiveVector (TP vector)
if (raw_dt.find("TriggerPrimitiveVector") != std::string::npos) {
TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerPrimitiveVector";
auto readout_model = std::make_shared<TriggerDataHandlingModel<
TriggerPrimitiveTypeAdapter,
TPRequestHandler,
rol::SkipListLatencyBufferModel<TriggerPrimitiveTypeAdapter>,
TPProcessor,
std::vector<TriggerPrimitiveTypeAdapter>>>(run_marker);
register_node("TPProcessor", readout_model);
readout_model->init(modconf);
return readout_model;
}

// IF TriggerPrimitive (TP)
if (raw_dt.find("TriggerPrimitive") != std::string::npos) {
TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerPrimitive";
auto readout_model = std::make_shared<rol::DataHandlingModel<
auto readout_model = std::make_shared<TriggerDataHandlingModel<
TriggerPrimitiveTypeAdapter,
TPRequestHandler,
rol::SkipListLatencyBufferModel<TriggerPrimitiveTypeAdapter>,
Expand All @@ -85,11 +101,12 @@ TriggerDataHandlerModule::create_readout(const appmodel::DataHandlerModule* modc
// IF TriggerActivity (TA)
if (raw_dt.find("TriggerActivity") != std::string::npos) {
TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerActivity";
auto readout_model = std::make_shared<rol::DataHandlingModel<
auto readout_model = std::make_shared<TriggerDataHandlingModel<
TAWrapper,
rol::DefaultSkipListRequestHandler<trigger::TAWrapper>,
rol::SkipListLatencyBufferModel<trigger::TAWrapper>,
TAProcessor>>(run_marker);
TAProcessor,
triggeralgs::TriggerActivity>>(run_marker);
register_node("TAProcessor", readout_model);

readout_model->init(modconf);
Expand All @@ -99,11 +116,12 @@ TriggerDataHandlerModule::create_readout(const appmodel::DataHandlerModule* modc
// No processing, only buffering to respond to data requests
if (raw_dt.find("TriggerCandidate") != std::string::npos) {
TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerCandidate";
auto readout_model = std::make_shared<rol::DataHandlingModel<
auto readout_model = std::make_shared<TriggerDataHandlingModel<
TCWrapper,
rol::DefaultSkipListRequestHandler<trigger::TCWrapper>,
rol::SkipListLatencyBufferModel<trigger::TCWrapper>,
TCProcessor>>(run_marker);
TCProcessor,
triggeralgs::TriggerCandidate>>(run_marker);
register_node("TCProcessor", readout_model);

readout_model->init(modconf);
Expand Down
1 change: 1 addition & 0 deletions src/TPProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using dunedaq::datahandlinglibs::logging::TLVL_TAKE_NOTE;

// THIS SHOULDN'T BE HERE!!!!! But it is necessary.....
DUNE_DAQ_TYPESTRING(dunedaq::trigger::TriggerPrimitiveTypeAdapter, "TriggerPrimitive")
DUNE_DAQ_TYPESTRING(std::vector<dunedaq::trigger::TriggerPrimitiveTypeAdapter>, "TriggerPrimitiveVector")

namespace dunedaq {
namespace trigger {
Expand Down
105 changes: 0 additions & 105 deletions src/trigger/TPSetSourceModel.hpp

This file was deleted.

Loading

0 comments on commit 3cbbc8e

Please sign in to comment.