CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/EventFilter/CSCRawToDigi/interface/CSCCFEBTimeSlice.h

Go to the documentation of this file.
00001 #ifndef CSCCFEBTimeSlice_h
00002 #define CSCCFEBTimeSlice_h
00003 
00004 
00021 struct CSCCFEBDataWord {
00022   unsigned short adcCounts   : 12;
00023   unsigned short adcOverflow : 1;
00025   unsigned short controllerData : 1;
00028   unsigned short overlappedSampleFlag : 1;
00031   unsigned short errorstat : 1;
00032 };
00033 
00034 #include <iostream>
00035 #include <string.h> //for bzero
00036 
00037 struct CSCCFEBSCAControllerWord {
00042   explicit CSCCFEBSCAControllerWord(unsigned short frame);
00043   CSCCFEBSCAControllerWord() {bzero(this, 2);}
00044 
00045   unsigned short trig_time : 8;
00046   unsigned short sca_blk   : 4;
00047   unsigned short l1a_phase : 1;
00048   unsigned short lct_phase : 1;
00049   unsigned short sca_full  : 1;
00050   unsigned short ts_flag   : 1;
00051 };
00052 
00053 
00054 
00055 
00056 class CSCCFEBTimeSlice {
00057  public:
00058   CSCCFEBTimeSlice();
00059 
00061   CSCCFEBDataWord * timeSample(int index) const {
00062     return (CSCCFEBDataWord *)(theSamples+index);
00063   }
00065   CSCCFEBDataWord * timeSample(int layer, int channel) const;
00066 
00068   bool sixteenSamples() {/*return scaControllerWord(1).ts_flag;i*/
00069     return timeSample(95)->controllerData;}
00070   unsigned sizeInWords() const {return 100;}
00071 
00073   CSCCFEBSCAControllerWord scaControllerWord(int layer) const ;
00074   
00075   void setControllerWord(const CSCCFEBSCAControllerWord & controllerWord);
00076 
00079   bool check() const {return ((dummy == 0x7FFF)||((dummy+crc)== 0x7FFF));}
00080 
00081   bool checkCRC() const {return crc==calcCRC();}
00082 
00083   unsigned calcCRC() const;
00084 
00086   void setCRC() { crc=calcCRC(); dummy=0x7FFF-crc;}
00087 
00088   friend std::ostream & operator<<(std::ostream & os, const CSCCFEBTimeSlice &);
00089 
00090 
00092   unsigned  get_crc()               const {return crc;}
00093   unsigned  get_n_free_sca_blocks() const {return n_free_sca_blocks;}
00094   unsigned  get_lctpipe_count()     const {return lctpipe_count;}
00095   unsigned  get_lctpipe_full()      const {return lctpipe_full;}
00096   unsigned  get_l1pipe_full()       const {return l1pipe_full;}
00097   unsigned  get_lctpipe_empty()     const {return lctpipe_empty;}
00098   unsigned  get_l1pipe_empty()      const {return l1pipe_empty;}
00099   unsigned  get_buffer_warning()    const {return buffer_warning;}
00100   unsigned  get_buffer_count()      const {return buffer_count;}
00101   unsigned  get_L1A_number()        const {return L1A_number;}
00102 
00103  private:
00104   unsigned short theSamples[96];
00105 
00107   unsigned crc : 16;
00108 
00110   unsigned n_free_sca_blocks : 4;
00111   unsigned lctpipe_count : 4;
00112   unsigned lctpipe_full  : 1;
00113   unsigned l1pipe_full   : 1;
00114   unsigned lctpipe_empty : 1;
00115   unsigned l1pipe_empty  : 1;
00116   unsigned blank_space_1 : 4;
00117 
00118 
00120   unsigned buffer_warning : 1;
00121   unsigned buffer_count : 5;
00122   unsigned L1A_number :6;
00123   unsigned blank_space_3 : 4; 
00124 
00126   unsigned dummy : 16;
00127 };
00128 
00129 #endif