DUNE-DAQ
DUNE Trigger and Data Acquisition software
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
std::ifstream inFile(
filename
, std::ios::in);
21
if
(inFile.bad() || inFile.fail() || !inFile.is_open()) {
22
throw
std::runtime_error(std::string(
"VDColdboxChannelMapService: Invalid map file "
) + std::string(
filename
));
23
}
24
25
std::string line;
26
while
(std::getline(inFile,line)) {
27
VDCBChanInfo
chinfo;
28
std::stringstream linestream(line);
29
linestream >>
30
chinfo.
offlchan
>>
31
chinfo.
wib
>>
32
chinfo.
wibconnector
>>
33
chinfo.
cebchan
>>
34
chinfo.
femb
>>
35
chinfo.
asic
>>
36
chinfo.
asicchan
>>
37
chinfo.
connector
>>
38
chinfo.
stripid
;
39
chinfo.
valid
=
true
;
40
chantoinfomap
[chinfo.
offlchan
] = chinfo;
41
infotochanmap
[chinfo.
wib
][chinfo.
wibconnector
][chinfo.
cebchan
] = chinfo.
offlchan
;
42
}
43
inFile.close();
44
45
}
46
47
// The function below gets cold electronics info from offline channel number. Sets valid to be false if
48
// there is no corresponding cold electronics channel
49
// if not found in the map, return a chan info struct filled with -1's and set the valid flag to false.
50
51
VDColdboxChannelMapService::VDCBChanInfo
VDColdboxChannelMapService::getChanInfoFromOfflChan
(
int
offlchan)
52
{
53
VDCBChanInfo
r;
54
auto
fm =
chantoinfomap
.find(offlchan);
55
if
(fm ==
chantoinfomap
.end())
56
{
57
r.offlchan = -1;
58
r.wib = -1;
59
r.wibconnector = -1;
60
r.cebchan = -1;
61
r.femb = -1;
62
r.asic = -1;
63
r.asicchan = -1;
64
r.connector = -1;
65
r.stripid =
"INVALID"
;
66
r.valid =
false
;
67
}
68
else
69
{
70
r = fm->second;
71
}
72
return
r;
73
}
74
75
76
// The function below uses conventions from Nitish's spreadsheet. WIB: 1-3, wibconnector: 1-4, cechan: 0-127
77
// It returns an offline channel number of -1 if the wib, wibconnector, and cechan are not in the map
78
79
int
VDColdboxChannelMapService::getOfflChanFromWIBConnectorInfo
(
int
wib
,
int
wibconnector,
int
cechan)
80
{
81
// int r = -1;
82
// auto fm1 = infotochanmap.find(wib);
83
// if (fm1 == infotochanmap.end()) return r;
84
// auto& m1 = fm1->second;
85
// auto fm2 = m1.find(wibconnector);
86
// if (fm2 == m1.end()) return r;
87
// auto& m2 = fm2->second;
88
// auto fm3 = m2.find(cechan);
89
// if (fm3 == m2.end()) return r;
90
// r = fm3->second;
91
// return r;
92
try
{
93
return
infotochanmap
.at(
wib
).at(wibconnector).at(cechan);
94
}
catch
(...) {
95
return
-1;
96
}
97
// return -1;
98
}
99
100
// For convenience, the function below uses conventions from the DAQ WIB header, with two FEMBs per fiber
101
// on FELIX readout: slot: 0-2, fiber=1 or 2, cehcan: 0-255
102
// it returns a channel number of -1 if the slot, fiber, chan combination is not in the map
103
104
int
VDColdboxChannelMapService::getOfflChanFromSlotFiberChan
(
int
slot,
int
fiber,
int
chan)
105
{
106
int
wc = fiber*2 - 1;
107
if
(chan>127)
108
{
109
chan -= 128;
110
wc++;
111
}
112
return
getOfflChanFromWIBConnectorInfo
(slot+1,wc,chan);
113
}
114
115
}
// namespace detchannelsmap
116
}
// namespace dunedaq
117
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:104
dunedaq::detchannelmaps::VDColdboxChannelMapService::getChanInfoFromOfflChan
VDCBChanInfo getChanInfoFromOfflChan(int offlchan)
Definition
VDColdboxChannelMapService.cpp:51
dunedaq::detchannelmaps::VDColdboxChannelMapService::chantoinfomap
std::unordered_map< int, VDCBChanInfo > chantoinfomap
Definition
VDColdboxChannelMapService.hpp:60
dunedaq::detchannelmaps::VDColdboxChannelMapService::getOfflChanFromWIBConnectorInfo
int getOfflChanFromWIBConnectorInfo(int wib, int wibconnector, int cechan)
Definition
VDColdboxChannelMapService.cpp:79
dunedaq::detchannelmaps::VDColdboxChannelMapService::infotochanmap
std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, int > > > infotochanmap
Definition
VDColdboxChannelMapService.hpp:64
detchannelmaps
Definition
__init__.py:1
dunedaq
Including Qt Headers.
Definition
TimingController.hxx:1
wib
Definition
wib.pb.cc:23
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo
Definition
VDColdboxChannelMapService.hpp:25
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::femb
int femb
Definition
VDColdboxChannelMapService.hpp:30
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::connector
int connector
Definition
VDColdboxChannelMapService.hpp:33
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::stripid
std::string stripid
Definition
VDColdboxChannelMapService.hpp:34
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::offlchan
int offlchan
Definition
VDColdboxChannelMapService.hpp:26
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::asic
int asic
Definition
VDColdboxChannelMapService.hpp:31
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::valid
bool valid
Definition
VDColdboxChannelMapService.hpp:35
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::asicchan
int asicchan
Definition
VDColdboxChannelMapService.hpp:32
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::wib
int wib
Definition
VDColdboxChannelMapService.hpp:27
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::cebchan
int cebchan
Definition
VDColdboxChannelMapService.hpp:29
dunedaq::detchannelmaps::VDColdboxChannelMapService::VDCBChanInfo::wibconnector
int wibconnector
Definition
VDColdboxChannelMapService.hpp:28
tablepositions::filename
@ filename
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0