LCOV - code coverage report
Current view: top level - detchannelmaps/src - PD2HDChannelMapSP.h (source / functions) Coverage Total Hit
Test: code.result Lines: 75.0 % 4 3
Test Date: 2026-02-16 10:18:04 Functions: 100.0 % 1 1

            Line data    Source code
       1              : ///////////////////////////////////////////////////////////////////////////////////////////////////
       2              : // Class:       PD2HDChannelMapSP
       3              : // Module type: algorithm
       4              : // File:        PD2HDChannelMapSP.h
       5              : // Author:      Tom Junk, June 2022
       6              : //
       7              : // Implementation of hardware-offline channel mapping reading from a file.
       8              : // art-independent class  
       9              : // ProtoDUNE-2 Horizontal Drift APA wire to offline channel map
      10              : ///////////////////////////////////////////////////////////////////////////////////////////////////
      11              : 
      12              : #ifndef PD2HDChannelMapSP_H
      13              : #define PD2HDChannelMapSP_H
      14              : 
      15              : #include <unordered_map>
      16              : #include <vector>
      17              : #include <stdexcept>
      18              : 
      19              : namespace dune {
      20              :   class PD2HDChannelMapSP;
      21              : }
      22              : 
      23              : class dune::PD2HDChannelMapSP {
      24              : 
      25              : public:
      26              : 
      27              :   typedef struct HDChanInfo {
      28              :     unsigned int offlchan;        // in gdml and channel sorting convention
      29              :     unsigned int crate;           // crate number
      30              :     std::string APAName;          // Descriptive APA name
      31              :     unsigned int wib;             // 1, 2, 3, 4 or 5  (slot number +1?)
      32              :     unsigned int link;            // link identifier: 0 or 1
      33              :     unsigned int femb_on_link;    // which of two FEMBs in the WIB frame this FEMB is:  0 or 1
      34              :     unsigned int cebchan;         // cold electronics channel on FEMB:  0 to 127
      35              :     unsigned int plane;           // 0: U,  1: V,  2: X
      36              :     unsigned int chan_in_plane;   // which channel this is in the plane in the FEMB:  0:39 for U and V, 0:47 for X
      37              :     unsigned int femb;            // which FEMB on an APA -- 1 to 20
      38              :     unsigned int asic;            // ASIC:   1 to 8
      39              :     unsigned int asicchan;        // ASIC channel:  0 to 15
      40              :     unsigned int wibframechan;    // channel index in WIB frame (used with get_adc in detdataformats/WIB2Frame.hh).  0:255
      41              :     bool valid;          // true if valid, false if not
      42              :   } HDChanInfo_t;
      43              : 
      44              :   PD2HDChannelMapSP();  // constructor
      45              : 
      46              :   // initialize:  read map from file
      47              : 
      48              :   void ReadMapFromFile(std::string &fullname);
      49              : 
      50              :   // TPC channel map accessors
      51              : 
      52              :   // Map instrumentation numbers (crate:slot:link:FEMB:plane) to offline channel number.  FEMB is 0 or 1 and indexes the FEMB in the WIB frame.
      53              :   // plane = 0 for U, 1 for V and 2 for X
      54              : 
      55              :   HDChanInfo_t GetChanInfoFromWIBElements(
      56              :    unsigned int crate,
      57              :    unsigned int slot,
      58              :    unsigned int link,
      59              :    unsigned int wibframechan) const;
      60              : 
      61              :   HDChanInfo_t GetChanInfoFromOfflChan(unsigned int offlchan) const;
      62              : 
      63              : private:
      64              : 
      65              :   const unsigned int fNChans = 2560*4;
      66              : 
      67              :   // map of crate, slot, link, femb_on_link, plane, chan to channel info struct
      68              : 
      69              :   std::unordered_map<unsigned int,   // crate
      70              :     std::unordered_map<unsigned int, // wib
      71              :     std::unordered_map<unsigned int, // link
      72              :     std::unordered_map<unsigned int, // wibframechan
      73              :     HDChanInfo_t > > > > DetToChanInfo;
      74              : 
      75              :   // map of chan info indexed by offline channel number
      76              : 
      77              :   std::unordered_map<unsigned int, HDChanInfo_t> OfflToChanInfo;
      78              : 
      79              :   //-----------------------------------------------
      80              : 
      81         2560 :   void check_offline_channel(unsigned int offlineChannel) const
      82              :   {
      83         2560 :   if (offlineChannel >= fNChans)
      84              :     {      
      85            0 :       throw std::range_error("PD2HDChannelMapSP offline Channel out of range"); 
      86              :     }
      87         2560 :   };
      88              : 
      89              : };
      90              : 
      91              : 
      92              : #endif
        

Generated by: LCOV version 2.0-1