Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:29

0001 #ifndef CTPPS_CTPPSRawToDigi_RPixErrorChecker_h
0002 #define CTPPS_CTPPSRawToDigi_RPixErrorChecker_h
0003 /** \class RPixErrorChecker
0004  *
0005  *  RPix == CTPPS Pixel detector (Roman Pot Pixels)
0006  */
0007 
0008 #include "DataFormats/CTPPSDigi/interface/CTPPSPixelDataError.h"
0009 
0010 #include <vector>
0011 #include <map>
0012 
0013 class FEDRawData;
0014 
0015 enum State { InvalidLinkId, InvalidROCId, InvalidPixelId, Unknown };
0016 
0017 class RPixErrorChecker {
0018 public:
0019   typedef uint32_t Word32;
0020   typedef uint64_t Word64;
0021 
0022   typedef std::vector<CTPPSPixelDataError> DetErrors;
0023   typedef std::map<uint32_t, DetErrors> Errors;
0024 
0025   static constexpr int CRC_bits = 1;
0026   static constexpr int ROC_bits = 5;
0027   static constexpr int DCOL_bits = 5;
0028   static constexpr int PXID_bits = 8;
0029   static constexpr int ADC_bits = 8;
0030   static constexpr int OMIT_ERR_bits = 1;
0031 
0032   static constexpr int CRC_shift = 2;
0033   static constexpr int ADC_shift = 0;
0034   static constexpr int PXID_shift = ADC_shift + ADC_bits;
0035   static constexpr int DCOL_shift = PXID_shift + PXID_bits;
0036   static constexpr int ROC_shift = DCOL_shift + DCOL_bits;
0037   static constexpr int OMIT_ERR_shift = 20;
0038 
0039   static constexpr Word32 dummyDetId = 0xffffffff;
0040 
0041   static constexpr Word64 CRC_mask = ~(~RPixErrorChecker::Word64(0) << CRC_bits);
0042   static constexpr Word32 ERROR_mask = ~(~RPixErrorChecker::Word32(0) << ROC_bits);
0043   static constexpr Word32 OMIT_ERR_mask = ~(~RPixErrorChecker::Word32(0) << OMIT_ERR_bits);
0044 
0045 public:
0046   RPixErrorChecker();
0047 
0048   void setErrorStatus(bool errorStatus);
0049 
0050   bool checkCRC(bool& errorsInEvent, int fedId, const Word64* trailer, Errors& errors) const;
0051 
0052   bool checkHeader(bool& errorsInEvent, int fedId, const Word64* header, Errors& errors) const;
0053 
0054   bool checkTrailer(bool& errorsInEvent, int fedId, unsigned int nWords, const Word64* trailer, Errors& errors) const;
0055 
0056   bool checkROC(bool& errorsInEvent, int fedId, uint32_t iD, const Word32& errorWord, Errors& errors) const;
0057 
0058   void conversionError(int fedId, uint32_t iD, const State& state, const Word32& errorWord, Errors& errors) const;
0059 
0060 private:
0061   bool includeErrors_;
0062 };
0063 
0064 #endif