Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef EventFilter_CSCRawToDigi_CSCDMBHeader2013_h
0002 #define EventFilter_CSCRawToDigi_CSCDMBHeader2013_h
0003 
0004 /*
0005  DMB-DDU 2013 Header/Trailer bit definitions (some bits get repeated for bit error mitigation)
0006 
0007     DMB_L1A:    L1A Event Number, count from DMB
0008     DMB_BXN:    Bunch Crossing Number, count from DMB
0009     TMB_DAV:    non-zero indicates TMB data exists for this event
0010     ALCT_DAV:    non-zero indicates ALCT data exists for this event
0011     CFEB_CLCT_SENT:    indicates which CFEBs should have sent data to DMB
0012     CFEB_DAV:    indicates which CFEBs have sent data to DMB
0013     CLCT-DAV-Mismatch:    the CFEB_DAVs do not match the CLCTs sent
0014     DMB_CRATE:    peripheral crate ID from DMB
0015     DMB_ID:    board number of DMB
0016     CFEB_MOVLP:    the time sample for this event has multiple overlaps with samples from previous events
0017     DMB-CFEB-Sync:    bits used for DMB-CFEB synchronization check
0018     ALCT_HALF:    zero indicates that the ALCT FIFO on the DMB is half-full
0019     TMB_HALF:    zero indicates that the TMB FIFO on the DMB is half-full
0020     CFEB_HALF:    zero indicates that the CFEB FIFO on the DMB is half-full
0021     DMB_L1PIPE:    number of L1A Events backed-up in the DMB
0022     ALCT_EMPTY:    one indicates that the ALCT FIFO on the DMB is empty
0023     TMB_EMPTY:    one indicates that the TMB FIFO on the DMB is empty
0024     CFEB_EMPTY:    one indicates that the CFEB FIFO on the DMB is empty
0025     ALCT_Start_Timeout:    indicates that the start of ALCT data was not detected within the time-out period
0026     TMB_Start_Timeout:    indicates that the start of TMB data was not detected within the time-out period
0027     CFEB_Start_Timeout:    indicates that the start of CFEB data was not detected within the time-out period.
0028     CFEB_End_Timeout:    indicates that the end of CFEB data was not detected within the time-out period
0029     ALCT_End_Timeout:    indicates that the end of ALCT data was not detected within the time-out period
0030     TMB_End_Timeout:    indicates that the end of TMB data was not detected within the time-out period
0031     ALCT_FULL:    one indicates that the ALCT FIFO on the DMB is full
0032     TMB_FULL:    one indicates that the TMB FIFO on the DMB is full
0033     CFEB_FULL:    one indicates that the CFEB FIFO on the DMB is full
0034     DMB_CRC:    each DMB generates a 22-bit CRC that encompasses all CSC data from the first 9-code to the last F-code in the event
0035  */
0036 
0037 #include <cassert>
0038 #include <iosfwd>
0039 #include <cstring>  // bzero
0040 #include "DataFormats/CSCDigi/interface/CSCDMBStatusDigi.h"
0041 #include "EventFilter/CSCRawToDigi/interface/CSCVDMBHeaderFormat.h"
0042 
0043 struct CSCDMBHeader2013 : public CSCVDMBHeaderFormat {
0044   // public:
0045 
0046   CSCDMBHeader2013();
0047 
0048   CSCDMBHeader2013(const uint16_t *buf);
0049   /*
0050   CSCDMBHeader2013(const CSCDMBStatusDigi & digi)
0051     {
0052       memcpy(this, digi.header(), sizeInWords()*2);
0053     }
0054 */
0055   bool cfebAvailable(unsigned icfeb) override;
0056 
0057   void addCFEB(int icfeb) override;
0058   void addNCLCT() override;
0059   void addNALCT() override;
0060   void setBXN(int bxn) override;
0061   void setL1A(int l1a) override;
0062   void setL1A24(int l1a) override;
0063   void setCrateAddress(int crate, int dmbId) override;
0064   void setdmbID(int newDMBID) override { bits.dmb_id = newDMBID; }
0065   void setdmbVersion(unsigned int version) override { bits.fmt_version = (version < 4) ? version : 0; }
0066 
0067   unsigned cfebActive() const override { return bits.cfeb_clct_sent; }
0068   unsigned crateID() const override;
0069   unsigned dmbID() const override;
0070   unsigned bxn() const override;
0071   unsigned bxn12() const override;
0072   unsigned l1a() const override;
0073   unsigned l1a24() const override;
0074   unsigned cfebAvailable() const override;
0075   unsigned nalct() const override;
0076   unsigned nclct() const override;
0077   unsigned cfebMovlp() const override;
0078   unsigned dmbCfebSync() const override;
0079   unsigned activeDavMismatch() const override;
0080   unsigned format_version() const override;
0081 
0082   unsigned sizeInWords() const override;
0083 
0084   bool check() const override;
0085 
0086   unsigned short *data() override { return (unsigned short *)(&bits); }
0087   unsigned short *data() const override { return (unsigned short *)(&bits); }
0088 
0089   //ostream & operator<<(ostream &, const CSCDMBHeader &);
0090 
0091   // private:
0092 
0093   struct {
0094     /// 1st Header word
0095     unsigned dmb_l1a_lowo : 12;  /// DMB_L1A[11:0]
0096     unsigned newddu_code_1 : 4;  /// constant, should be 1001
0097 
0098     /// 2nd Header word
0099     unsigned dmb_l1a_hiwo : 12;  /// DMB_L1A[23:12]
0100     unsigned newddu_code_2 : 4;  /// constant, should be 1001
0101 
0102     /// 3rd Header word
0103     unsigned cfeb_clct_sent : 7;     /// CFEB_CLCT_SENT(7:1)
0104     unsigned clct_dav_mismatch : 1;  /// CLCT-DAV-Mismatch(1)
0105     unsigned fmt_version : 2;        /// Fmt_Vers(1:0)
0106     unsigned tmb_dav : 1;            /// TMB_DAV(1)
0107     unsigned alct_dav : 1;           /// ALCT_DAV(1)
0108     unsigned newddu_code_3 : 4;      /// constant, should be 1001
0109 
0110     /// 4th Header word
0111     unsigned dmb_bxn1 : 12;      /// DMB_BXN[11:0]
0112     unsigned newddu_code_4 : 4;  /// constant, should be 1001
0113 
0114     /// 5th Header word
0115     unsigned cfeb_dav : 7;                /// CFEB_DAV(7:1)
0116     unsigned clct_dav_mismatch_copy : 1;  /// CLCT-DAV-Mismatch(1)
0117     unsigned fmt_version_copy : 2;        /// Fmt_Vers(1:0)
0118     unsigned tmb_dav_copy : 1;            /// TMB_DAV(1)
0119     unsigned alct_dav_copy : 1;           /// ALCT_DAV(1)
0120     unsigned ddu_code_1 : 4;              /// constant, should be '1010'
0121 
0122     /// 6th Header word
0123     unsigned dmb_id : 4;      /// DMB_ID(4)
0124     unsigned dmb_crate : 8;   /// DMB_CRATE(8)
0125     unsigned ddu_code_2 : 4;  /// constant, should be '1010'
0126 
0127     /// 7th Header word
0128     unsigned dmb_bxn : 5;         /// DMB_BXN[4:0]
0129                                   /// the time sample for this event has multiple overlaps
0130                                   /// with samples from previous events
0131     unsigned cfeb_movlp : 5;      /// CFEB_MOVLP(5:1)
0132     unsigned tmb_dav_copy2 : 1;   /// TMB_DAV(1)
0133     unsigned alct_dav_copy2 : 1;  /// ALCT_DAV(1)
0134     unsigned ddu_code_3 : 4;      /// constant, should be '1010'
0135 
0136     /// 8th Header word
0137     unsigned dmb_l1a : 5;                  /// DMB_L1A[4:0]
0138     unsigned clct_dav_mismatch_copy2 : 1;  /// CLCT-DAV-Mismatch(1)
0139     unsigned fmt_version_copy2 : 2;        /// Fmt_Vers(1:0)
0140     unsigned dmb_cfeb_sync : 4;            /// DMB-CFEB-Sync[3:0]
0141     unsigned ddu_code_4 : 4;               /// constant, should be '1010'
0142   } bits;
0143 };
0144 
0145 #endif