CMS 3D CMS Logo

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
CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
Definition: CSCCLCTData.h:14
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:54
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const
Definition: CSCCLCTData.h:63
unsigned short cfeb_
Definition: CSCCLCTData.h:21
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
Definition: value.py:1
static std::atomic< bool > debug
Definition: CSCCLCTData.h:90
static void setDebug(const bool value)
Definition: CSCCLCTData.h:35
unsigned short tbin_
Definition: CSCCLCTData.h:20
#define debug
Definition: HDRShower.cc:19
bool value(int distrip)
Definition: CSCCLCTData.h:16
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def check(config)
Definition: trackerTree.py:14