File indexing completed on 2024-04-06 12:10:22
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef EventFilter_CSCRawToDigi_CSCTMBData_h
0009 #define EventFilter_CSCRawToDigi_CSCTMBData_h
0010
0011 #include "EventFilter/CSCRawToDigi/interface/CSCTMBHeader.h"
0012 #include "EventFilter/CSCRawToDigi/interface/CSCComparatorData.h"
0013 #include "EventFilter/CSCRawToDigi/interface/CSCTMBScope.h"
0014 #include "EventFilter/CSCRawToDigi/interface/CSCTMBMiniScope.h"
0015 #include "EventFilter/CSCRawToDigi/interface/CSCTMBBlockedCFEB.h"
0016 #include "EventFilter/CSCRawToDigi/interface/CSCTMBTrailer.h"
0017 #include "EventFilter/CSCRawToDigi/interface/CSCRPCData.h"
0018 #include "EventFilter/CSCRawToDigi/interface/CSCGEMData.h"
0019 #include <bitset>
0020 #include <boost/dynamic_bitset.hpp>
0021 #ifndef LOCAL_UNPACK
0022 #include <atomic>
0023 #endif
0024
0025 class CSCTMBData {
0026 public:
0027 CSCTMBData();
0028 CSCTMBData(int firmwareVersion, int firmwareRevision, int ncfebs = 5);
0029 ~CSCTMBData();
0030 CSCTMBData(const uint16_t* buf);
0031 CSCTMBData(const CSCTMBData& data);
0032 int UnpackTMB(const uint16_t* buf);
0033
0034 bool checkSize() const;
0035 static void setDebug(const bool value) { debug = value; }
0036 short unsigned int CWordCnt() const { return cWordCnt; }
0037 int getCRC() const { return theTMBTrailer.crc22(); }
0038 const unsigned short size() const { return size_; }
0039
0040 CSCTMBHeader* tmbHeader() { return &theTMBHeader; }
0041 CSCComparatorData* comparatorData() { return &theComparatorData; }
0042
0043 bool hasTMBScope() const { return theTMBScopeIsPresent; }
0044 CSCTMBScope& tmbScope() const;
0045
0046 bool hasTMBMiniScope() const { return theTMBMiniScopeIsPresent; }
0047 CSCTMBMiniScope& tmbMiniScope() const;
0048
0049 bool hasTMBBlockedCFEB() const { return theBlockedCFEBIsPresent; }
0050 CSCTMBBlockedCFEB& tmbBlockedCFEB() const;
0051 CSCTMBTrailer* tmbTrailer() { return &theTMBTrailer; }
0052
0053 bool hasRPC() const { return theRPCDataIsPresent; }
0054 CSCRPCData* rpcData() { return &theRPCData; }
0055 bool hasGEM() const { return theGEMDataIsPresent; }
0056 CSCGEMData* gemData();
0057
0058
0059
0060
0061 boost::dynamic_bitset<> pack();
0062
0063 std::bitset<22> calCRC22(const std::vector<std::bitset<16> >& datain);
0064 std::bitset<22> nextCRC22_D16(const std::bitset<16>& D, const std::bitset<22>& C);
0065 int TMBCRCcalc();
0066
0067
0068 static void selfTest();
0069
0070 private:
0071
0072
0073 const uint16_t* theOriginalBuffer;
0074
0075
0076 unsigned theB0CLine;
0077 unsigned theE0FLine;
0078
0079 CSCTMBHeader theTMBHeader;
0080 CSCComparatorData theComparatorData;
0081 CSCRPCData theRPCData;
0082 CSCGEMData theGEMData;
0083
0084 bool theTMBScopeIsPresent;
0085 CSCTMBScope* theTMBScope;
0086
0087
0088
0089 bool theTMBMiniScopeIsPresent;
0090 CSCTMBMiniScope* theTMBMiniScope;
0091
0092 bool theBlockedCFEBIsPresent;
0093 CSCTMBBlockedCFEB* theTMBBlockedCFEB;
0094
0095 CSCTMBTrailer theTMBTrailer;
0096 #ifdef LOCAL_UNPACK
0097 static bool debug;
0098 #else
0099 static std::atomic<bool> debug;
0100 #endif
0101 unsigned short size_;
0102 unsigned short cWordCnt;
0103 bool theRPCDataIsPresent;
0104 bool theGEMDataIsPresent;
0105 };
0106
0107 #endif