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 
13  CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data) : data_(data), tbin_(tbin), cfeb_(cfeb) {}
14  bool value(int distrip) { return (data_ >> distrip) & 0x1; }
16  void set(int distrip, bool value) { data_ |= (value << distrip); }
17  unsigned short data_ : 8;
18  unsigned short tbin_ : 4;
19  unsigned short cfeb_ : 4;
20 };
21 
22 class CSCTMBHeader;
23 
24 class CSCCLCTData {
25 public:
26  explicit CSCCLCTData(const CSCTMBHeader *tmbHeader);
27  CSCCLCTData(int ncfebs, int ntbins, int firmware_version = 2007);
28  CSCCLCTData(int ncfebs, int ntbins, const unsigned short *e0bbuf, int firmware_version = 2007);
29 
31  static void setDebug(const bool value) { debug = value; };
32 
34  std::vector<CSCComparatorDigi> comparatorDigis(int layer);
35 
37  std::vector<CSCComparatorDigi> comparatorDigis(uint32_t idlayer, unsigned icfeb);
38 
39  unsigned short *data() { return theData; }
41  int sizeInWords() const { return size_; }
42  int nlines() const { return ncfebs_ * ntbins_ * 6; }
43 
45  void add(const CSCComparatorDigi &digi, int layer);
47  void add(const CSCComparatorDigi &digi, const CSCDetId &id);
48 
50 #ifdef ASSERTS
51  assert(iline < nlines());
52 #endif
53  union dataPtr {
54  const unsigned short *s;
56  } mptr;
57  mptr.s = theData + iline;
58  return *(mptr.d);
59  }
60 
61  CSCCLCTDataWord &dataWord(int cfeb, int tbin, int layer) const {
62  int iline = (layer - 1) + tbin * 6 + cfeb * 6 * ntbins_;
63  return dataWord(iline);
64  }
65 
66  bool bitValue(int cfeb, int tbin, int layer, int distrip) { return dataWord(cfeb, tbin, layer).value(distrip); }
67 
68  // checks that the CFEB number and time bins are correct
69  bool check() const;
70 
71  // hex dump
72  void dump() const;
73 
74  // checks packing and unpacking
75  static void selfTest();
76 
77 private:
78  // helper for constructors
79  void zero();
80 
81 #ifdef LOCAL_UNPACK
82  static bool debug;
83 #else
84  static std::atomic<bool> debug;
85 #endif
86 
87  int ncfebs_;
88  int ntbins_;
89  int size_;
90  unsigned short theData[7 * 6 * 32];
92 };
93 
94 #endif
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:41
unsigned short data_
Definition: CSCCLCTData.h:17
int nlines() const
Definition: CSCCLCTData.h:42
CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
Definition: CSCCLCTData.h:13
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:49
CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const
Definition: CSCCLCTData.h:61
unsigned short cfeb_
Definition: CSCCLCTData.h:19
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCCLCTData.h:66
unsigned short * data()
Definition: CSCCLCTData.h:39
int theFirmwareVersion
Definition: CSCCLCTData.h:91
Definition: value.py:1
static std::atomic< bool > debug
Definition: CSCCLCTData.h:84
d
Definition: ztail.py:151
static void setDebug(const bool value)
Definition: CSCCLCTData.h:31
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
unsigned short tbin_
Definition: CSCCLCTData.h:18
#define debug
Definition: HDRShower.cc:19
bool value(int distrip)
Definition: CSCCLCTData.h:14
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79