DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
detchannelmaps
src
VDColdboxChannelMapService.cpp
Go to the documentation of this file.
1
2
// Class: VDColdboxChannelMapService
3
// Module type: service
4
// File: VDColdboxChannelMapService.h
5
// Author: Tom Junk, October 2021
6
//
7
// Implementation of hardware-offline channel mapping reading from a file.
9
10
#include "
VDColdboxChannelMapService.hpp
"
11
12
#include <fstream>
13
#include <sstream>
14
15
namespace
dunedaq
{
16
namespace
detchannelmaps
{
17
18
VDColdboxChannelMapService::VDColdboxChannelMapService
(std::string filename)
19
{
20
21
std::ifstream inFile(
filename
, std::ios::in);
22
if
(inFile.bad() || inFile.fail() || !inFile.is_open()) {
23
throw
std::runtime_error(std::string(
"VDColdboxChannelMapService: Invalid map file "
) + std::string(
filename
));
24
}
25
26
std::string line;
27
while
(std::getline(inFile, line)) {
28
VDCBChanInfo
chinfo;
29
std::stringstream linestream(line);
30
linestream >> chinfo.
offlchan
>> chinfo.
wib
>> chinfo.
wibconnector
>> chinfo.
cebchan
>> chinfo.
femb
>>
31
chinfo.
asic
>> chinfo.
asicchan
>> chinfo.
connector
>> chinfo.
stripid
;
32
chinfo.
valid
=
true
;
33
chantoinfomap
[chinfo.
offlchan
] = chinfo;
34
infotochanmap
[chinfo.
wib
][chinfo.
wibconnector
][chinfo.
cebchan
] = chinfo.
offlchan
;
35
}
36
inFile.close();
37
}
38
39
// The function below gets cold electronics info from offline channel number. Sets valid to be false if
40
// there is no corresponding cold electronics channel
41
// if not found in the map, return a chan info struct filled with -1's and set the valid flag to false.
42
43
VDColdboxChannelMapService::VDCBChanInfo
44
VDColdboxChannelMapService::getChanInfoFromOfflChan
(
int
offlchan)
45
{
46
VDCBChanInfo
r;
47
auto
fm =
chantoinfomap
.find(offlchan);
48
if
(fm ==
chantoinfomap
.end()) {
49
r.offlchan = -1;
50
r.wib = -1;
51
r.wibconnector = -1;
52
r.cebchan = -1;
53
r.femb = -1;
54
r.asic = -1;
55
r.asicchan = -1;
56
r.connector = -1;
57
r.stripid =
"INVALID"
;
58
r.valid =
false
;
59
}
else
{
60
r = fm->second;
61
}
62
return
r;
63
}
64
65
// The function below uses conventions from Nitish's spreadsheet. WIB: 1-3, wibconnector: 1-4, cechan: 0-127
66
// It returns an offline channel number of -1 if the wib, wibconnector, and cechan are not in the map
67
68
int
69
VDColdboxChannelMapService::getOfflChanFromWIBConnectorInfo
(
int
wib
,
int
wibconnector,
int
cechan)
70
{
71
// int r = -1;
72
// auto fm1 = infotochanmap.find(wib);
73
// if (fm1 == infotochanmap.end()) return r;
74
// auto& m1 = fm1->second;
75
// auto fm2 = m1.find(wibconnector);
76
// if (fm2 == m1.end()) return r;
77
// auto& m2 = fm2->second;
78
// auto fm3 = m2.find(cechan);
79
// if (fm3 == m2.end()) return r;
80
// r = fm3->second;
81
// return r;
82
try
{
83
return
infotochanmap
.at(
wib
).at(wibconnector).at(cechan);
84
}
catch
(...) {
85
return
-1;
86
}
87
// return -1;
88
}
89
90
// For convenience, the function below uses conventions from the DAQ WIB header, with two FEMBs per fiber
91
// on FELIX readout: slot: 0-2, fiber=1 or 2, cehcan: 0-255
92
// it returns a channel number of -1 if the slot, fiber, chan combination is not in the map
93
94
int
95
VDColdboxChannelMapService::getOfflChanFromSlotFiberChan
(
int
slot,
int
fiber,
int
chan)
96
{
97
int
wc = fiber * 2 - 1;
98
if
(chan > 127) {
99
chan -= 128;
100
wc++;
101
}
102
return
getOfflChanFromWIBConnectorInfo
(slot + 1, wc, chan);
103
}
104
105
}
// namespace detchannelsmap
106
}
// namespace dunedaq
VDColdboxChannelMapService.hpp
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDColdboxChannelMapService
VDColdboxChannelMapService(std::string mapfile)
Definition
VDColdboxChannelMapService.cpp:18
dunedaq::detchannelmaps::VDColdboxChannelMapService::getOfflChanFromSlotFiberChan
int getOfflChanFromSlotFiberChan(int slot, int fiber, int chan)
Definition
VDColdboxChannelMapService.cpp:95
dunedaq::detchannelmaps::VDColdboxChannelMapService::chantoinfomap
std::unordered_map< int, VDCBChanInfo > chantoinfomap
Definition
VDColdboxChannelMapService.hpp:59
dunedaq::detchannelmaps::VDColdboxChannelMapService::getChanInfoFromOfflChan
VDCBChanInfo getChanInfoFromOfflChan(int offlchan)
Definition
VDColdboxChannelMapService.cpp:44
dunedaq::detchannelmaps::VDColdboxChannelMapService::getOfflChanFromWIBConnectorInfo
int getOfflChanFromWIBConnectorInfo(int wib, int wibconnector, int cechan)
Definition
VDColdboxChannelMapService.cpp:69
dunedaq::detchannelmaps::VDColdboxChannelMapService::infotochanmap
std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, int > > > infotochanmap
Definition
VDColdboxChannelMapService.hpp:63
dunedaq::detchannelmaps
Definition
PD2HDChannelMapSPPluginBase.hpp:8
dunedaq
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
wib
Definition
wib.pb.cc:23
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo
Definition
VDColdboxChannelMapService.hpp:26
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::femb
int femb
Definition
VDColdboxChannelMapService.hpp:31
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::connector
int connector
Definition
VDColdboxChannelMapService.hpp:34
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::stripid
std::string stripid
Definition
VDColdboxChannelMapService.hpp:35
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::offlchan
int offlchan
Definition
VDColdboxChannelMapService.hpp:27
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::asic
int asic
Definition
VDColdboxChannelMapService.hpp:32
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::valid
bool valid
Definition
VDColdboxChannelMapService.hpp:36
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::asicchan
int asicchan
Definition
VDColdboxChannelMapService.hpp:33
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::wib
int wib
Definition
VDColdboxChannelMapService.hpp:28
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::cebchan
int cebchan
Definition
VDColdboxChannelMapService.hpp:30
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::wibconnector
int wibconnector
Definition
VDColdboxChannelMapService.hpp:29
tablepositions::filename
@ filename
Definition
ui_constants.hpp:13
Generated on
for DUNE-DAQ by
1.18.0