Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CSCSP_MBblock_h
0002 #define CSCSP_MBblock_h
0003 
0004 #include <cstring>
0005 
0006 class CSCSP_MBblock {
0007 private:
0008   /////// word 1 ///////
0009   unsigned quality_ : 3;   // muon quality (0-7),  quality > 0 for valid data;
0010   unsigned zero_1 : 1;     // format specific
0011   unsigned phi_bend_ : 5;  // phi bend angle
0012   unsigned zero_2 : 3;     // format specific
0013   unsigned flag_ : 1;      // if 1 then it is a second muon from previous bunch crossing
0014   unsigned cal_ : 1;       // MBy special mode flag
0015   unsigned zero_3 : 2;     // format specific
0016   /////// word 2 ///////
0017   unsigned phi_ : 12;   // azimuth coordinate;
0018   unsigned bxn1_ : 1;   // next to the least significant bit of the MB BX number
0019   unsigned bxn0_ : 1;   // least significant bit of the MB BX number
0020   unsigned bc0_ : 1;    // BX zero timing mark
0021   unsigned zero_4 : 1;  // format specific
0022   /////// word 3 ///////
0023   unsigned mb_bxn_ : 12;  // Stub arrival time picked from a local 12-bit Bunch Counter, that runs at data stream timing
0024   unsigned spare_1 : 3;   // not used
0025   unsigned zero_5 : 1;    // format specific
0026   /////// word 4 ///////
0027   unsigned spare_2 : 15;  // not used
0028   unsigned zero_6 : 1;    // format specific
0029 
0030   // Other data members logically belong to MB block record,
0031   //  but physically are located in Data Block Header, which implementation is:
0032   friend class CSCSPRecord;
0033   friend class CSCTFPacker;
0034   // Let this class set following data memebers:
0035   unsigned int tbin_;           // time bin, that this MB block belongs to in global SP record
0036   unsigned int valid_quality;   // valid quality
0037   unsigned int alignment_fifo;  // AF error
0038   unsigned int bxBit;           // monitors the MB(DT) timing
0039   unsigned int id_;             // stub id (1-MB1a, 2-MB1d)
0040 
0041 public:
0042   bool check(void) const throw() {
0043     return zero_1 != 0 || zero_2 != 0 || zero_3 != 0 || zero_4 != 0 || zero_5 != 0 || zero_6 != 0 || spare_1 != 0 ||
0044            spare_2 != 0;
0045   }
0046 
0047   unsigned int quality(void) const throw() { return quality_; }
0048   unsigned int phi_bend(void) const throw() { return phi_bend_; }
0049   unsigned int flag(void) const throw() { return flag_; }
0050   unsigned int cal(void) const throw() { return cal_; }
0051 
0052   unsigned int phi(void) const throw() { return phi_; }
0053   unsigned int bxn(void) const throw() { return (bxn1_ << 1) | bxn0_; }
0054   unsigned int bc0(void) const throw() { return bc0_; }
0055   unsigned int BXN(void) const throw() { return mb_bxn_; }
0056 
0057   unsigned int id(void) const throw() { return id_; }
0058   unsigned int tbin(void) const throw() { return tbin_; }
0059   unsigned int vq(void) const throw() { return valid_quality; }
0060   unsigned int af(void) const throw() { return alignment_fifo; }
0061   unsigned int timingError(void) const throw() { return bxBit; }
0062 
0063   bool unpack(const unsigned short *&buf) throw() {
0064     std::memcpy(this, buf, 4 * sizeof(short));
0065     buf += 4;
0066     return check();
0067   }
0068 
0069   CSCSP_MBblock(void) {}
0070 };
0071 
0072 #endif