Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CSCSP_MEblock_h
0002 #define CSCSP_MEblock_h
0003 
0004 #include <cstring>
0005 
0006 class CSCSP_MEblock {
0007 private:
0008   /////// word 1 ///////
0009   // higher pattern number - straighter high-momentum tracks with more layers hit, also encodes half/di-strip indication
0010   unsigned clct_pattern_number : 4;
0011   unsigned quality_ : 4;       // the more hits the higher LCT Quality
0012   unsigned wire_group_id : 7;  // radial position of the pattern within the chamber (0-111)
0013   unsigned zero_1 : 1;         // format specific
0014   /////// word 2 ///////
0015   unsigned
0016       clct_pattern_id : 8;  // azimuthal position ot the pattern at the third (key) layer: (0-159 for half-strips 0-39 for di-strips)
0017   unsigned csc_id : 4;      // chamber # (1-9)
0018   unsigned left_right : 1;  // L/R - track is heading towards lower/higher strip number
0019   unsigned bx0_ : 1;        // BX counter least significant bit
0020   unsigned bc0_ : 1;        // BC Zero flag marks that next BXN = 0
0021   unsigned zero_2 : 1;      // format specific
0022   /////// word 3 ///////
0023   unsigned me_bxn : 12;              // LCT arrival time picked from a local 12-bit BX Counter, that runs at link timing
0024   unsigned receiver_status_er1 : 1;  // receiver status for the frame 1 (see below)
0025   unsigned receiver_status_dv1 : 1;  // receiver status for the frame 1 (see below)
0026   unsigned
0027       aligment_fifo_full : 1;  // Alignment FIFO Full Flag, should be 0, if AF has been initialized successfully by L1Reset
0028   unsigned zero_3 : 1;         // format specific
0029   /////// word 4 ///////
0030   unsigned link_id : 2;              // Link number (1-3)         [reported by MPC on every L1 Reset]
0031   unsigned mpc_id : 6;               // MPC Crate number (0-63)   [reported by MPC on every L1 Reset]
0032   unsigned err_prop_cnt : 4;         // accumulates the "Receive Error Propagation" occurrences since last L1Reset
0033   unsigned receiver_status_er2 : 1;  // receiver status for the frame 2 (see below)
0034   unsigned receiver_status_dv2 : 1;  // receiver status for the frame 2 (see below)
0035   // Alignment FIFO Empty Flag, should be 0, if AF has been initialized successfully by L1Reset
0036   unsigned aligment_fifo_empty : 1;
0037   unsigned zero_4 : 1;  // format specific
0038 
0039   // Optical Receiver Status options:
0040   // {receiver_status_dv, receiver_status_er} = {Receive Data Valid, Receive Error}
0041   // {0,0} - Receive Idle Character;
0042   // {0,1} - Receive Carrier Extend;
0043   // {1,0} - Receive Normal Data Character <- expect to have;
0044   // {1,1} - Receive Error Propagation;
0045 
0046   // Other data members logically belong to ME Block record,
0047   //  but physically are located in Data Block Header, which implementation is:
0048   friend class CSCSPRecord;
0049   friend class CSCTFPacker;
0050   // Let this class set following data memebers:
0051   unsigned int tbin_;           // time bin, that this ME block belongs to in global SP record
0052   unsigned int valid_pattern;   // LCT valid bit
0053   unsigned int sync_error;      // LCT synchronization error bit
0054   unsigned int sync_modified;   // LCT modified synchronization error bit
0055   unsigned int alignment_fifo;  // AF error
0056   unsigned int bxBit;           // monitors the ALCT/TMB/MPC timing
0057   unsigned int spInput_;        // Input SP link, this LCT come through [1..15] (as SP sees it)
0058 
0059 public:
0060   bool check(void) const throw() { return zero_1 != 0 || zero_2 != 0 || zero_3 != 0 || zero_4 != 0; }
0061 
0062   unsigned int quality(void) const throw() { return quality_; }
0063   unsigned int BXN(void) const throw() { return me_bxn; }
0064   unsigned int bx0(void) const throw() { return bx0_; }
0065   unsigned int bc0(void) const throw() { return bc0_; }
0066 
0067   unsigned int spInput(void) const throw() { return spInput_; }
0068   unsigned int link(void) const throw() { return link_id; }
0069   unsigned int mpc(void) const throw() { return mpc_id; }
0070   unsigned int csc(void) const throw() { return csc_id; }
0071 
0072   unsigned int l_r(void) const throw() { return left_right; }
0073   unsigned int wireGroup(void) const throw() { return wire_group_id; }
0074   unsigned int strip(void) const throw() { return clct_pattern_id; }
0075   unsigned int pattern(void) const throw() { return clct_pattern_number; }
0076 
0077   enum AF { EMPTY = 1, FULL = 2 };
0078   unsigned int aligment_fifo(void) const throw() { return (aligment_fifo_full << 1) | aligment_fifo_empty; }
0079 
0080   enum RS { IDLE_CHARs = 0, CARRIER_EXTEND = 1, NORMAL_DATA = 2, ERROR_PROP = 3 };
0081   unsigned int receiver_status_frame1(void) const throw() { return (receiver_status_dv1 << 1) | receiver_status_er1; }
0082   unsigned int receiver_status_frame2(void) const throw() { return (receiver_status_dv2 << 1) | receiver_status_er2; }
0083 
0084   unsigned int errCnt(void) const throw() { return err_prop_cnt; }
0085 
0086   unsigned int tbin(void) const throw() { return tbin_; }
0087   unsigned int vp(void) const throw() { return valid_pattern; }
0088   unsigned int se(void) const throw() { return sync_error; }
0089   unsigned int sm(void) const throw() { return sync_modified; }
0090   unsigned int af(void) const throw() { return alignment_fifo; }
0091   unsigned int timingError(void) const throw() { return bxBit; }
0092 
0093   bool unpack(const unsigned short *&buf) throw() {
0094     std::memcpy((void *)this, buf, 4 * sizeof(short));
0095     buf += 4;
0096     return check();
0097   }
0098 
0099   CSCSP_MEblock(void) {}
0100 };
0101 
0102 #endif