Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:20

0001 #ifndef DataFormats_HGCalDigis_HGCalElectronicsId_h
0002 #define DataFormats_HGCalDigis_HGCalElectronicsId_h
0003 
0004 #include <iostream>
0005 #include <ostream>
0006 #include <cstdint>
0007 
0008 /**
0009    @class HGCalElectronicsId
0010    @short wrapper for a 32b data word identifying a readout channel in the raw data
0011    The format is the following:
0012    Reserved: b'[28,31]
0013    FED ID: b'[18,27]
0014    Capture Block ID: b'[14,17]
0015    ECON-D idx: b'[10,13]
0016    ECON-D eRx: b'[6,9]
0017    1/2 ROC channel number: b'[0-5]
0018  */
0019 
0020 class HGCalElectronicsId {
0021 public:
0022   enum HGCalElectronicsIdMask {
0023     kFEDIDMask = 0x3ff,
0024     kCaptureBlockMask = 0xf,
0025     kECONDIdxMask = 0xf,
0026     kECONDeRxMask = 0xf,
0027     kHalfROCChannelMask = 0x3f
0028   };
0029   enum HGCalElectronicsIdShift {
0030     kFEDIDShift = 18,
0031     kCaptureBlockShift = 14,
0032     kECONDIdxShift = 10,
0033     kECONDeRxShift = 6,
0034     kHalfROCChannelShift = 0
0035   };
0036 
0037   /**
0038      @short CTOR
0039   */
0040   HGCalElectronicsId() : value_(0) {}
0041   explicit HGCalElectronicsId(
0042       uint16_t fedid, uint8_t captureblock, uint8_t econdidx, uint8_t econderx, uint8_t halfrocch);
0043   explicit HGCalElectronicsId(uint32_t value) : value_(value) {}
0044 
0045   /**
0046      @short getters
0047   */
0048   uint32_t operator()() const { return value_; }
0049   bool operator<(const HGCalElectronicsId& oth) const { return value_ < oth.value_; }
0050   uint32_t raw() const { return value_; }
0051   uint16_t fedId() const;
0052   uint8_t captureBlock() const;
0053   uint8_t econdIdx() const;
0054   uint8_t econdeRx() const;
0055   uint8_t halfrocChannel() const;
0056 
0057   void print(std::ostream& out = std::cout) const {
0058     out << "Raw=0x" << std::hex << raw() << std::dec << std::endl
0059         << "\tFED-ID: " << (uint32_t)fedId() << " Capture Block: " << (uint32_t)captureBlock()
0060         << " ECON-D idx: " << (uint32_t)econdIdx() << " eRx: " << (uint32_t)econdeRx()
0061         << " 1/2 ROC ch.: " << (uint32_t)halfrocChannel() << std::endl;
0062   }
0063 
0064 private:
0065   // a 32-bit word
0066   uint32_t value_;
0067 };
0068 
0069 #endif