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
CSCCLCTData::zero
void zero()
Definition: CSCCLCTData.cc:40
CSCCLCTData::size_
int size_
Definition: CSCCLCTData.h:89
cms::cuda::assert
assert(be >=bs)
CSCCLCTDataWord::set
void set(int distrip, bool value)
@ not right! doesn't set zero
Definition: CSCCLCTData.h:16
CSCCLCTData::check
bool check() const
Definition: CSCCLCTData.cc:295
CSCDetId.h
CSCCLCTDataWord::data_
unsigned short data_
Definition: CSCCLCTData.h:17
CSCCLCTData::theData
unsigned short theData[7 *6 *32]
Definition: CSCCLCTData.h:90
CSCComparatorDigi.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
CSCCLCTData::ncfebs_
int ncfebs_
Definition: CSCCLCTData.h:87
CSCCLCTData::dataWord
CSCCLCTDataWord & dataWord(int cfeb, int tbin, int layer) const
Definition: CSCCLCTData.h:61
CSCComparatorDigi
Definition: CSCComparatorDigi.h:16
CSCCLCTData::bitValue
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCCLCTData.h:66
CSCCLCTData::data
unsigned short * data()
Definition: CSCCLCTData.h:39
CSCCLCTData::nlines
int nlines() const
Definition: CSCCLCTData.h:42
CSCCLCTData::comparatorDigis
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
Definition: CSCCLCTData.cc:178
CSCCLCTDataWord::cfeb_
unsigned short cfeb_
Definition: CSCCLCTData.h:19
CSCCLCTData::sizeInWords
int sizeInWords() const
in 16-bit words
Definition: CSCCLCTData.h:41
CSCCLCTData::add
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn't do flipping yet.
Definition: CSCCLCTData.cc:191
CSCDetId
Definition: CSCDetId.h:26
CSCCLCTData::theFirmwareVersion
int theFirmwareVersion
Definition: CSCCLCTData.h:91
ntuplemaker.iline
iline
Definition: ntuplemaker.py:186
CSCCLCTDataWord::tbin_
unsigned short tbin_
Definition: CSCCLCTData.h:18
value
Definition: value.py:1
CSCCLCTData::dump
void dump() const
Definition: CSCCLCTData.cc:317
CSCCLCTData::dataWord
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:49
CSCTMBHeader
Definition: CSCTMBHeader.h:25
CSCCLCTDataWord
Definition: CSCCLCTData.h:12
CSCCLCTData::debug
static std::atomic< bool > debug
Definition: CSCCLCTData.h:84
CSCCLCTData::CSCCLCTData
CSCCLCTData(const CSCTMBHeader *tmbHeader)
Definition: CSCCLCTData.cc:16
CSCCLCTData::setDebug
static void setDebug(const bool value)
Definition: CSCCLCTData.h:31
relativeConstraints.value
value
Definition: relativeConstraints.py:53
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
CSCCLCTDataWord::CSCCLCTDataWord
CSCCLCTDataWord(unsigned cfeb, unsigned tbin, unsigned data)
Definition: CSCCLCTData.h:13
ztail.d
d
Definition: ztail.py:151
CSCCLCTData::ntbins_
int ntbins_
Definition: CSCCLCTData.h:88
CSCCLCTData
Definition: CSCCLCTData.h:24
CSCCLCTDataWord::value
bool value(int distrip)
Definition: CSCCLCTData.h:14
CSCCLCTData::selfTest
static void selfTest()
Definition: CSCCLCTData.cc:324