CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CSCTMBTrailer Class Reference

#include <CSCTMBTrailer.h>

Public Member Functions

bool check () const
 
unsigned int crc22 () const
 
 CSCTMBTrailer (int wordCount, int firmwareVersion)
 don't forget to pass in the size of the tmb header + clct data More...
 
 CSCTMBTrailer (const uint16_t *buf, unsigned short int firmwareVersion)
 
 CSCTMBTrailer (const CSCTMBStatusDigi &digi)
 
unsigned short * data ()
 
void setCRC (int crc)
 
uint16_t sizeInBytes () const
 
int sizeInWords () const
 in 16-bit frames More...
 
int wordCount () const
 

Static Public Member Functions

static void selfTest ()
 

Private Member Functions

int crcOffset () const
 
int de0fOffset () const
 

Private Attributes

unsigned short theData [7]
 
unsigned short int theFirmwareVersion
 
int thePadding
 

Detailed Description

Defined to begin at the 6E0C word 2006 format

6E0C 2AAA (optional) 5555 (optional) D8+CRC22(10) D8+CRC22(10) DE0F D8+WordCount D2007 format 6E0C 2AAA (optional) 5555 (optional) DE0F D8+CRC22(10) D8+CRC22(10) D8+WordCount

Definition at line 28 of file CSCTMBTrailer.h.

Constructor & Destructor Documentation

CSCTMBTrailer::CSCTMBTrailer ( int  wordCount,
int  firmwareVersion 
)

don't forget to pass in the size of the tmb header + clct data

Definition at line 6 of file CSCTMBTrailer.cc.

References de0fOffset(), mps_fire::i, theData, thePadding, and wordCount().

6  : 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;
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
27 }
int wordCount() const
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:54
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
int de0fOffset() const
Definition: CSCTMBTrailer.h:50
CSCTMBTrailer::CSCTMBTrailer ( const uint16_t *  buf,
unsigned short int  firmwareVersion 
)

in 2007 format de0f line moved

Definition at line 29 of file CSCTMBTrailer.cc.

References theData, and thePadding.

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 }
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:54
Log< level::Error, false > LogError
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
CSCTMBTrailer::CSCTMBTrailer ( const CSCTMBStatusDigi digi)
inline

Definition at line 35 of file CSCTMBTrailer.h.

References sizeInBytes(), and CSCTMBStatusDigi::trailer().

35 { memcpy(this, digi.trailer(), sizeInBytes()); }
uint16_t sizeInBytes() const
Definition: CSCTMBTrailer.h:37
const uint16_t * trailer() const

Member Function Documentation

bool CSCTMBTrailer::check ( ) const
inline

Definition at line 40 of file CSCTMBTrailer.h.

References theData.

40 { return theData[0] == 0x6e0c; }
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
unsigned int CSCTMBTrailer::crc22 ( ) const

Definition at line 51 of file CSCTMBTrailer.cc.

References crcOffset(), and theData.

Referenced by CSCTMBData::getCRC(), and selfTest().

51  {
52  return (theData[crcOffset()] & 0x07ff) + ((theData[crcOffset() + 1] & 0x07ff) << 11);
53 }
int crcOffset() const
Definition: CSCTMBTrailer.h:49
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
int CSCTMBTrailer::crcOffset ( ) const
inlineprivate

Definition at line 49 of file CSCTMBTrailer.h.

References theFirmwareVersion, and thePadding.

Referenced by crc22(), and setCRC().

49 { return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding; }
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:54
unsigned short* CSCTMBTrailer::data ( )
inline

Definition at line 43 of file CSCTMBTrailer.h.

References theData.

Referenced by CSCTMBData::pack().

43 { return theData; }
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
int CSCTMBTrailer::de0fOffset ( ) const
inlineprivate

Definition at line 50 of file CSCTMBTrailer.h.

References theFirmwareVersion, and thePadding.

Referenced by CSCTMBTrailer().

50 { return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding; }
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:54
void CSCTMBTrailer::selfTest ( )
static

Definition at line 62 of file CSCTMBTrailer.cc.

References cms::cuda::assert(), crc22(), and setCRC().

62  {
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 }
assert(be >=bs)
void CSCTMBTrailer::setCRC ( int  crc)

Definition at line 55 of file CSCTMBTrailer.cc.

References crcOffset(), and theData.

Referenced by CSCTMBData::pack(), and selfTest().

55  {
56  theData[crcOffset()] |= (crc & 0x07ff);
57  theData[crcOffset() + 1] |= ((crc >> 11) & 0x07ff);
58 }
int crcOffset() const
Definition: CSCTMBTrailer.h:49
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
uint16_t CSCTMBTrailer::sizeInBytes ( ) const
inline

Definition at line 37 of file CSCTMBTrailer.h.

Referenced by CSCTMBTrailer().

37 { return 16; }
int CSCTMBTrailer::sizeInWords ( ) const
inline

in 16-bit frames

Definition at line 42 of file CSCTMBTrailer.h.

References thePadding.

Referenced by CSCTMBData::pack(), and CSCTMBData::UnpackTMB().

42 { return 5 + thePadding; }
int CSCTMBTrailer::wordCount ( ) const

Definition at line 60 of file CSCTMBTrailer.cc.

References theData, and thePadding.

Referenced by CSCTMBTrailer(), and cscdqm::EventProcessor::processCSC().

60 { return theData[4 + thePadding] & 0x7ff; }
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52

Member Data Documentation

unsigned short CSCTMBTrailer::theData[7]
private

Definition at line 52 of file CSCTMBTrailer.h.

Referenced by check(), crc22(), CSCTMBTrailer(), data(), setCRC(), and wordCount().

unsigned short int CSCTMBTrailer::theFirmwareVersion
private

Definition at line 54 of file CSCTMBTrailer.h.

Referenced by crcOffset(), and de0fOffset().

int CSCTMBTrailer::thePadding
private

Definition at line 53 of file CSCTMBTrailer.h.

Referenced by crcOffset(), CSCTMBTrailer(), de0fOffset(), sizeInWords(), and wordCount().