LCOV - code coverage report
Current view: top level - detchannelmaps/src - PdspChannelMapService.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 8 0
Test Date: 2026-02-16 10:18:04 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /**
       2              :  * @file PdspChannelMapService.hpp PDSP Channel Map
       3              :  * Inherited from Offline. Further details of author below.
       4              :  *
       5              :  * This is part of the DUNE DAQ , copyright 2020.
       6              :  * Licensing/copyright details are in the COPYING file that you should have
       7              :  * received with this code.
       8              :  * */
       9              : ///////////////////////////////////////////////////////////////////////////////////////////////////
      10              : // Class:       PdspChannelMapService
      11              : // Module type: service
      12              : // File:        PdspChannelMapService.h
      13              : // Author:      Jingbo Wang (jiowang@ucdavis.edu), February 2018
      14              : //
      15              : // Implementation of hardware-offline channel mapping reading from a file.
      16              : // Separate files for TPC wires and SSP modules
      17              : ///////////////////////////////////////////////////////////////////////////////////////////////////
      18              : 
      19              : #ifndef DETCHANNELMAPS_PDSPCHANNELMAPSERVICE_HPP_
      20              : #define DETCHANNELMAPS_PDSPCHANNELMAPSERVICE_HPP_
      21              : 
      22              : #include <fstream>
      23              : #include <iostream>
      24              : #include <limits>
      25              : #include <map>
      26              : #include <string>
      27              : #include <vector>
      28              : 
      29              : namespace dunedaq {
      30              : namespace detchannelmaps {
      31              : 
      32              : class PdspChannelMapService
      33              : {
      34              : 
      35              : public:
      36              :   PdspChannelMapService(std::string, std::string);
      37              : 
      38              :   typedef enum _FelixOrRCE
      39              :   {
      40              :     kRCE,
      41              :     kFELIX
      42              :   } FelixOrRCE;
      43              : 
      44              :   /////////////////////////\ ProtoDUNE-SP channel map fundtions //////////////////////////////
      45              : 
      46              :   // TPC channel map accessors
      47              : 
      48              :   // Map instrumentation numbers (crate:slot:fiber:FEMBchannel) to offline channel number
      49              :   // FEMB channel number is really the stream index number, but for FELIX, it is restricted to be in the range 0:127, so
      50              :   // really it's more like an FEMB channel number
      51              : 
      52              :   unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate,
      53              :                                                     unsigned int slot,
      54              :                                                     unsigned int fiber,
      55              :                                                     unsigned int fembchannel,
      56              :                                                     FelixOrRCE frswitch);
      57              : 
      58              :   /// Returns APA/crate
      59              :   unsigned int APAFromOfflineChannel(unsigned int offlineChannel) const;
      60              : 
      61              :   /// Returns APA/crate in installation notation
      62              :   unsigned int InstalledAPAFromOfflineChannel(unsigned int offlineChannel) const;
      63              : 
      64              :   /// Returns WIB/slot
      65              :   unsigned int WIBFromOfflineChannel(unsigned int offlineChannel) const;
      66              : 
      67              :   /// Returns FEMB/fiber
      68              :   unsigned int FEMBFromOfflineChannel(unsigned int offlineChannel) const;
      69              : 
      70              :   /// Returns FEMB channel
      71              :   unsigned int FEMBChannelFromOfflineChannel(unsigned int offlineChannel) const;
      72              : 
      73              :   /// Returns RCE(FELIX) stream(frame) channel
      74              :   unsigned int StreamChannelFromOfflineChannel(unsigned int offlineChannel, FelixOrRCE frswitch) const;
      75              : 
      76              :   /// Returns global slot ID
      77              :   unsigned int SlotIdFromOfflineChannel(unsigned int offlineChannel) const;
      78              : 
      79              :   /// Returns global fiber ID
      80              :   unsigned int FiberIdFromOfflineChannel(unsigned int offlineChannel) const;
      81              : 
      82              :   /// Returns chip number
      83              :   unsigned int ChipFromOfflineChannel(unsigned int offlineChannel) const;
      84              : 
      85              :   /// Returns chip channel number
      86              :   unsigned int ChipChannelFromOfflineChannel(unsigned int offlineChannel) const;
      87              : 
      88              :   /// Returns ASIC number -- to be deprecated
      89              :   unsigned int ASICFromOfflineChannel(unsigned int offlineChannel);
      90              : 
      91              :   /// Returns ASIC channel number -- to be deprecated
      92              :   unsigned int ASICChannelFromOfflineChannel(unsigned int offlineChannel);
      93              : 
      94              :   // replaced by these
      95              : 
      96              :   unsigned int AsicFromOfflineChannel(unsigned int offlineChannel) const;
      97              : 
      98              :   unsigned int AsicChannelFromOfflineChannel(unsigned int offlineChannel) const;
      99              : 
     100              :   unsigned int AsicLinkFromOfflineChannel(unsigned int offlineChannel) const;
     101              : 
     102              :   /// Returns plane
     103              :   unsigned int PlaneFromOfflineChannel(unsigned int offlineChannel) const;
     104              : 
     105              :   // SSP channel map accessors
     106              : 
     107              :   unsigned int SSPOfflineChannelFromOnlineChannel(unsigned int onlineChannel);
     108              : 
     109              :   unsigned int SSPOnlineChannelFromOfflineChannel(unsigned int offlineChannel) const;
     110              : 
     111              :   unsigned int SSPAPAFromOfflineChannel(unsigned int offlineChannel) const;
     112              : 
     113              :   unsigned int SSPWithinAPAFromOfflineChannel(unsigned int offlineChannel) const;
     114              : 
     115              :   unsigned int SSPGlobalFromOfflineChannel(unsigned int offlineChannel) const;
     116              : 
     117              :   unsigned int SSPChanWithinSSPFromOfflineChannel(unsigned int offlineChannel) const;
     118              : 
     119              :   unsigned int OpDetNoFromOfflineChannel(unsigned int offlineChannel) const;
     120              : 
     121              : private:
     122              :   // hardcoded TPC channel map sizes
     123              :   // Note -- we are assuming that FELIX with its two fibers per fragment knows the fiber numbers and that we aren't
     124              :   // encoding double-size channel lists for FELIX with single fiber numbers.
     125              : 
     126              :   const size_t fNChans = 15360;
     127              :   const size_t fNCrates = 6;
     128              :   const size_t fNSlots = 5;
     129              :   const size_t fNFibers = 4;
     130              :   const size_t fNFEMBChans = 128;
     131              : 
     132              :   // hardcoded SSP channel map sizes
     133              : 
     134              :   const size_t fNSSPChans = 288;
     135              :   // const size_t fNSSPs = 24;
     136              :   // const size_t fNSSPsPerAPA = 4;
     137              :   const size_t fNChansPerSSP = 12;
     138              :   const size_t fNAPAs = 6;
     139              : 
     140              :   // control behavior in case we need to fall back to default behavior
     141              : 
     142              :   size_t fBadCrateNumberWarningsIssued;
     143              :   size_t fBadSlotNumberWarningsIssued;
     144              :   size_t fBadFiberNumberWarningsIssued;
     145              :   size_t fSSPBadChannelNumberWarningsIssued;
     146              : 
     147              :   size_t fASICWarningsIssued;
     148              :   size_t fASICChanWarningsIssued;
     149              : 
     150              :   // TPC Maps
     151              :   unsigned int farrayCsfcToOffline[6][5][4][128]; // implement as an array.  Do our own bounds checking
     152              : 
     153              :   // lookup tables as functions of offline channel number
     154              : 
     155              :   unsigned int fvAPAMap[15360];           // APA(=crate)
     156              :   unsigned int fvWIBMap[15360];           // WIB(slot)
     157              :   unsigned int fvFEMBMap[15360];          // FEMB(fiber)
     158              :   unsigned int fvFEMBChannelMap[15360];   // FEMB internal channel
     159              :   unsigned int fvStreamChannelMap[15360]; // RCE(FELIX) internal channel
     160              :   unsigned int fvSlotIdMap[15360];        // global WIB(slot) ID
     161              :   unsigned int fvFiberIdMap[15360];       // global FEMB(fiber) ID
     162              :   unsigned int fvChipMap[15360];          // Chip
     163              :   unsigned int fvChipChannelMap[15360];   // Chip internal channel
     164              :   unsigned int fvASICMap[15360];          // ASIC
     165              :   unsigned int fvASICChannelMap[15360];   // ASIC internal channel
     166              :   unsigned int fvPlaneMap[15360];         // Plane type
     167              : 
     168              :   unsigned int fFELIXarrayCsfcToOffline[6][5][4][128]; // implement as an array.  Do our own bounds checking
     169              :   unsigned int fFELIXvAPAMap[15360];                   // APA(=crate)
     170              :   unsigned int fFELIXvWIBMap[15360];                   // WIB(slot)
     171              :   unsigned int fFELIXvFEMBMap[15360];                  // FEMB(fiber)
     172              :   unsigned int fFELIXvFEMBChannelMap[15360];           // FEMB internal channel
     173              :   unsigned int fFELIXvStreamChannelMap[15360];         // RCE(FELIX) internal channel
     174              :   unsigned int fFELIXvSlotIdMap[15360];                // global WIB(slot) ID
     175              :   unsigned int fFELIXvFiberIdMap[15360];               // global FEMB(fiber) ID
     176              :   unsigned int fFELIXvChipMap[15360];                  // Chip
     177              :   unsigned int fFELIXvChipChannelMap[15360];           // Chip internal channel
     178              :   unsigned int fFELIXvASICMap[15360];                  // ASIC
     179              :   unsigned int fFELIXvASICChannelMap[15360];           // ASIC internal channel
     180              :   unsigned int fFELIXvPlaneMap[15360];                 // Plane type
     181              : 
     182              :   unsigned int
     183              :     fvInstalledAPA[6]; // APA as installed.  This array maps the two conventions.  Argument = offline, value = installed
     184              :   unsigned int fvTPCSet_VsInstalledAPA[6]; // inverse map
     185              : 
     186              :   // SSP Maps
     187              : 
     188              :   unsigned int farraySSPOnlineToOffline[288]; // all accesses to this array need to be bounds-checked first.
     189              :   unsigned int farraySSPOfflineToOnline[288];
     190              :   unsigned int fvSSPAPAMap[288];
     191              :   unsigned int fvSSPWithinAPAMap[288]; // Global SSP number 11, 12, 21, etc.
     192              :   unsigned int fvSSPGlobalMap[288];    // Also global SSP number 11, 12, 21, etc.
     193              :   unsigned int fvSSPChanWithinSSPMap[288];
     194              :   unsigned int fvOpDetNoMap[288]; // PDS op det number
     195              : 
     196              :   size_t count_bits(size_t i); // returns the number of bits set, for use in determing whether to print a warning out
     197              : 
     198              :   //-----------------------------------------------
     199              : 
     200            0 :   void check_offline_channel(unsigned int offlineChannel) const
     201              :   {
     202            0 :     if (offlineChannel >= fNChans) {
     203            0 :       throw std::logic_error("Offline TPC Channel Number out of range");
     204              :     }
     205            0 :   };
     206              : 
     207            0 :   void SSP_check_offline_channel(unsigned int offlineChannel) const
     208              :   {
     209            0 :     if (offlineChannel >= fNSSPChans) {
     210            0 :       throw std::logic_error("Offline SSP Channel Number out of range");
     211              :     }
     212            0 :   };
     213              : };
     214              : 
     215              : } // namespace detchannelmaps
     216              : } // namespace dunedaq
     217              : 
     218              : #endif // DETCHANNELMAPS_PDSPCHANNELMAPSERVICE_HPP_
        

Generated by: LCOV version 2.0-1