Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //_______________________________________
0002 //
0003 //  Class to group TMB data
0004 //  CSCTMBData 9/18/03  B.Mohr
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   /// sees if the size adds up to the word count
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   /// check this before using TMB Scope
0043   bool hasTMBScope() const { return theTMBScopeIsPresent; }
0044   CSCTMBScope& tmbScope() const;
0045   /// check this before using TMB mini scope
0046   bool hasTMBMiniScope() const { return theTMBMiniScopeIsPresent; }
0047   CSCTMBMiniScope& tmbMiniScope() const;
0048   /// check this before TMB Block CFEB
0049   bool hasTMBBlockedCFEB() const { return theBlockedCFEBIsPresent; }
0050   CSCTMBBlockedCFEB& tmbBlockedCFEB() const;
0051   CSCTMBTrailer* tmbTrailer() { return &theTMBTrailer; }
0052   /// check this before using RPC
0053   bool hasRPC() const { return theRPCDataIsPresent; }
0054   CSCRPCData* rpcData() { return &theRPCData; }
0055   bool hasGEM() const { return theGEMDataIsPresent; }
0056   CSCGEMData* gemData();
0057 
0058   /// not const because it sets size int TMBTrailer
0059 
0060   /// this method is for digi2raw
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   /// tests packing
0068   static void selfTest();
0069 
0070 private:
0071   ///@@ not sure what this means for simulation.  I keep this
0072   /// around so we can calculate CRCs
0073   const uint16_t* theOriginalBuffer;
0074   /// CRC calc needs to know where 0x6B0C and 0x6E0F lines were
0075   /// we want to put off CRC calc until needed
0076   unsigned theB0CLine;
0077   unsigned theE0FLine;
0078 
0079   CSCTMBHeader theTMBHeader;
0080   CSCComparatorData theComparatorData;
0081   CSCRPCData theRPCData;
0082   CSCGEMData theGEMData;
0083   /// The TMB scope is not present in most of data hence its dynamic
0084   bool theTMBScopeIsPresent;
0085   CSCTMBScope* theTMBScope;
0086 
0087   /// The TMB MiniScope must presen in every event, hovewer make it dynamic
0088   /// as for the main scope
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