Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-04 22:44:55

0001 #ifndef DataFormats_SiPixelDigi_interface_SiPixelDigiConstants
0002 #define DataFormats_SiPixelDigi_interface_SiPixelDigiConstants
0003 
0004 #include "FWCore/Utilities/interface/typedefs.h"
0005 #include <cstdint>
0006 
0007 using Word64 = cms_uint64_t;
0008 using Word32 = cms_uint32_t;
0009 
0010 namespace sipixelconstants {
0011   constexpr cms_uint32_t dummyDetId = 0xffffffff;
0012 
0013   constexpr uint32_t CRC_bits = 1;
0014   constexpr uint32_t DCOL_bits = 5;  // double column
0015   constexpr uint32_t PXID_bits = 8;  // pixel id
0016   constexpr uint32_t ADC_bits = 8;
0017   constexpr uint32_t OMIT_ERR_bits = 1;
0018   // GO BACK TO OLD VALUES. THE 48-CHAN FED DOES NOT NEED A NEW FORMAT 28/9/16 d.k.
0019   constexpr uint32_t LINK_bits = 6;  // 7;
0020   constexpr uint32_t ROC_bits = 5;   // 4;
0021 
0022   constexpr uint32_t CRC_shift = 2;
0023   constexpr uint32_t ADC_shift = 0;
0024   constexpr uint32_t PXID_shift = ADC_shift + ADC_bits;
0025   constexpr uint32_t DCOL_shift = PXID_shift + PXID_bits;
0026   constexpr uint32_t ROC_shift = DCOL_shift + DCOL_bits;
0027   constexpr uint32_t LINK_shift = ROC_shift + ROC_bits;
0028   constexpr uint32_t OMIT_ERR_shift = 20;
0029 
0030   constexpr uint64_t CRC_mask = ~(~Word64(0) << CRC_bits);
0031   constexpr uint32_t ERROR_mask = ~(~Word32(0) << ROC_bits);
0032   constexpr uint32_t LINK_mask = ~(~Word32(0) << LINK_bits);
0033   constexpr uint32_t ROC_mask = ~(~Word32(0) << ROC_bits);
0034   constexpr uint32_t OMIT_ERR_mask = ~(~Word32(0) << OMIT_ERR_bits);
0035   constexpr uint32_t DCOL_mask = ~(~Word32(0) << DCOL_bits);
0036   constexpr uint32_t PXID_mask = ~(~Word32(0) << PXID_bits);
0037   constexpr uint32_t ADC_mask = ~(~Word32(0) << ADC_bits);
0038 
0039   // Special for layer 1 bpix rocs 6/9/16 d.k. THIS STAYS.
0040   inline namespace phase1layer1 {
0041     constexpr uint32_t COL_bits1_l1 = 6;
0042     constexpr uint32_t ROW_bits1_l1 = 7;
0043     constexpr uint32_t ROW_shift = ADC_shift + ADC_bits;
0044     constexpr uint32_t COL_shift = ROW_shift + ROW_bits1_l1;
0045     constexpr uint32_t COL_mask = ~(~Word32(0) << COL_bits1_l1);
0046     constexpr uint32_t ROW_mask = ~(~Word32(0) << ROW_bits1_l1);
0047   }  // namespace phase1layer1
0048 
0049   // constexpr functions are available in device code (GPU) as well
0050   inline namespace functions {
0051     inline constexpr uint32_t getLink(uint32_t ww) { return ((ww >> LINK_shift) & LINK_mask); }
0052     inline constexpr uint32_t getROC(uint32_t ww) { return ((ww >> ROC_shift) & ROC_mask); }
0053     inline constexpr uint32_t getADC(uint32_t ww) { return ((ww >> ADC_shift) & ADC_mask); }
0054     inline constexpr uint32_t getCol(uint32_t ww) { return ((ww >> COL_shift) & COL_mask); }
0055     inline constexpr uint32_t getRow(uint32_t ww) { return ((ww >> ROW_shift) & ROW_mask); }
0056     inline constexpr uint32_t getDCol(uint32_t ww) { return ((ww >> DCOL_shift) & DCOL_mask); }
0057     inline constexpr uint32_t getPxId(uint32_t ww) { return ((ww >> PXID_shift) & PXID_mask); }
0058     inline constexpr uint32_t removeADC(uint32_t ww) { return (ww & ~(ADC_mask << ADC_shift)); }
0059   }  // namespace functions
0060 }  // namespace sipixelconstants
0061 
0062 #endif  // DataFormats_SiPixelDigi_interface_SiPixelDigiConstants