DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPCChannelMap.hpp
Go to the documentation of this file.
1#ifndef DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_TPCCHANNELMAP_HPP_
2#define DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_TPCCHANNELMAP_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_TPCCHANNEL_MAP(klass) \
22 EXTERN_C_FUNC_DECLARE_START \
23 std::shared_ptr<dunedaq::detchannelmaps::TPCChannelMap> make() \
24 { \
25 return std::shared_ptr<dunedaq::detchannelmaps::TPCChannelMap>(new klass()); \
26 } \
27 }
28
29namespace dunedaq {
30
31// Disable coverage collection LCOV_EXCL_START
36 ChannelMapCreationFailed,
37 "Failed to create TPCChannelMap of type " << plugin_name,
38 ((std::string)plugin_name)
39)
40
43 "Invalid stream identifier " << stream,
44 ((uint)stream)
45)
46
48 InvalidDetectorID,
49 "Invalid detector identifier " << stream,
50 ((uint)stream)
51)
52
53namespace detchannelmaps {
54
55class TPCChannelMap
56{
57public:
58 struct TPCChannelInfo
59 {
60 static constexpr uint16_t kUndefined = 0xffff;
61
62 uint16_t detector = kUndefined;
63 uint16_t crate = kUndefined;
64 uint16_t slot = kUndefined;
65 uint16_t stream = kUndefined;
66 uint16_t channel = kUndefined;
67 uint16_t element = kUndefined;
68 };
69
81 virtual uint get_offline_channel_from_det_crate_slot_stream_chan(uint det,
82 uint crate,
83 uint slot,
84 uint stream,
85 uint channel) = 0;
86
87 virtual uint get_plane_from_offline_channel(uint offchannel) = 0;
88 virtual uint get_element_id_from_offline_channel(uint) = 0;
89 virtual std::string get_element_name_from_offline_channel(uint) = 0;
90 virtual std::optional<TPCChannelInfo> get_channel_info_from_offline_channel(uint offchannel) = 0;
94 virtual ~TPCChannelMap() noexcept = default;
95
96protected:
101 explicit TPCChannelMap() {}
102};
103
112inline std::shared_ptr<TPCChannelMap>
113make_tpc_map(std::string const& plugin_name)
114{
115 static cet::BasicPluginFactory bpf("duneTPCChannelMap", "make");
116
117 std::shared_ptr<TPCChannelMap> mod_ptr;
118 try {
119 mod_ptr = bpf.makePlugin<std::shared_ptr<TPCChannelMap>>(plugin_name);
120 } catch (const cet::exception& cexpt) {
121 throw ChannelMapCreationFailed(ERS_HERE, plugin_name, cexpt);
122 }
123 return mod_ptr;
124}
125
126} // namespace detchannelmaps
127
128} // namespace dunedaq
129
130#endif // DETCHANNELMAPS_INCLUDE_DETCHANNELMAPS_TPCCHANNELMAP_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
InvalidStreamID
< Namespace