DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
detchannelmaps
src
PD2HDChannelMapSPPluginBase.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
PD2HDChannelMapSP.h
"
4
#include "
logging/Logging.hpp
"
// NOLINT
5
#include "
detchannelmaps/TPCChannelMap.hpp
"
6
7
namespace
dunedaq
{
8
namespace
detchannelmaps
{
9
10
class
PD2HDChannelMapSPPluginBase
:
public
TPCChannelMap {
11
private
:
12
const
uint
m_det_id
;
13
std::unique_ptr<dune::PD2HDChannelMapSP>
m_channel_map
;
14
protected
:
15
std::function<uint(std::string)>
m_elem_name_id_converter
;
16
public
:
17
24
explicit
PD2HDChannelMapSPPluginBase
(uint det_id,
const
std::string& channel_map_path ) :
25
m_det_id
(det_id) {
26
27
const
char
* detchannelmaps_share_cstr = getenv(
"DETCHANNELMAPS_SHARE"
);
28
if
(!detchannelmaps_share_cstr) {
29
throw
std::runtime_error(
"Environment variable DETCHANNELMAPS_SHARE is not set"
);
30
}
31
std::string detchannelmaps_share(detchannelmaps_share_cstr);
32
std::string channel_map_file = detchannelmaps_share +
"/config/"
+ channel_map_path;
33
m_channel_map
.reset(
new
dune::PD2HDChannelMapSP
());
34
m_channel_map
->ReadMapFromFile(channel_map_file);
35
36
}
37
38
PD2HDChannelMapSPPluginBase
(
const
PD2HDChannelMapSPPluginBase
&) =
delete
;
39
PD2HDChannelMapSPPluginBase
&
operator=
(
const
PD2HDChannelMapSPPluginBase
&) =
delete
;
40
PD2HDChannelMapSPPluginBase
(
PD2HDChannelMapSPPluginBase
&&) =
delete
;
41
PD2HDChannelMapSPPluginBase
&
operator=
(
PD2HDChannelMapSPPluginBase
&&) =
delete
;
42
43
55
uint
56
get_offline_channel_from_det_crate_slot_stream_chan
(uint det, uint crate, uint slot, uint stream, uint channel)
final
{
57
58
// Must be a BDE channel
59
if
( det !=
m_det_id
)
60
return
-1;
61
62
// if stream number looks wrong (not 0,1,2,3 or 64,65,66,67)
63
if
( (stream & 0xbc) )
64
return
-1;
65
66
constexpr
uint n_chan_per_stream = 64;
67
68
uint link = (stream >> 6) & 1;
69
uint stream_in_link = (stream & 0x3);
70
uint wibframechan = n_chan_per_stream*stream_in_link+channel;
71
72
auto
chan_info =
m_channel_map
->GetChanInfoFromWIBElements(
73
crate, slot, link, wibframechan
74
);
75
76
if
(!chan_info.valid) {
77
return
-1;
78
}
79
80
return
chan_info.offlchan;
81
}
82
83
90
uint
91
get_plane_from_offline_channel
(uint offchannel)
final
{
92
auto
chan_info =
m_channel_map
->GetChanInfoFromOfflChan(offchannel);
93
94
if
(!chan_info.valid) {
95
return
-1;
96
}
97
98
return
chan_info.plane;
99
};
100
101
108
uint
109
get_element_id_from_offline_channel
( uint offchannel)
final
{
110
auto
chan_info =
m_channel_map
->GetChanInfoFromOfflChan(offchannel);
111
112
if
(!chan_info.valid) {
113
return
-1;
114
}
115
116
return
m_elem_name_id_converter
(chan_info.APAName);
117
118
// There is only one element
119
return
0;
120
}
121
128
std::string
129
get_element_name_from_offline_channel
( uint offchannel)
final
{
130
auto
chan_info =
m_channel_map
->GetChanInfoFromOfflChan(offchannel);
131
132
if
(!chan_info.valid) {
133
return
""
;
134
}
135
136
return
chan_info.APAName;
137
}
138
139
140
std::optional<TPCChannelMap::TPCChannelInfo>
141
get_channel_info_from_offline_channel
(uint offchannel)
final
{
142
auto
ci =
m_channel_map
->GetChanInfoFromOfflChan(offchannel);
143
144
if
( !ci.valid) {
145
return
std::nullopt;
146
}
147
constexpr
uint n_chan_per_stream = 64;
148
uint16_t slot_id = ci.wib-1;
149
uint16_t stream_id = ci.link*n_chan_per_stream+ci.wibframechan/n_chan_per_stream;
150
uint16_t chan_id = ci.wibframechan%n_chan_per_stream;
151
152
return
TPCChannelMap::TPCChannelInfo{
m_det_id
, ci.crate, slot_id, stream_id, chan_id,
m_elem_name_id_converter
(ci.APAName)};
153
}
154
155
};
156
157
}
// namespace detchannelmaps
158
}
// namespace dunedaq
PD2HDChannelMapSP.h
TPCChannelMap.hpp
dune::PD2HDChannelMapSP
Definition
PD2HDChannelMapSP.h:23
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::get_plane_from_offline_channel
uint get_plane_from_offline_channel(uint offchannel) final
Get the plane from offline channel object.
Definition
PD2HDChannelMapSPPluginBase.hpp:91
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::PD2HDChannelMapSPPluginBase
PD2HDChannelMapSPPluginBase(PD2HDChannelMapSPPluginBase &&)=delete
PD2HDChannelMapSPPluginBase is not move-constructible.
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::operator=
PD2HDChannelMapSPPluginBase & operator=(PD2HDChannelMapSPPluginBase &&)=delete
PD2HDChannelMapSPPluginBase is not move-assignable.
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::get_element_name_from_offline_channel
std::string get_element_name_from_offline_channel(uint offchannel) final
Get the tpc element name from offline channel object.
Definition
PD2HDChannelMapSPPluginBase.hpp:129
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::PD2HDChannelMapSPPluginBase
PD2HDChannelMapSPPluginBase(uint det_id, const std::string &channel_map_path)
Construct a new PD2HDChannelMapSPPluginBase object.
Definition
PD2HDChannelMapSPPluginBase.hpp:24
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::get_channel_info_from_offline_channel
std::optional< TPCChannelMap::TPCChannelInfo > get_channel_info_from_offline_channel(uint offchannel) final
Definition
PD2HDChannelMapSPPluginBase.hpp:141
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::get_element_id_from_offline_channel
uint get_element_id_from_offline_channel(uint offchannel) final
Get the element id from offline channel object.
Definition
PD2HDChannelMapSPPluginBase.hpp:109
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::operator=
PD2HDChannelMapSPPluginBase & operator=(const PD2HDChannelMapSPPluginBase &)=delete
PD2HDChannelMapSPPluginBase is not copy-assignable.
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::m_elem_name_id_converter
std::function< uint(std::string)> m_elem_name_id_converter
Definition
PD2HDChannelMapSPPluginBase.hpp:15
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::get_offline_channel_from_det_crate_slot_stream_chan
uint get_offline_channel_from_det_crate_slot_stream_chan(uint det, uint crate, uint slot, uint stream, uint channel) final
Get the offline channel from detector crate slot stream chan object.
Definition
PD2HDChannelMapSPPluginBase.hpp:56
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::m_channel_map
std::unique_ptr< dune::PD2HDChannelMapSP > m_channel_map
Definition
PD2HDChannelMapSPPluginBase.hpp:13
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::PD2HDChannelMapSPPluginBase
PD2HDChannelMapSPPluginBase(const PD2HDChannelMapSPPluginBase &)=delete
PD2HDChannelMapSPPluginBase is not copy-constructible.
dunedaq::detchannelmaps::PD2HDChannelMapSPPluginBase::m_det_id
const uint m_det_id
Definition
PD2HDChannelMapSPPluginBase.hpp:12
Logging.hpp
detchannelmaps
Definition
__init__.py:1
dunedaq
Including Qt Headers.
Definition
module.cpp:16
Generated on
for DUNE-DAQ by
1.17.0