Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CSCSPRecord_h
0002 #define CSCSPRecord_h
0003 #include <vector>
0004 
0005 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_MEblock.h"
0006 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_MBblock.h"
0007 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_SPblock.h"
0008 
0009 class CSCSPRecord {
0010 private:
0011   // Data Block Header format
0012   /////// word 1 ///////
0013   unsigned vp_bits : 15;  // Valid Pattern bits for 15 ME LCTs
0014   unsigned zero_1 : 1;    // format specific
0015   /////// word 2 ///////
0016   unsigned mode1 : 4;    // First track mode (ids of stations, that give LCTs to build a track, mode=0 - no track)
0017   unsigned mode2 : 4;    // Second track mode (...)
0018   unsigned mode3 : 4;    // Third track mode (...)
0019   unsigned vq_a : 1;     // Valid Quality (Q > 0) bit for the first MB Stub;
0020   unsigned vq_b : 1;     // Valid Quality (Q > 0) bit for the second MB Stub;
0021   unsigned spare_1 : 1;  // not used
0022   unsigned zero_2 : 1;   // format specific
0023   /////// word 3 ///////
0024   unsigned se_bits : 15;  // Sync Error bits for 15 ME LCTs
0025   unsigned zero_3 : 1;    // format specific
0026   /////// word 4 ///////
0027   // Modified Sync Error bits for 15 ME LCTs: (SE) OR (Optical Link status) OR (Alignment FIFO status) OR (Bunch Crossing Counter status)
0028   unsigned sm_bits : 15;
0029   unsigned zero_4 : 1;  // format specific
0030   /////// word 5 ///////
0031   unsigned af_bits : 15;  // Alignment FIFO status bits for 15 ME links, in normal state zero
0032   unsigned zero_5 : 1;    // format specific
0033   /////// word 6 ///////
0034   unsigned bx_bits : 15;  // set for LCT with BC0 commig early or later that the BC0 => monitors the ALCT/TMB/MPC timing
0035   unsigned zero_6 : 1;    // format specific
0036   /////// word 7 ///////
0037   unsigned pt_low : 8;        // low byte of pt for track, that we are spying at
0038   unsigned pt_spy_point : 2;  // defines track, that we are spying at
0039   unsigned spare_2 : 1;       // not used
0040   unsigned spare_3 : 1;       // not used
0041   unsigned af_barrel_1 : 1;
0042   unsigned af_barrel_2 : 1;
0043   unsigned spare_4 : 1;  // not used
0044   unsigned zero_7 : 1;   // format specific
0045   /////// word 8 ///////
0046   unsigned pt_high : 8;  // high byte of pt for track, that we are spying at
0047   unsigned time_bin : 3;
0048 
0049   //    unsigned spare_5     : 1; // not used
0050   //    unsigned spare_6     : 1; // not used
0051   //    unsigned spare_7     : 1; // not used
0052 
0053   unsigned spare_8 : 1;  // not used
0054   unsigned bx_barrel_1 : 1;
0055   unsigned bx_barrel_2 : 1;
0056   unsigned spare_9 : 1;  // not used
0057   unsigned zero_8 : 1;   // format specific
0058 
0059   // persistent storage for specific data blocks
0060   CSCSP_MEblock me[5][3];
0061   CSCSP_MBblock mb[2];
0062   CSCSP_SPblock sp[3];
0063   // data blocks, that were used (=true) in this record
0064   bool meFilled[5][3], mbFilled[2], spFilled[3];
0065   // Allow CSCSPEvent, front end to the data format, access 'sp' field dirrectly
0066   friend class CSCSPEvent;
0067   friend class CSCTFPacker;
0068 
0069 public:
0070   bool check(void) const throw() {
0071     return zero_1 != 0 || zero_2 != 0 || zero_3 != 0 || zero_4 != 0 || zero_5 != 0 || zero_6 != 0 || zero_7 != 0 ||
0072            zero_8 != 0  // || spare_1!=0
0073            || spare_2 != 0 || spare_3 != 0 || spare_4 != 0 || spare_8 != 0 || spare_9 != 0;
0074   }
0075 
0076   // Following functions return empty vector if no LCTs/MB_stubs/tracks are available
0077   std::vector<CSCSP_MEblock> LCTs(void) const throw();
0078   std::vector<CSCSP_MEblock> LCTs(unsigned int mpc) const throw();
0079   std::vector<CSCSP_MEblock> LCT(unsigned int mpc, unsigned int link) const throw();
0080   std::vector<CSCSP_SPblock> tracks(void) const throw();
0081   std::vector<CSCSP_MBblock> mbStubs(void) const throw();
0082 
0083   unsigned int VPs(void) const throw() { return vp_bits | (vq_a << 15) | (vq_b << 16); }
0084   unsigned int SEs(void) const throw() { return se_bits; }
0085   unsigned int SMs(void) const throw() { return sm_bits; }
0086   unsigned int AFs(void) const throw() { return af_bits | (af_barrel_1 << 15) | (af_barrel_2 << 16); }
0087   unsigned int BXs(void) const throw() { return bx_bits | (bx_barrel_1 << 15) | (bx_barrel_2 << 16); }
0088 
0089   unsigned int ptSpy(void) const throw() { return (pt_high << 8) | pt_low; }
0090   unsigned int ptSpyTrack(void) const throw() { return pt_spy_point; }
0091 
0092   bool unpack(const unsigned short*& buf,
0093               unsigned int nonmasked_data_blocks,
0094               bool empty_blocks_suppressed,
0095               unsigned int tbin) throw();
0096 
0097   CSCSPRecord(void) {}
0098 };
0099 
0100 #endif