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 return *(CSCCLCTDataWord *)(theData+iline);
00051 }
00052
00053 CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const {
00054 int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
00055 return dataWord(iline);
00056 }
00057
00058 bool bitValue(int cfeb, int tbin, int layer, int distrip) {
00059 return dataWord(cfeb, tbin, layer).value(distrip);
00060 }
00061
00062
00063 bool check() const;
00064
00065
00066 void dump() const;
00067
00068
00069 static void selfTest();
00070
00071
00072 private:
00073
00074
00075 void zero();
00076
00077 static bool debug;
00078 int ncfebs_;
00079 int ntbins_;
00080 int size_;
00081 unsigned short theData[5*6*32];
00082 };
00083
00084 #endif