LCOV - code coverage report
Current view: top level - detchannelmaps/src - VDColdboxChannelMapService.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 53 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 4 0

            Line data    Source code
       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.
       8              : ///////////////////////////////////////////////////////////////////////////////////////////////////
       9              : 
      10              : #include "VDColdboxChannelMapService.hpp"
      11              : 
      12              : #include <fstream>
      13              : #include <sstream>
      14              : 
      15              : namespace dunedaq {
      16              : namespace detchannelmaps {
      17              : 
      18            0 : VDColdboxChannelMapService::VDColdboxChannelMapService(std::string filename) {
      19              : 
      20            0 :   std::ifstream inFile(filename, std::ios::in);
      21            0 :   if (inFile.bad() || inFile.fail() || !inFile.is_open()) {
      22            0 :     throw std::runtime_error(std::string("VDColdboxChannelMapService: Invalid map file ") + std::string(filename));
      23              :   }
      24              : 
      25            0 :   std::string line;
      26            0 :   while (std::getline(inFile,line)) {
      27            0 :     VDCBChanInfo chinfo;
      28            0 :     std::stringstream linestream(line);
      29            0 :     linestream >>
      30            0 :       chinfo.offlchan >>
      31            0 :       chinfo.wib >>
      32            0 :       chinfo.wibconnector >>
      33            0 :       chinfo.cebchan >>
      34            0 :       chinfo.femb >>
      35            0 :       chinfo.asic >>
      36            0 :       chinfo.asicchan >>
      37            0 :       chinfo.connector >>
      38            0 :       chinfo.stripid;
      39            0 :     chinfo.valid = true;
      40            0 :     chantoinfomap[chinfo.offlchan] = chinfo;
      41            0 :     infotochanmap[chinfo.wib][chinfo.wibconnector][chinfo.cebchan] = chinfo.offlchan; 
      42            0 :   }
      43            0 :   inFile.close();
      44              : 
      45            0 : }
      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            0 : VDColdboxChannelMapService::VDCBChanInfo VDColdboxChannelMapService::getChanInfoFromOfflChan(int offlchan)
      52              : {
      53            0 :   VDCBChanInfo r;
      54            0 :   auto fm = chantoinfomap.find(offlchan);
      55            0 :   if (fm == chantoinfomap.end())
      56              :     {
      57            0 :       r.offlchan = -1;
      58            0 :       r.wib = -1;
      59            0 :       r.wibconnector = -1;
      60            0 :       r.cebchan = -1;
      61            0 :       r.femb = -1;
      62            0 :       r.asic = -1;
      63            0 :       r.asicchan = -1;
      64            0 :       r.connector = -1;
      65            0 :       r.stripid = "INVALID";
      66            0 :       r.valid = false;
      67              :     }
      68              :   else
      69              :     {
      70            0 :       r = fm->second;
      71              :     }
      72            0 :   return r;
      73            0 : }
      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            0 : 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            0 :   try {
      93            0 :     return infotochanmap.at(wib).at(wibconnector).at(cechan);
      94            0 :   } catch (...) {
      95            0 :     return -1;
      96            0 :   }
      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            0 : int VDColdboxChannelMapService::getOfflChanFromSlotFiberChan(int slot, int fiber, int chan)
     105              : {
     106            0 :   int wc = fiber*2 - 1;
     107            0 :   if (chan>127)
     108              :     {
     109            0 :       chan -= 128;
     110            0 :       wc++;
     111              :     }
     112            0 :   return getOfflChanFromWIBConnectorInfo(slot+1,wc,chan);
     113              : }
     114              : 
     115              : } // namespace detchannelsmap
     116              : } // namespace dunedaq
     117              : 
        

Generated by: LCOV version 2.0-1