Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:36

0001 #ifndef EventFilter_CSCRawToDigi_CSCDDUTrailer_h
0002 #define EventFilter_CSCRawToDigi_CSCDDUTrailer_h
0003 
0004 #include <iostream>
0005 #include <cstdint>
0006 #include <cstring>  // bzero
0007 #include "DataFormats/CSCDigi/interface/CSCDDUStatusDigi.h"
0008 
0009 /** documented at  http://www.physics.ohio-state.edu/~cms/ddu/ddu2.html
0010  */
0011 
0012 class CSCDDUTrailer {
0013 public:
0014   CSCDDUTrailer() {
0015     bzero(this, sizeInWords() * 2);
0016     trailer2_1 = trailer2_2 = trailer2_4 = 0x8000;
0017     trailer2_3 = 0xFFFF;
0018   }
0019   CSCDDUTrailer(const CSCDDUStatusDigi& digi) { memcpy(this, digi.trailer(), sizeInWords() * 2); }
0020 
0021   void setFromBuffer(uint16_t const* buf) { memcpy(this, buf, sizeInWords() * 2); }
0022 
0023   static unsigned sizeInWords() { return 12; }
0024 
0025   bool check() const {
0026     //std::cout << std:: hex << "DDUTRAILER CHECK " << trailer2_1 << " "
0027     //      << trailer2_2  << " " << trailer2_3 << " "
0028     //      << trailer2_4 << std:: dec << std::endl;
0029     return trailer2_1 == 0x8000 && trailer2_2 == 0x8000 && trailer2_3 == 0xFFFF && trailer2_4 == 0x8000;
0030   }
0031 
0032   unsigned short* data() { return (unsigned short*)this; }
0033 
0034   //These are accessors to use for calling private members
0035 
0036   unsigned errorstat() const { return errorstat_; }
0037   unsigned wordcount() const { return word_count_; }
0038   void setWordCount(unsigned wordcount) { word_count_ = wordcount; }
0039   //@@ Tim: This seems wrong to me so just pull it
0040   //@@  void setDMBDAV(int dmbId) {dmb_full_ |= (1 << dmbId);}
0041   unsigned dmb_warn() const { return dmb_warn_; }
0042   unsigned dmb_full() const { return dmb_full_; }
0043   unsigned reserved() const { return whatever; }
0044 
0045 private:
0046   /// should be 8000/8000/FFFF/8000
0047   unsigned trailer2_1 : 16;
0048   unsigned trailer2_2 : 16;
0049   unsigned trailer2_3 : 16;
0050   unsigned trailer2_4 : 16;
0051 
0052   /// Active DMB Count (4 bits)
0053   unsigned dmb_warn_ : 16;
0054   unsigned dmb_full_ : 16;
0055   unsigned errorstat_ : 32;
0056 
0057   // DDU2004
0058   //  unsigned reserved_bits     : 4;
0059   //unsigned ddu_tts_status    : 4;
0060   //unsigned event_status      : 8;
0061   //unsigned event_crc         : 16;
0062   //
0063 
0064   //DDU2000
0065   //unsigned s_link_status  : 4;
0066   //unsigned crc_check_word : 16;
0067   //unsigned whatever       : 4;
0068   //unsigned event_status   : 8;
0069   //
0070 
0071   //the following bits change their meaning in DDU2004
0072   unsigned word1 : 4;
0073   unsigned word2 : 4;
0074   unsigned word3 : 4;
0075   unsigned word4 : 4;
0076 
0077   unsigned word5 : 4;
0078   unsigned word6 : 4;
0079   unsigned word7 : 4;
0080   unsigned word8 : 4;
0081 
0082   /// in 64-bit words
0083   /// DDU_WC = (6 + 25*N_ts*nCFEB + 3*nDMB)
0084   unsigned word_count_ : 24;
0085   unsigned whatever : 4;
0086   ///constant, should be 1010
0087   unsigned cms_directive_0xA : 4;
0088 };
0089 #endif