CMS 3D CMS Logo

CSCComparatorData.h
Go to the documentation of this file.
1 #ifndef EventFilter_CSCRawToDigi_CSCComparatorData_h
2 #define EventFilter_CSCRawToDigi_CSCComparatorData_h
5 #include <vector>
6 #include <cassert>
7 
8 #ifndef LOCAL_UNPACK
9 #include <atomic>
10 #endif
11 
13  CSCComparatorDataWord(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 
25 public:
26  explicit CSCComparatorData(const CSCTMBHeader *tmbHeader);
27  CSCComparatorData(int ncfebs, int ntbins, int firmware_version = 2007);
28  CSCComparatorData(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  CSCComparatorDataWord &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
CSCComparatorData::sizeInWords
int sizeInWords() const
in 16-bit words
Definition: CSCComparatorData.h:41
CSCComparatorDataWord::value
bool value(int distrip)
Definition: CSCComparatorData.h:14
CSCComparatorDataWord::CSCComparatorDataWord
CSCComparatorDataWord(unsigned cfeb, unsigned tbin, unsigned data)
Definition: CSCComparatorData.h:13
CSCComparatorDataWord::tbin_
unsigned short tbin_
Definition: CSCComparatorData.h:18
CSCComparatorData::bitValue
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCComparatorData.h:66
cms::cuda::assert
assert(be >=bs)
CSCComparatorData::selfTest
static void selfTest()
Definition: CSCComparatorData.cc:325
CSCDetId.h
CSCComparatorDigi.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
CSCComparatorData::setDebug
static void setDebug(const bool value)
Definition: CSCComparatorData.h:31
CSCComparatorData::dump
void dump() const
Definition: CSCComparatorData.cc:318
CSCComparatorData::check
bool check() const
Definition: CSCComparatorData.cc:296
CSCComparatorDigi
Definition: CSCComparatorDigi.h:16
CSCComparatorData::nlines
int nlines() const
Definition: CSCComparatorData.h:42
CSCComparatorData::theFirmwareVersion
int theFirmwareVersion
Definition: CSCComparatorData.h:91
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
CSCComparatorData::dataWord
CSCComparatorDataWord & dataWord(int cfeb, int tbin, int layer) const
Definition: CSCComparatorData.h:61
CSCComparatorData::dataWord
CSCComparatorDataWord & dataWord(int iline) const
Definition: CSCComparatorData.h:49
CSCDetId
Definition: CSCDetId.h:26
ntuplemaker.iline
iline
Definition: ntuplemaker.py:186
value
Definition: value.py:1
CSCComparatorData::size_
int size_
Definition: CSCComparatorData.h:89
CSCComparatorData::ncfebs_
int ncfebs_
Definition: CSCComparatorData.h:87
CSCComparatorData::comparatorDigis
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
Definition: CSCComparatorData.cc:179
CSCComparatorData::theData
unsigned short theData[7 *6 *32]
Definition: CSCComparatorData.h:90
CSCTMBHeader
Definition: CSCTMBHeader.h:26
CSCComparatorData::CSCComparatorData
CSCComparatorData(const CSCTMBHeader *tmbHeader)
Definition: CSCComparatorData.cc:16
CSCComparatorData::add
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn't do flipping yet.
Definition: CSCComparatorData.cc:192
relativeConstraints.value
value
Definition: relativeConstraints.py:53
CSCComparatorData::data
unsigned short * data()
Definition: CSCComparatorData.h:39
CSCComparatorDataWord::cfeb_
unsigned short cfeb_
Definition: CSCComparatorData.h:19
CSCComparatorData::zero
void zero()
Definition: CSCComparatorData.cc:41
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
ztail.d
d
Definition: ztail.py:151
CSCComparatorDataWord::set
void set(int distrip, bool value)
@ not right! doesn't set zero
Definition: CSCComparatorData.h:16
CSCComparatorDataWord
Definition: CSCComparatorData.h:12
CSCComparatorDataWord::data_
unsigned short data_
Definition: CSCComparatorData.h:17
CSCComparatorData::ntbins_
int ntbins_
Definition: CSCComparatorData.h:88
CSCComparatorData
Definition: CSCComparatorData.h:24
CSCComparatorData::debug
static std::atomic< bool > debug
Definition: CSCComparatorData.h:84