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
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_TPCCHANNEL_MAP(klass) \
23 EXTERN_C_FUNC_DECLARE_START \
24 std::shared_ptr<dunedaq::detchannelmaps::TPCChannelMap> make() \
25 { \
26 return std::shared_ptr<dunedaq::detchannelmaps::TPCChannelMap>(new klass()); \
27 } \
28 }
29
30
31namespace dunedaq {
32
33// Disable coverage collection LCOV_EXCL_START
38 ChannelMapCreationFailed,
39 "Failed to create TPCChannelMap of type " << plugin_name,
40 ((std::string)plugin_name)
41)
42
45 "Invalid stream identifier " << stream,
46 ((uint)stream)
47)
48
50 InvalidDetectorID,
51 "Invalid detector identifier " << stream,
52 ((uint)stream)
53)
54
55
56namespace detchannelmaps {
57
58class TPCChannelMap
59{
60public:
61
62 struct TPCChannelInfo
63 {
64 static constexpr uint16_t kUndefined=0xffff;
65
66 uint16_t detector = kUndefined;
67 uint16_t crate = kUndefined;
68 uint16_t slot = kUndefined;
69 uint16_t stream = kUndefined;
70 uint16_t channel = kUndefined;
71 uint16_t element = kUndefined;
72 };
73
85 virtual uint get_offline_channel_from_det_crate_slot_stream_chan(uint det, uint crate, uint slot, uint stream, 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_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_HERE
Including Qt Headers.
InvalidStreamID
< Namespace