DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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
11
12#include <fstream>
13#include <sstream>
14
15namespace dunedaq {
16namespace detchannelmaps {
17
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
45{
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
68int
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
94int
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
int getOfflChanFromWIBConnectorInfo(int wib, int wibconnector, int cechan)
std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, int > > > infotochanmap
The DUNE-DAQ namespace.
Definition wib.pb.cc:23