22 : theOriginalBuffer(nullptr),
25 theTMBHeader(2007, 0x50c3),
26 theComparatorData(&theTMBHeader),
27 theTMBScopeIsPresent(
false),
29 theTMBMiniScopeIsPresent(
false),
30 theTMBMiniScope(nullptr),
31 theBlockedCFEBIsPresent(
false),
32 theTMBBlockedCFEB(nullptr),
33 theTMBTrailer(theTMBHeader.sizeInWords() + theComparatorData.sizeInWords(), 2007),
36 theRPCDataIsPresent(
false) {}
39 : theOriginalBuffer(nullptr),
43 theComparatorData(&theTMBHeader),
44 theTMBScopeIsPresent(
false),
46 theTMBMiniScopeIsPresent(
false),
47 theTMBMiniScope(nullptr),
48 theBlockedCFEBIsPresent(
false),
49 theTMBBlockedCFEB(nullptr),
50 theTMBTrailer(theTMBHeader.sizeInWords() + theComparatorData.sizeInWords(),
firmwareVersion),
53 theRPCDataIsPresent(
false) {
60 : theOriginalBuffer(
buf),
61 theTMBHeader(2007, 0x50c3),
62 theComparatorData(&theTMBHeader),
63 theTMBScopeIsPresent(
false),
65 theTMBMiniScopeIsPresent(
false),
66 theTMBMiniScope(nullptr),
67 theBlockedCFEBIsPresent(
false),
68 theTMBBlockedCFEB(nullptr),
69 theTMBTrailer(theTMBHeader.sizeInWords() + theComparatorData.sizeInWords(), 2007),
70 theRPCDataIsPresent(
false) {
77 : theOriginalBuffer(
data.theOriginalBuffer),
78 theB0CLine(
data.theB0CLine),
79 theE0FLine(
data.theE0FLine),
80 theTMBHeader(
data.theTMBHeader),
81 theComparatorData(
data.theComparatorData),
82 theRPCData(
data.theRPCData),
83 theTMBScopeIsPresent(
data.theTMBScopeIsPresent),
84 theTMBMiniScopeIsPresent(
data.theTMBMiniScopeIsPresent),
85 theBlockedCFEBIsPresent(
data.theBlockedCFEBIsPresent),
86 theTMBTrailer(
data.theTMBTrailer),
88 cWordCnt(
data.cWordCnt),
89 theRPCDataIsPresent(
data.theRPCDataIsPresent) {
129 for (
int i =
first;
i < maxToDo; ++
i) {
130 if (
buf[
i] == marker) {
144 if (!theTotalTMBData.empty()) {
146 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
" Test here " <<
CRC.to_ulong();
147 return CRC.to_ulong();
149 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"theTotalTMBData doesn't exist";
164 if (
buf[b0cLine] == 0xdb0c) {
166 Ntbins =
buf[b0cLine + 19] & 0xF8;
167 NRPCtbins = (
buf[b0cLine + 36] >> 5) & 0x1F;
168 }
else if (
buf[b0cLine] == 0x6b0c) {
170 Ntbins =
buf[b0cLine + 1] & 0x1f;
173 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ Can't find b0C flag";
177 (!(((
buf[b0cLine] & 0xFFFF) == 0xDB0C) && ((
buf[b0cLine + 1] & 0xf000) == 0xD000) &&
178 ((
buf[b0cLine + 2] & 0xf000) == 0xD000) && ((
buf[b0cLine + 3] & 0xf000) == 0xD000)))) {
179 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ CSCTMBData warning: error in header in 2007 format!";
182 int MaxSizeRPC = 1 + NRPCtbins * 2 * 4 + 1;
193 edm::LogError(
"CSCTMBData|CSCRawToDigi") <<
"+++ undetermined firmware format - cant find e0bLine";
199 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ CSCTMBData warning: Bad TMB header e0bLine=" << std::hex
211 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ CSCTMBData warning: Bad CLCT data";
220 int b04Line = currentPosition;
222 if (
buf[b04Line] == 0x6b04) {
224 int e04Line =
findLine(
buf, 0x6e04, currentPosition, currentPosition + MaxSizeRPC);
230 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"CSCTMBData::corrupt RPC data! Failed to find end! ";
235 int TotTMBReadout = 0;
238 TotTMBReadout = 43 + Ntbins * 6 * 5 + 1 + NRPCtbins * 2 * 4 + 2 + 8 * 256 + 8;
242 27 + Ntbins * 6 * 5 + 1 + NRPCtbins * 2 * 4 + 2 + 8 * 256 + 8;
245 edm::LogError(
"CSCTMBData|CSCRawToDigi") <<
"can't find TotTMBReadout - unknown firmware version!";
250 if (
buf[currentPosition] == 0x6b05) {
251 int b05Line = currentPosition;
252 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"found scope!";
253 int e05Line =
findLine(
buf, 0x6e05, currentPosition, TotTMBReadout - currentPosition);
260 currentPosition += (e05Line - b05Line + 1);
262 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ CSCTMBData warning: found 0x6b05 line, but not 0x6e05! +++";
267 if (
buf[currentPosition] == 0x6b07) {
268 int Line6b07 = currentPosition;
269 LogTrace(
"CSCTMBData") <<
" TMBData ---> Begin of MiniScope found ";
270 int Line6E07 =
findLine(
buf, 0x6E07, currentPosition, TotTMBReadout - currentPosition);
271 if (Line6E07 != -1) {
272 LogTrace(
"CSCTMBData") <<
" TMBData --> End of MiniScope found " << Line6E07 - Line6b07 + 1 <<
" words ";
275 currentPosition += (Line6E07 - Line6b07 + 1);
277 LogTrace(
"CSCTMBData") <<
"+++ CSCTMBData warning MiniScope!: found 0x6b07 line, but not 0x6e07! +++";
283 if (
buf[currentPosition] == 0x6BCB) {
284 int Line6BCB = currentPosition;
285 LogTrace(
"CSCTMBData") <<
" TMBData ---> Begin of Blocked CFEB found ";
286 int Line6ECB =
findLine(
buf, 0x6ECB, currentPosition, TotTMBReadout - currentPosition);
287 if (Line6ECB != -1) {
288 LogTrace(
"CSCTMBData") <<
" TMBData --> End of Blocked CFEB found " << Line6ECB - Line6BCB + 1 <<
" words ";
291 currentPosition += (Line6ECB - Line6BCB + 1);
293 LogTrace(
"CSCTMBData") <<
"+++ CSCTMBData warning Blocked CFEB!: found 0x6BCB line, but not 0x6ECB! +++";
298 int maxLine =
findLine(
buf, 0xde0f, currentPosition, TotTMBReadout - currentPosition);
300 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ CSCTMBData warning: No e0f line!";
310 int e0cLine =
findLine(
buf, 0x6e0c, currentPosition, maxLine);
312 LogTrace(
"CSCTMBData|CSCRawToDigi") <<
"+++ CSCTMBData warning: No e0c line!";
322 LogTrace(
"CSCTMBData") <<
"Dump of TMB data:";
324 LogTrace(
"CSCTMBData") <<
"Adr= " << std::setw(4) <<
line <<
" Data= " << std::setfill(
'0') << std::setw(5)
342 for (
unsigned int i = 0;
i < datain.size() - 3; ++
i) {
350 throw(
"No TMBScope in this chamber");
356 throw(
"No TMBScope in this chamber");
362 throw(
"No TMB Blocked CFEB in this chamber");
367 std::bitset<22> NewCRC;
369 NewCRC[0] =
D[0] ^
C[6];
370 NewCRC[1] =
D[1] ^
D[0] ^
C[6] ^
C[7];
371 NewCRC[2] =
D[2] ^
D[1] ^
C[7] ^
C[8];
372 NewCRC[3] =
D[3] ^
D[2] ^
C[8] ^
C[9];
373 NewCRC[4] =
D[4] ^
D[3] ^
C[9] ^
C[10];
374 NewCRC[5] =
D[5] ^
D[4] ^
C[10] ^
C[11];
375 NewCRC[6] =
D[6] ^
D[5] ^
C[11] ^
C[12];
376 NewCRC[7] =
D[7] ^
D[6] ^
C[12] ^
C[13];
377 NewCRC[8] =
D[8] ^
D[7] ^
C[13] ^
C[14];
378 NewCRC[9] =
D[9] ^
D[8] ^
C[14] ^
C[15];
379 NewCRC[10] =
D[10] ^
D[9] ^
C[15] ^
C[16];
380 NewCRC[11] =
D[11] ^
D[10] ^
C[16] ^
C[17];
381 NewCRC[12] =
D[12] ^
D[11] ^
C[17] ^
C[18];
382 NewCRC[13] =
D[13] ^
D[12] ^
C[18] ^
C[19];
383 NewCRC[14] =
D[14] ^
D[13] ^
C[19] ^
C[20];
384 NewCRC[15] =
D[15] ^
D[14] ^
C[20] ^
C[21];
385 NewCRC[16] =
D[15] ^
C[0] ^
C[21];
396 boost::dynamic_bitset<>
result =
401 boost::dynamic_bitset<> newResult =
result;
409 std::vector<std::bitset<16> > wordVector;
412 std::bitset<16>
word;
413 for (
int i = 0;
i < 16; ++
i) {
416 wordVector.push_back(
word);