CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCALCTHeader.h
Go to the documentation of this file.
1 #ifndef EventFilter_CSCRawToDigi_CSCALCTHeader_h
2 #define EventFilter_CSCRawToDigi_CSCALCTHeader_h
3 
7 #include <bitset>
8 #include <vector>
9 #include <iosfwd>
10 #ifndef LOCAL_UNPACK
11 #include <atomic>
12 #endif
19 #include <boost/dynamic_bitset.hpp>
20 
22 public:
23  explicit CSCALCTHeader(int chamberType);
24 
25  explicit CSCALCTHeader(const unsigned short *buf);
26 
27  CSCALCTHeader(const CSCALCTStatusDigi &digi);
28 
30  static void setDebug(bool value) { debug = value; };
31 
32  void setEventInformation(const CSCDMBHeader &);
33  unsigned short int nLCTChipRead() const;
34 
35  std::vector<CSCALCTDigi> ALCTDigis() const;
36 
39 
41  unsigned short int FIFOMode() const { return header2006.fifoMode; }
42  unsigned short int NTBins() const {
43 #ifdef LOCAL_UNPACK
44  switch (firmwareVersion) {
45 #else
46  switch (firmwareVersion.load()) {
47 #endif
48  case 2006:
49  return header2006.nTBins;
50  case 2007:
51  return header2007.rawBins;
52  default:
53  edm::LogError("CSCALCTHeader|CSCRawToDigi")
54  << "trying to access NTBINs: ALCT firmware version is bad/not defined!";
55  return 0;
56  }
57  }
58  unsigned short int BoardID() const { return header2006.boardID; }
59  unsigned short int ExtTrig() const { return header2006.extTrig; }
60  unsigned short int CSCID() const { return header2006.cscID; }
61  unsigned short int BXNCount() const {
62 #ifdef LOCAL_UNPACK
63  switch (firmwareVersion) {
64 #else
65  switch (firmwareVersion.load()) {
66 #endif
67  case 2006:
68  return header2006.bxnCount;
69  case 2007:
70  return header2007.bxnCount;
71  default:
72  edm::LogError("CSCALCTHeader|CSCRawToDigi")
73  << "trying to access BXNcount: ALCT firmware version is bad/not defined!";
74  return 0;
75  }
76  }
77 
78  void setBXNCount(unsigned int bxn) {
79 #ifdef LOCAL_UNPACK
80  switch (firmwareVersion) {
81 #else
82  switch (firmwareVersion.load()) {
83 #endif
84  case 2006:
85  header2006.bxnCount = bxn % 0xFFF;
86  break;
87  case 2007:
88  header2007.bxnCount = bxn % 0xFFF;
89  break;
90  default:
91  edm::LogError("CSCALCTHeader|CSCRawToDigi")
92  << "trying to set BXNcount: ALCT firmware version is bad/not defined!";
93  break;
94  }
95  }
96 
97  unsigned short int L1Acc() const {
98 #ifdef LOCAL_UNPACK
99  switch (firmwareVersion) {
100 #else
101  switch (firmwareVersion.load()) {
102 #endif
103  case 2006:
104  return header2006.l1Acc;
105  case 2007:
106  return header2007.l1aCounter;
107  default:
108  edm::LogError("CSCALCTHeader|CSCRawToDigi")
109  << "trying to access L1Acc: ALCT firmware version is bad/not defined!";
110  return 0;
111  }
112  }
113 
114  void setL1Acc(unsigned int l1a) {
115 #ifdef LOCAL_UNPACK
116  switch (firmwareVersion) {
117 #else
118  switch (firmwareVersion.load()) {
119 #endif
120  case 2006:
121  header2006.l1Acc = l1a % 0xF;
122  break;
123  case 2007:
124  header2007.l1aCounter = l1a % 0xFFF;
125  break;
126  default:
127  edm::LogError("CSCALCTHeader|CSCRawToDigi") << "trying to set L1Acc: ALCT firmware version is bad/not defined!";
128  break;
129  }
130  }
131 
132  unsigned short int L1AMatch() const { return header2006.l1aMatch; }
133  unsigned short int ActiveFEBs() const { return header2006.activeFEBs; }
134  unsigned short int Promote1() const { return header2006.promote1; }
135  unsigned short int Promote2() const { return header2006.promote2; }
136  unsigned short int LCTChipRead() const { return header2006.lctChipRead; }
137  unsigned short int alctFirmwareVersion() const { return firmwareVersion; }
138  void setDAVForChannel(int wireGroup) {
139  if (firmwareVersion == 2006) {
140  header2006.setDAV((wireGroup - 1) / 16);
141  }
142  }
145 
146  unsigned short int *data() { return theOriginalBuffer; }
147 
149  int sizeInWords() {
150 #ifdef LOCAL_UNPACK
151  switch (firmwareVersion) {
152 #else
153  switch (firmwareVersion.load()) {
154 #endif
155  case 2006:
156  return 8;
157  case 2007:
158  return sizeInWords2007_;
159  default:
160  edm::LogError("CSCALCTHeader|CSCRawToDigi") << "SizeInWords(): ALCT firmware version is bad/not defined!";
161  return 0;
162  }
163  }
164 
165  bool check() const {
166 #ifdef LOCAL_UNPACK
167  switch (firmwareVersion) {
168 #else
169  switch (firmwareVersion.load()) {
170 #endif
171  case 2006:
172  return header2006.flag_0 == 0xC;
173  case 2007:
174  return header2007.flag1 == 0xDB0A;
175  default:
176  edm::LogError("CSCALCTHeader|CSCRawToDigi") << "check(): ALCT firmware version is bad/not defined!";
177  return false;
178  }
179  }
180 
181  void add(const std::vector<CSCALCTDigi> &digis);
182 
183  boost::dynamic_bitset<> pack();
184 
186  static void selfTest(int firmware);
187 
188 private:
191  std::vector<CSCALCT> theALCTs;
195  std::vector<CSCCollisionMask> collisionMasks;
196  std::vector<CSCHotChannelMask> hotChannelMasks;
197 
198  //raw data also stored in this buffer
199  //maximum header size is 116 words
200  unsigned short int theOriginalBuffer[116];
201 
202 #ifdef LOCAL_UNPACK
203  static bool debug;
204  static unsigned short int firmwareVersion;
205 #else
206  static std::atomic<bool> debug;
207  static std::atomic<unsigned short int> firmwareVersion;
208 #endif
209 
211  unsigned short int sizeInWords2007_, bxn0, bxn1;
212 };
213 
214 std::ostream &operator<<(std::ostream &os, const CSCALCTHeader &header);
215 
216 #endif
unsigned short int L1AMatch() const
unsigned bxnCount
full bunch crossing number
unsigned fifoMode
see the FIFO_MODE enum
unsigned short int LCTChipRead() const
std::vector< CSCHotChannelMask > hotChannelMasks
std::vector< CSCCollisionMask > collisionMasks
unsigned promote1
promotion bit for 1st LCT pattern
CSCVirtexID virtexID
unsigned short int bxn1
unsigned short int nLCTChipRead() const
for packing
void setBXNCount(unsigned int bxn)
Definition: CSCALCTHeader.h:78
CSCConfigurationRegister configRegister
CSCALCTHeader(int chamberType)
bool check() const
CSCALCTs2006 alcts2006
Log< level::Error, false > LogError
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
void setEventInformation(const CSCDMBHeader &)
static std::atomic< unsigned short int > firmwareVersion
static void selfTest(int firmware)
tests that we unpack what we packed
unsigned extTrig
trigger source was external
CSCALCTHeader2007 alctHeader2007() const
unsigned short int CSCID() const
Definition: CSCALCTHeader.h:60
unsigned short int theOriginalBuffer[116]
unsigned short int ActiveFEBs() const
CSCALCTHeader2006 header2006
unsigned short int ExtTrig() const
Definition: CSCALCTHeader.h:59
ALCT Header consists of several modular units that are defined as structs below.
std::vector< CSCALCT > theALCTs
void add(const std::vector< CSCALCTDigi > &digis)
CSCALCTHeader2007 header2007
boost::dynamic_bitset pack()
unsigned nTBins
of 25 ns time bins in the raw dump
unsigned short int sizeInWords2007_
size of the 2007 header in words
unsigned short int Promote2() const
int sizeInWords()
in 16-bit words
std::vector< CSCALCTDigi > ALCTDigis() const
unsigned short int Promote1() const
unsigned short int alctFirmwareVersion() const
unsigned short int bxn0
static void setDebug(bool value)
to access data by via status digis
Definition: CSCALCTHeader.h:30
unsigned short int L1Acc() const
Definition: CSCALCTHeader.h:97
unsigned l1Acc
l1 accept counter
unsigned promote2
promotion bit for 2nd LCT pattern
unsigned short int FIFOMode() const
Definition: CSCALCTHeader.h:41
unsigned boardID
ALCT2000 board ID.
unsigned short int NTBins() const
Definition: CSCALCTHeader.h:42
unsigned lctChipRead
LCT chips read out in raw hit dump.
unsigned activeFEBs
LCT chips with ADB hits.
CSCALCTHeader2006 alctHeader2006() const
unsigned cscID
chamber ID number
void setDAV(int afebBoard)
for packing
unsigned short int BXNCount() const
Definition: CSCALCTHeader.h:61
unsigned l1aMatch
exteran L1A arrived in L1A window
unsigned short int BoardID() const
Definition: CSCALCTHeader.h:58
void setDAVForChannel(int wireGroup)
void setL1Acc(unsigned int l1a)
static std::atomic< bool > debug
unsigned flag_0
should be &#39;01100&#39;, so it&#39;ll be a 6xxx in the ASCII dump
unsigned short int * data()