CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 (const CSCTMBStatusDigi &digi)
 
 CSCTMBTrailer (const uint16_t *buf, unsigned short int firmwareVersion)
 
 CSCTMBTrailer (int wordCount, int firmwareVersion)
 don't forget to pass in the size of the tmb header + clct data More...
 
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() [1/3]

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.

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 }

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

◆ CSCTMBTrailer() [2/3]

CSCTMBTrailer::CSCTMBTrailer ( const uint16_t *  buf,
unsigned short int  firmwareVersion 
)

in 2007 format de0f line moved

Definition at line 29 of file CSCTMBTrailer.cc.

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 }

References visDQMUpload::buf, simCaloStage2Layer1Digis_cfi::firmwareVersion, theData, and thePadding.

◆ CSCTMBTrailer() [3/3]

CSCTMBTrailer::CSCTMBTrailer ( const CSCTMBStatusDigi digi)
inline

Definition at line 35 of file CSCTMBTrailer.h.

35 { memcpy(this, digi.trailer(), sizeInBytes()); }

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

Member Function Documentation

◆ check()

bool CSCTMBTrailer::check ( ) const
inline

Definition at line 40 of file CSCTMBTrailer.h.

40 { return theData[0] == 0x6e0c; }

References theData.

◆ crc22()

unsigned int CSCTMBTrailer::crc22 ( ) const

Definition at line 51 of file CSCTMBTrailer.cc.

51  {
52  return (theData[crcOffset()] & 0x07ff) + ((theData[crcOffset() + 1] & 0x07ff) << 11);
53 }

References crcOffset(), and theData.

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

◆ crcOffset()

int CSCTMBTrailer::crcOffset ( ) const
inlineprivate

Definition at line 49 of file CSCTMBTrailer.h.

49 { return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding; }

References theFirmwareVersion, and thePadding.

Referenced by crc22(), and setCRC().

◆ data()

unsigned short* CSCTMBTrailer::data ( )
inline

Definition at line 43 of file CSCTMBTrailer.h.

43 { return theData; }

References theData.

Referenced by CSCTMBData::pack().

◆ de0fOffset()

int CSCTMBTrailer::de0fOffset ( ) const
inlineprivate

Definition at line 50 of file CSCTMBTrailer.h.

50 { return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding; }

References theFirmwareVersion, and thePadding.

Referenced by CSCTMBTrailer().

◆ selfTest()

void CSCTMBTrailer::selfTest ( )
static

Definition at line 62 of file CSCTMBTrailer.cc.

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 }

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

◆ setCRC()

void CSCTMBTrailer::setCRC ( int  crc)

Definition at line 55 of file CSCTMBTrailer.cc.

55  {
56  theData[crcOffset()] |= (crc & 0x07ff);
57  theData[crcOffset() + 1] |= ((crc >> 11) & 0x07ff);
58 }

References crcOffset(), and theData.

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

◆ sizeInBytes()

uint16_t CSCTMBTrailer::sizeInBytes ( ) const
inline

Definition at line 37 of file CSCTMBTrailer.h.

37 { return 16; }

Referenced by CSCTMBTrailer().

◆ sizeInWords()

int CSCTMBTrailer::sizeInWords ( ) const
inline

in 16-bit frames

Definition at line 42 of file CSCTMBTrailer.h.

42 { return 5 + thePadding; }

References thePadding.

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

◆ wordCount()

int CSCTMBTrailer::wordCount ( ) const

Definition at line 60 of file CSCTMBTrailer.cc.

60 { return theData[4 + thePadding] & 0x7ff; }

References theData, and thePadding.

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

Member Data Documentation

◆ theData

unsigned short CSCTMBTrailer::theData[7]
private

Definition at line 52 of file CSCTMBTrailer.h.

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

◆ theFirmwareVersion

unsigned short int CSCTMBTrailer::theFirmwareVersion
private

Definition at line 54 of file CSCTMBTrailer.h.

Referenced by crcOffset(), and de0fOffset().

◆ thePadding

int CSCTMBTrailer::thePadding
private

Definition at line 53 of file CSCTMBTrailer.h.

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

mps_fire.i
i
Definition: mps_fire.py:428
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)
CSCTMBStatusDigi::trailer
const uint16_t * trailer() const
Definition: CSCTMBStatusDigi.h:25
CSCTMBTrailer::theData
unsigned short theData[7]
Definition: CSCTMBTrailer.h:52
simCaloStage2Layer1Digis_cfi.firmwareVersion
firmwareVersion
Definition: simCaloStage2Layer1Digis_cfi.py:21
CSCTMBTrailer
Definition: CSCTMBTrailer.h:28
CSCTMBTrailer::sizeInBytes
uint16_t sizeInBytes() const
Definition: CSCTMBTrailer.h:37
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
CSCTMBTrailer::theFirmwareVersion
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:54
CSCTMBTrailer::de0fOffset
int de0fOffset() const
Definition: CSCTMBTrailer.h:50