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 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
52{
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
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
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
int getOfflChanFromWIBConnectorInfo(int wib, int wibconnector, int cechan)
std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, int > > > infotochanmap
Including Qt Headers.
Definition wib.pb.cc:23