CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/EventFilter/CSCRawToDigi/interface/CSCCLCTData.h

Go to the documentation of this file.
00001 #ifndef CSCCLCTData_h
00002 #define CSCCLCTData_h
00003 #include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h"
00004 #include <vector>
00005 #include <cassert>
00006 
00007 struct CSCCLCTDataWord {
00008   CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
00009   : data_(data), tbin_(tbin), cfeb_(cfeb) {}
00010   bool value(int distrip) {return (data_ >> distrip) & 0x1;}
00012   void set(int distrip, bool value) {data_ |= (value << distrip);}
00013   unsigned short data_ : 8;
00014   unsigned short tbin_ : 4;
00015   unsigned short cfeb_ : 4;
00016 };
00017 
00018 class CSCTMBHeader;
00019 
00020 class CSCCLCTData {
00021 
00022 public:
00023 
00024   explicit CSCCLCTData(const CSCTMBHeader * tmbHeader);
00025   CSCCLCTData(int ncfebs, int ntbins);
00026   CSCCLCTData(int ncfebs, int ntbins, const unsigned short *e0bbuf);
00027 
00029   static void setDebug(const bool value) {debug = value;};
00030 
00032   std::vector<CSCComparatorDigi> comparatorDigis(int layer);
00033 
00035   std::vector<CSCComparatorDigi> comparatorDigis(uint32_t idlayer, unsigned icfeb);
00036 
00037 
00038   unsigned short * data() {return theData;}
00040   int sizeInWords() const { return size_;}
00041   int nlines() const { return ncfebs_*ntbins_*6; }
00042 
00044   void add(const CSCComparatorDigi & digi, int layer);
00045 
00046   CSCCLCTDataWord & dataWord(int iline) const {
00047 #ifdef ASSERTS
00048     assert(iline < nlines());
00049 #endif
00050     union dataPtr { const unsigned short * s; CSCCLCTDataWord * d; } mptr;
00051     mptr.s = theData+iline;
00052     return *(mptr.d);
00053   }
00054 
00055   CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const {
00056     int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
00057     return dataWord(iline);
00058   }
00059 
00060   bool bitValue(int cfeb, int tbin, int layer, int distrip) {
00061     return dataWord(cfeb, tbin, layer).value(distrip);
00062   }
00063 
00064   // checks that the CFEB number and time bins are correct
00065   bool check() const;
00066 
00067   // hex dump
00068   void dump() const;
00069 
00070   // checks packing and unpacking
00071   static void selfTest();
00072 
00073 
00074  private:
00075 
00076   // helper for constructors
00077   void zero();
00078 
00079   static bool debug;
00080   int ncfebs_;
00081   int ntbins_;
00082   int size_;
00083   unsigned short theData[5*6*32];
00084 };
00085 
00086 #endif