EventFilter
CSCRawToDigi
src
CSCTMBTrailer.cc
Go to the documentation of this file.
1
#include "
EventFilter/CSCRawToDigi/interface/CSCTMBTrailer.h
"
2
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
3
#include <iostream>
4
#include <cassert>
5
6
CSCTMBTrailer::CSCTMBTrailer
(
int
wordCount,
int
firmwareVersion
) : theFirmwareVersion(
firmwareVersion
) {
7
//FIXME do firmware version
8
theData
[0] = 0x6e0c;
9
// all the necessary lines from this thing first
10
wordCount
+= 5;
11
// see if we need thePadding to make a multiple of 4
12
thePadding
= 0;
13
14
if
(
wordCount
% 4 == 2) {
15
theData
[1] = 0x2AAA;
16
theData
[2] = 0x5555;
17
thePadding
= 2;
18
wordCount
+=
thePadding
;
19
}
20
// the next four words start with 11011, or a D
21
for
(
int
i
= 1;
i
< 5; ++
i
) {
22
theData
[
i
+
thePadding
] = 0xD800;
23
}
24
theData
[
de0fOffset
()] = 0xde0f;
25
// word count excludes the trailer
26
theData
[4 +
thePadding
] |=
wordCount
;
27
}
28
29
CSCTMBTrailer::CSCTMBTrailer
(
const
uint16_t*
buf
,
unsigned
short
int
firmwareVersion
)
30
: theFirmwareVersion(
firmwareVersion
) {
31
// take a little too much, maybe
32
memcpy(
theData
,
buf
, 14);
33
switch
(
firmwareVersion
) {
34
case
2006:
35
// if there's padding, there'll be a de0f in the 6th word.
36
// If not, you'll be in CFEB-land, where they won't be de0f.
37
thePadding
= (
theData
[5] == 0xde0f ? 2 : 0);
38
break
;
39
case
2007:
41
// =VB= check for 1st word to be 0xDE0F, then check 3rd
42
// to handle freaky cases of double 0xDE0F signatures in trailer
43
thePadding
= (
theData
[1] == 0xde0f ? 0 : (
theData
[3] == 0xde0f ? 2 : 0));
44
// thePadding = (theData[3] == 0xde0f ? 2 : 0);
45
break
;
46
default
:
47
edm::LogError
(
"CSCTMBTrailer|CSCRawToDigi"
) <<
"failed to contruct: firmware version is bad/not defined!"
;
48
}
49
}
50
51
unsigned
int
CSCTMBTrailer::crc22
()
const
{
52
return
(
theData
[
crcOffset
()] & 0x07ff) + ((
theData
[
crcOffset
() + 1] & 0x07ff) << 11);
53
}
54
55
void
CSCTMBTrailer::setCRC
(
int
crc) {
56
theData
[
crcOffset
()] |= (crc & 0x07ff);
57
theData
[
crcOffset
() + 1] |= ((crc >> 11) & 0x07ff);
58
}
59
60
int
CSCTMBTrailer::wordCount
()
const
{
return
theData
[4 +
thePadding
] & 0x7ff; }
61
62
void
CSCTMBTrailer::selfTest
() {
63
CSCTMBTrailer
trailer(104, 2006);
64
unsigned
int
crc = 0xb00b1;
65
trailer.
setCRC
(crc);
66
assert
(trailer.
crc22
() == 0xb00b1);
67
68
CSCTMBTrailer
trailer2(104, 2007);
69
crc = 0xb00b1;
70
trailer2.setCRC(crc);
71
assert
(trailer2.crc22() == 0xb00b1);
72
}
CSCTMBTrailer.h
mps_fire.i
i
Definition:
mps_fire.py:355
MessageLogger.h
CSCTMBTrailer::thePadding
int thePadding
Definition:
CSCTMBTrailer.h:53
CSCTMBTrailer::wordCount
int wordCount() const
Definition:
CSCTMBTrailer.cc:60
CSCTMBTrailer::crcOffset
int crcOffset() const
Definition:
CSCTMBTrailer.h:49
cms::cuda::assert
assert(be >=bs)
CSCTMBTrailer::theData
unsigned short theData[7]
Definition:
CSCTMBTrailer.h:52
simCaloStage2Layer1Digis_cfi.firmwareVersion
firmwareVersion
Definition:
simCaloStage2Layer1Digis_cfi.py:21
edm::LogError
Definition:
MessageLogger.h:183
CSCTMBTrailer::selfTest
static void selfTest()
Definition:
CSCTMBTrailer.cc:62
CSCTMBTrailer
Definition:
CSCTMBTrailer.h:28
CSCTMBTrailer::CSCTMBTrailer
CSCTMBTrailer(int wordCount, int firmwareVersion)
don't forget to pass in the size of the tmb header + clct data
Definition:
CSCTMBTrailer.cc:6
visDQMUpload.buf
buf
Definition:
visDQMUpload.py:154
CSCTMBTrailer::de0fOffset
int de0fOffset() const
Definition:
CSCTMBTrailer.h:50
CSCTMBTrailer::crc22
unsigned int crc22() const
Definition:
CSCTMBTrailer.cc:51
CSCTMBTrailer::setCRC
void setCRC(int crc)
Definition:
CSCTMBTrailer.cc:55
Generated for CMSSW Reference Manual by
1.8.16