test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCALCTHeader.h
Go to the documentation of this file.
1 #ifndef CSCALCTHeader_h
2 #define 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 
98  unsigned short int L1Acc() const {
99 #ifdef LOCAL_UNPACK
100  switch (firmwareVersion) {
101 #else
102  switch (firmwareVersion.load()) {
103 #endif
104  case 2006:
105  return header2006.l1Acc;
106  case 2007:
107  return header2007.l1aCounter;
108  default:
109  edm::LogError("CSCALCTHeader|CSCRawToDigi")
110  <<"trying to access L1Acc: ALCT firmware version is bad/not defined!";
111  return 0;
112  }
113  }
114 
115  void setL1Acc(unsigned int l1a) {
116 #ifdef LOCAL_UNPACK
117  switch (firmwareVersion) {
118 #else
119  switch (firmwareVersion.load()) {
120 #endif
121  case 2006:
122  header2006.l1Acc = l1a % 0xF;
123  break;
124  case 2007:
125  header2007.l1aCounter = l1a % 0xFFF;
126  break;
127  default:
128  edm::LogError("CSCALCTHeader|CSCRawToDigi")
129  <<"trying to set L1Acc: ALCT firmware version is bad/not defined!";
130  break;
131  }
132  }
133 
134  unsigned short int L1AMatch() const {return header2006.l1aMatch;}
135  unsigned short int ActiveFEBs() const {return header2006.activeFEBs;}
136  unsigned short int Promote1() const {return header2006.promote1;}
137  unsigned short int Promote2() const {return header2006.promote2;}
138  unsigned short int LCTChipRead() const {return header2006.lctChipRead;}
139  unsigned short int alctFirmwareVersion() const {return firmwareVersion;}
140  void setDAVForChannel(int wireGroup) {
141  if(firmwareVersion == 2006) {
142  header2006.setDAV((wireGroup-1)/16);
143  }
144  }
147 
148  unsigned short int * data() {return theOriginalBuffer;}
149 
151  int sizeInWords() {
152 #ifdef LOCAL_UNPACK
153  switch (firmwareVersion) {
154 #else
155  switch (firmwareVersion.load()) {
156 #endif
157  case 2006:
158  return 8;
159  case 2007:
160  return sizeInWords2007_;
161  default:
162  edm::LogError("CSCALCTHeader|CSCRawToDigi")
163  <<"SizeInWords(): ALCT firmware version is bad/not defined!";
164  return 0;
165  }
166  }
167 
168  bool check() const {
169 #ifdef LOCAL_UNPACK
170  switch (firmwareVersion) {
171 #else
172  switch (firmwareVersion.load()) {
173 #endif
174  case 2006:
175  return header2006.flag_0 == 0xC;
176  case 2007:
177  return header2007.flag1 == 0xDB0A;
178  default:
179  edm::LogError("CSCALCTHeader|CSCRawToDigi")
180  <<"check(): ALCT firmware version is bad/not defined!";
181  return 0;
182  }
183  }
184 
185  void add(const std::vector<CSCALCTDigi> & digis);
186 
187  boost::dynamic_bitset<> pack();
188 
190  static void selfTest(int firmware);
191 
192  private:
195  std::vector<CSCALCT> theALCTs;
199  std::vector<CSCCollisionMask> collisionMasks;
200  std::vector<CSCHotChannelMask> hotChannelMasks;
201 
202  //raw data also stored in this buffer
203  //maximum header size is 116 words
204  unsigned short int theOriginalBuffer[116];
205 
206 #ifdef LOCAL_UNPACK
207  static bool debug;
208  static unsigned short int firmwareVersion;
209 #else
210  static std::atomic<bool> debug;
211  static std::atomic<unsigned short int> firmwareVersion;
212 #endif
213 
215  unsigned short int sizeInWords2007_, bxn0, bxn1;
216 };
217 
218 std::ostream & operator<<(std::ostream & os, const CSCALCTHeader & header);
219 
220 #endif
221 
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
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
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:98
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()