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#ifndef EXTERN_C_FUNC_DECLARE_START
11// NOLINTNEXTLINE(build/define_used)
12#define EXTERN_C_FUNC_DECLARE_START \
13 extern "C" \
14 {
15#endif
20// NOLINTNEXTLINE(build/define_used)
21#define DEFINE_DUNE_DET_PDSCHANNEL_MAP(klass) \
22 EXTERN_C_FUNC_DECLARE_START \
23 std::shared_ptr<dunedaq::detchannelmaps::PDSChannelMap> make() \
24 { \
25 return std::shared_ptr<dunedaq::detchannelmaps::PDSChannelMap>(new klass()); \
26 } \
27 }
28
29namespace dunedaq {
30
31// Disable coverage collection LCOV_EXCL_START
36 PDSChannelMapCreationFailed,
37 "Failed to create PDSChannelMap of type " << plugin_name,
38 ((std::string)plugin_name)
39)
42 "Invalid stream number " << stream,
43 ((uint)stream)
44)
45
46namespace detchannelmaps {
47
48class PDSChannelMap
49{
50public:
51 struct PDSChannelInfo
52 {
53 static constexpr uint16_t kUndefined = 0xffff;
54
55 uint16_t detector = kUndefined;
56 uint16_t crate = kUndefined;
57 uint16_t slot = kUndefined;
58 uint16_t stream = kUndefined;
59 uint16_t channel = kUndefined;
60 uint16_t element = kUndefined;
61 };
62
74 virtual uint get_offline_channel_from_det_crate_slot_stream_chan(uint det,
75 uint crate,
76 uint slot,
77 uint stream,
78 uint channel) = 0;
79
80 virtual uint get_element_from_offline_channel(uint) = 0;
81 virtual std::string get_element_name_from_offline_channel(uint) = 0;
82 virtual std::optional<PDSChannelInfo> get_det_crate_slot_fiber_chan_from_offline_channel(uint offchannel) = 0;
86 virtual ~PDSChannelMap() noexcept = default;
87
88protected:
89 /*
90 * @brief PDSChannelMap Constructor
91 * @param name Name of the PDSChannelMap
92 */
93 explicit PDSChannelMap() {}
94};
95
104inline std::shared_ptr<PDSChannelMap>
105make_pds_map(std::string const& plugin_name)
106{
107 static cet::BasicPluginFactory bpf("dunePDSChannelMap", "make");
108
109 std::shared_ptr<PDSChannelMap> mod_ptr;
110 try {
111 mod_ptr = bpf.makePlugin<std::shared_ptr<PDSChannelMap>>(plugin_name);
112 } catch (const cet::exception& cexpt) {
113 throw PDSChannelMapCreationFailed(ERS_HERE, plugin_name, cexpt);
114 }
115 return mod_ptr;
116}
117
118} // namespace detchannelmaps
119
120} // namespace dunedaq
121
122#endif // DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_PDSCHANNELMAP_HPP_
#define ERS_HERE
The DUNE-DAQ namespace.
ERS_DECLARE_ISSUE(cibmodules, CIBCommunicationError, " CIB Hardware Communication Error: "<< descriptor,((std::string) descriptor)) ERS_DECLARE_ISSUE(cibmodules
PDSInvalidStream
< Namespace