DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
PDSChannelMap.hpp
Go to the documentation of this file.
1#ifndef DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_PDSCHANNELMAP_HPP_
2#define DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_PDSCHANNELMAP_HPP_
3
4#include "cetlib/BasicPluginFactory.h"
5#include "cetlib/compiler_macros.h"
6#include "ers/Issue.hpp"
7#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
8#include <optional>
9
10
11#ifndef EXTERN_C_FUNC_DECLARE_START
12// NOLINTNEXTLINE(build/define_used)
13#define EXTERN_C_FUNC_DECLARE_START \
14 extern "C" \
15 {
16#endif
21// NOLINTNEXTLINE(build/define_used)
22#define DEFINE_DUNE_DET_PDSCHANNEL_MAP(klass) \
23 EXTERN_C_FUNC_DECLARE_START \
24 std::shared_ptr<dunedaq::detchannelmaps::PDSChannelMap> make() \
25 { \
26 return std::shared_ptr<dunedaq::detchannelmaps::PDSChannelMap>(new klass()); \
27 } \
28 }
29
30
31namespace dunedaq {
32
33// Disable coverage collection LCOV_EXCL_START
38 PDSChannelMapCreationFailed,
39 "Failed to create PDSChannelMap of type " << plugin_name,
40 ((std::string)plugin_name)
41)
44 "Invalid stream number " << stream,
45 ((uint)stream)
46)
47
48namespace detchannelmaps {
49
50class PDSChannelMap
51{
52public:
53
54 struct PDSChannelInfo
55 {
56 static constexpr uint16_t kUndefined=0xffff;
57
58 uint16_t detector = kUndefined;
59 uint16_t crate = kUndefined;
60 uint16_t slot = kUndefined;
61 uint16_t stream = kUndefined;
62 uint16_t channel = kUndefined;
63 uint16_t element = kUndefined;
64 };
65
77 virtual uint get_offline_channel_from_det_crate_slot_stream_chan(uint det, uint crate, uint slot, uint stream, uint channel) = 0;
78
79 virtual uint get_element_from_offline_channel(uint ) = 0;
80 virtual std::string get_element_name_from_offline_channel(uint ) = 0;
81 virtual std::optional<PDSChannelInfo> get_det_crate_slot_fiber_chan_from_offline_channel(uint offchannel) = 0;
85 virtual ~PDSChannelMap() noexcept = default;
86
87protected:
88 /*
89 * @brief PDSChannelMap Constructor
90 * @param name Name of the PDSChannelMap
91 */
92 explicit PDSChannelMap(){}
93};
94
103inline std::shared_ptr<PDSChannelMap>
104make_pds_map(std::string const& plugin_name)
105{
106 static cet::BasicPluginFactory bpf("dunePDSChannelMap", "make");
107
108 std::shared_ptr<PDSChannelMap> mod_ptr;
109 try {
110 mod_ptr = bpf.makePlugin<std::shared_ptr<PDSChannelMap>>(plugin_name);
111 } catch (const cet::exception& cexpt) {
112 throw PDSChannelMapCreationFailed(ERS_HERE, plugin_name, cexpt);
113 }
114 return mod_ptr;
115}
116
117} // namespace detchannelmaps
118
119} // namespace dunedaq
120
121#endif // DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_PDSCHANNELMAP_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_HERE
The DUNE-DAQ namespace.
Definition DataStore.hpp:57
PDSInvalidStream
< Namespace