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  union dataPtr { const unsigned short * s; CSCCLCTDataWord * d; } mptr;
51  mptr.s = theData+iline;
52  return *(mptr.d);
53  }
54 
55  CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const {
56  int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
57  return dataWord(iline);
58  }
59 
60  bool bitValue(int cfeb, int tbin, int layer, int distrip) {
61  return dataWord(cfeb, tbin, layer).value(distrip);
62  }
63 
64  // checks that the CFEB number and time bins are correct
65  bool check() const;
66 
67  // hex dump
68  void dump() const;
69 
70  // checks packing and unpacking
71  static void selfTest();
72 
73 
74  private:
75 
76  // helper for constructors
77  void zero();
78 
79  static bool debug;
80  int ncfebs_;
81  int ntbins_;
82  int size_;
83  unsigned short theData[5*6*32];
84 };
85 
86 #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:55
unsigned short cfeb_
Definition: CSCCLCTData.h:15
unsigned short theData[5 *6 *32]
Definition: CSCCLCTData.h:83
void dump() const
Definition: CSCCLCTData.cc:240
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCCLCTData.h:60
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:79
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void zero()
Definition: CSCCLCTData.cc:42