CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCCLCTData.h
Go to the documentation of this file.
1 #ifndef CSCCLCTData_h
2 #define CSCCLCTData_h
4 #include <vector>
5 #include <cassert>
6 
8  CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
9  : data_(data), tbin_(tbin), cfeb_(cfeb) {}
10  bool value(int distrip) {return (data_ >> distrip) & 0x1;}
12  void set(int distrip, bool value) {data_ |= (value << distrip);}
13  unsigned short data_ : 8;
14  unsigned short tbin_ : 4;
15  unsigned short cfeb_ : 4;
16 };
17 
18 class CSCTMBHeader;
19 
20 class CSCCLCTData {
21 
22 public:
23 
24  explicit CSCCLCTData(const CSCTMBHeader * tmbHeader);
25  CSCCLCTData(int ncfebs, int ntbins);
26  CSCCLCTData(int ncfebs, int ntbins, const unsigned short *e0bbuf);
27 
29  static void setDebug(const bool value) {debug = value;};
30 
32  std::vector<CSCComparatorDigi> comparatorDigis(int layer);
33 
35  std::vector<CSCComparatorDigi> comparatorDigis(uint32_t idlayer, unsigned icfeb);
36 
37 
38  unsigned short * data() {return theData;}
40  int sizeInWords() const { return size_;}
41  int nlines() const { return ncfebs_*ntbins_*6; }
42 
44  void add(const CSCComparatorDigi & digi, int layer);
45 
47 #ifdef ASSERTS
48  assert(iline < nlines());
49 #endif
50  return *(CSCCLCTDataWord *)(theData+iline);
51  }
52 
53  CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const {
54  int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
55  return dataWord(iline);
56  }
57 
58  bool bitValue(int cfeb, int tbin, int layer, int distrip) {
59  return dataWord(cfeb, tbin, layer).value(distrip);
60  }
61 
62  // checks that the CFEB number and time bins are correct
63  bool check() const;
64 
65  // hex dump
66  void dump() const;
67 
68  // checks packing and unpacking
69  static void selfTest();
70 
71 
72  private:
73 
74  // helper for constructors
75  void zero();
76 
77  static bool debug;
78  int ncfebs_;
79  int ntbins_;
80  int size_;
81  unsigned short theData[5*6*32];
82 };
83 
84 #endif
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:40
unsigned short data_
Definition: CSCCLCTData.h:13
int nlines() const
Definition: CSCCLCTData.h:41
static void selfTest()
Definition: CSCCLCTData.cc:248
void set(int distrip, bool value)
@ not right! doesn&#39;t set zero
Definition: CSCCLCTData.h:12
CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
Definition: CSCCLCTData.h:8
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46
CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const
Definition: CSCCLCTData.h:53
unsigned short cfeb_
Definition: CSCCLCTData.h:15
unsigned short theData[5 *6 *32]
Definition: CSCCLCTData.h:81
void dump() const
Definition: CSCCLCTData.cc:240
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCCLCTData.h:58
unsigned short * data()
Definition: CSCCLCTData.h:38
CSCCLCTData(const CSCTMBHeader *tmbHeader)
Definition: CSCCLCTData.cc:12
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
Definition: CSCCLCTData.cc:167
static void setDebug(const bool value)
Definition: CSCCLCTData.h:29
unsigned short tbin_
Definition: CSCCLCTData.h:14
bool value(int distrip)
Definition: CSCCLCTData.h:10
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn&#39;t do flipping yet.
Definition: CSCCLCTData.cc:183
bool check() const
Definition: CSCCLCTData.cc:212
static bool debug
Definition: CSCCLCTData.h:77
void zero()
Definition: CSCCLCTData.cc:42