test
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
5 #include <vector>
6 #include <cassert>
7 
8 #ifndef LOCAL_UNPACK
9 #include <atomic>
10 #endif
11 
12 
14  CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
15  : data_(data), tbin_(tbin), cfeb_(cfeb) {}
16  bool value(int distrip) {return (data_ >> distrip) & 0x1;}
18  void set(int distrip, bool value) {data_ |= (value << distrip);}
19  unsigned short data_ : 8;
20  unsigned short tbin_ : 4;
21  unsigned short cfeb_ : 4;
22 };
23 
24 class CSCTMBHeader;
25 
26 class CSCCLCTData {
27 
28 public:
29 
30  explicit CSCCLCTData(const CSCTMBHeader * tmbHeader);
31  CSCCLCTData(int ncfebs, int ntbins, int firmware_version = 2007);
32  CSCCLCTData(int ncfebs, int ntbins, const unsigned short *e0bbuf, int firmware_version = 2007);
33 
35  static void setDebug(const bool value) {debug = value;};
36 
38  std::vector<CSCComparatorDigi> comparatorDigis(int layer);
39 
41  std::vector<CSCComparatorDigi> comparatorDigis(uint32_t idlayer, unsigned icfeb);
42 
43 
44  unsigned short * data() {return theData;}
46  int sizeInWords() const { return size_;}
47  int nlines() const { return ncfebs_*ntbins_*6; }
48 
50  void add(const CSCComparatorDigi & digi, int layer);
52  void add(const CSCComparatorDigi & digi, const CSCDetId & id);
53 
55 #ifdef ASSERTS
56  assert(iline < nlines());
57 #endif
58  union dataPtr { const unsigned short * s; CSCCLCTDataWord * d; } mptr;
59  mptr.s = theData+iline;
60  return *(mptr.d);
61  }
62 
63  CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const {
64  int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
65  return dataWord(iline);
66  }
67 
68  bool bitValue(int cfeb, int tbin, int layer, int distrip) {
69  return dataWord(cfeb, tbin, layer).value(distrip);
70  }
71 
72  // checks that the CFEB number and time bins are correct
73  bool check() const;
74 
75  // hex dump
76  void dump() const;
77 
78  // checks packing and unpacking
79  static void selfTest();
80 
81 
82  private:
83 
84  // helper for constructors
85  void zero();
86 
87 #ifdef LOCAL_UNPACK
88  static bool debug;
89 #else
90  static std::atomic<bool> debug;
91 #endif
92 
93  int ncfebs_;
94  int ntbins_;
95  int size_;
96  unsigned short theData[7*6*32];
98 };
99 
100 #endif
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:46
unsigned short data_
Definition: CSCCLCTData.h:19
int nlines() const
Definition: CSCCLCTData.h:47
static void selfTest()
Definition: CSCCLCTData.cc:397
void set(int distrip, bool value)
@ not right! doesn&#39;t set zero
Definition: CSCCLCTData.h:18
assert(m_qm.get())
CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
Definition: CSCCLCTData.h:14
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:54
CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const
Definition: CSCCLCTData.h:63
unsigned short theData[7 *6 *32]
Definition: CSCCLCTData.h:96
unsigned short cfeb_
Definition: CSCCLCTData.h:21
tuple d
Definition: ztail.py:151
void dump() const
Definition: CSCCLCTData.cc:387
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCCLCTData.h:68
unsigned short * data()
Definition: CSCCLCTData.h:44
int theFirmwareVersion
Definition: CSCCLCTData.h:97
static std::atomic< bool > debug
Definition: CSCCLCTData.h:90
CSCCLCTData(const CSCTMBHeader *tmbHeader)
Definition: CSCCLCTData.cc:17
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
Definition: CSCCLCTData.cc:206
static void setDebug(const bool value)
Definition: CSCCLCTData.h:35
unsigned short tbin_
Definition: CSCCLCTData.h:20
bool value(int distrip)
Definition: CSCCLCTData.h:16
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn&#39;t do flipping yet.
Definition: CSCCLCTData.cc:222
bool check() const
Definition: CSCCLCTData.cc:359
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void zero()
Definition: CSCCLCTData.cc:49