Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-04 04:04:19

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'[29,31]
0013    z side: b'[28]
0014    Local FED ID: b'[18,27]
0015    Capture Block ID: b'[14,17]
0016    ECON-D idx: b'[10,13]
0017    ECON-D eRx: b'[6,9]
0018    1/2 ROC channel number: b'[0-5]
0019  */
0020 
0021 class HGCalElectronicsId {
0022 public:
0023   enum HGCalElectronicsIdMask {
0024     kZsideMask = 0x1,
0025     kLocalFEDIDMask = 0x3ff,
0026     kCaptureBlockMask = 0xf,
0027     kECONDIdxMask = 0xf,
0028     kECONDeRxMask = 0xf,
0029     kHalfROCChannelMask = 0x3f
0030   };
0031   enum HGCalElectronicsIdShift {
0032     kZsideShift = 28,
0033     kLocalFEDIDShift = 18,
0034     kCaptureBlockShift = 14,
0035     kECONDIdxShift = 10,
0036     kECONDeRxShift = 6,
0037     kHalfROCChannelShift = 0
0038   };
0039 
0040   /**
0041      @short CTOR
0042   */
0043   HGCalElectronicsId() : value_(0) {}
0044   explicit HGCalElectronicsId(
0045       bool zside, uint16_t localfedid, uint8_t captureblock, uint8_t econdidx, uint8_t econderx, uint8_t halfrocch);
0046   explicit HGCalElectronicsId(uint32_t value) : value_(value) {}
0047 
0048   /**
0049      @short getters
0050   */
0051 
0052   uint32_t operator()() const { return value_; }
0053   bool operator<(const HGCalElectronicsId& oth) const { return value_ < oth.value_; }
0054   bool operator==(const HGCalElectronicsId& oth) const { return value_ == oth.value_; }
0055   uint32_t raw() const { return value_; }
0056   bool zSide() const;
0057   uint16_t localFEDId() const;
0058   uint8_t captureBlock() const;
0059   uint8_t econdIdx() const;
0060   uint8_t econdeRx() const;
0061   uint8_t halfrocChannel() const;
0062   uint8_t rocChannel() const;
0063   uint8_t cmWord() const;
0064   bool isCM() const;
0065   void print(std::ostream& out = std::cout) const {
0066     out << "Raw=0x" << std::hex << raw() << std::dec << std::endl
0067         << "\tLocal FED-ID: " << (uint32_t)localFEDId() << " Capture Block: " << (uint32_t)captureBlock()
0068         << " ECON-D idx: " << (uint32_t)econdIdx() << " eRx: " << (uint32_t)econdeRx()
0069         << " 1/2 ROC ch.: " << (uint32_t)halfrocChannel() << " isCM=" << isCM() << " zSide=" << zSide() << std::endl;
0070   }
0071 
0072 private:
0073   // a 32-bit word
0074   uint32_t value_;
0075 };
0076 
0077 #endif