test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 (unsigned short *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 30 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(), i, theData, thePadding, and wordCount().

7 : theFirmwareVersion(firmwareVersion)
8 {
9  //FIXME do firmware version
10  theData[0] = 0x6e0c;
11  // all the necessary lines from this thing first
12  wordCount += 5;
13  // see if we need thePadding to make a multiple of 4
14  thePadding = 0;
15 
16  if(wordCount%4==2)
17  {
18  theData[1] = 0x2AAA;
19  theData[2] = 0x5555;
20  thePadding = 2;
22  }
23  // the next four words start with 11011, or a D
24  for(int i = 1; i < 5; ++i)
25  {
26  theData[i+thePadding] = 0xD800;
27  }
28  theData[de0fOffset()] = 0xde0f;
29  // word count excludes the trailer
31 }
int i
Definition: DBlmapReader.cc:9
int wordCount() const
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:58
unsigned short theData[7]
Definition: CSCTMBTrailer.h:56
int de0fOffset() const
Definition: CSCTMBTrailer.h:54
CSCTMBTrailer::CSCTMBTrailer ( unsigned short *  buf,
unsigned short int  firmwareVersion 
)

in 2007 format de0f line moved

Definition at line 34 of file CSCTMBTrailer.cc.

References theData, and thePadding.

35 : theFirmwareVersion(firmwareVersion)
36 {
37  // take a little too much, maybe
38  memcpy(theData, buf, 14);
39  switch (firmwareVersion){
40  case 2006:
41  // if there's padding, there'll be a de0f in the 6th word.
42  // If not, you'll be in CFEB-land, where they won't be de0f.
43  thePadding = (theData[5] == 0xde0f ? 2 : 0);
44  break;
45  case 2007:
47  // =VB= check for 1st word to be 0xDE0F, then check 3rd
48  // to handle freaky cases of double 0xDE0F signatures in trailer
49  thePadding = (theData[1] == 0xde0f ? 0 : (theData[3] == 0xde0f ? 2 : 0));
50 // thePadding = (theData[3] == 0xde0f ? 2 : 0);
51  break;
52  default:
53  edm::LogError("CSCTMBTrailer|CSCRawToDigi")
54  <<"failed to contruct: firmware version is bad/not defined!";
55  }
56 }
unsigned short int theFirmwareVersion
Definition: CSCTMBTrailer.h:58
unsigned short theData[7]
Definition: CSCTMBTrailer.h:56
CSCTMBTrailer::CSCTMBTrailer ( const CSCTMBStatusDigi digi)
inline

Definition at line 37 of file CSCTMBTrailer.h.

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

38  {
39  memcpy(this, digi.trailer(), sizeInBytes());
40  }
uint16_t sizeInBytes() const
Definition: CSCTMBTrailer.h:42
const uint16_t * trailer() const

Member Function Documentation

bool CSCTMBTrailer::check ( ) const
inline

Definition at line 45 of file CSCTMBTrailer.h.

References theData.

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

Definition at line 58 of file CSCTMBTrailer.cc.

References crcOffset(), and theData.

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

59 {
60  return (theData[crcOffset()] & 0x07ff) +
61  ((theData[crcOffset()+1] & 0x07ff) << 11);
62 }
int crcOffset() const
Definition: CSCTMBTrailer.h:53
unsigned short theData[7]
Definition: CSCTMBTrailer.h:56
int CSCTMBTrailer::crcOffset ( ) const
inlineprivate

Definition at line 53 of file CSCTMBTrailer.h.

References theFirmwareVersion, and thePadding.

Referenced by crc22(), and setCRC().

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

Definition at line 48 of file CSCTMBTrailer.h.

References theData.

Referenced by cuy.FindIssue::__init__(), and CSCTMBData::pack().

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

Definition at line 54 of file CSCTMBTrailer.h.

References theFirmwareVersion, and thePadding.

Referenced by CSCTMBTrailer().

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

Definition at line 76 of file CSCTMBTrailer.cc.

References crc22(), and setCRC().

77 {
78  CSCTMBTrailer trailer(104, 2006);
79  unsigned int crc = 0xb00b1;
80  trailer.setCRC(crc);
81  assert(trailer.crc22() == 0xb00b1);
82 
83  CSCTMBTrailer trailer2(104, 2007);
84  crc = 0xb00b1;
85  trailer2.setCRC(crc);
86  assert(trailer2.crc22() == 0xb00b1);
87 
88 }
void CSCTMBTrailer::setCRC ( int  crc)

Definition at line 65 of file CSCTMBTrailer.cc.

References crcOffset(), and theData.

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

66 {
67  theData[crcOffset()] |= (crc & 0x07ff);
68  theData[crcOffset()+1] |= ((crc>>11) & 0x07ff);
69 }
int crcOffset() const
Definition: CSCTMBTrailer.h:53
unsigned short theData[7]
Definition: CSCTMBTrailer.h:56
uint16_t CSCTMBTrailer::sizeInBytes ( ) const
inline

Definition at line 42 of file CSCTMBTrailer.h.

Referenced by CSCTMBTrailer().

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

in 16-bit frames

Definition at line 47 of file CSCTMBTrailer.h.

References thePadding.

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

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

Definition at line 72 of file CSCTMBTrailer.cc.

References theData, and thePadding.

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

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

Member Data Documentation

unsigned short CSCTMBTrailer::theData[7]
private

Definition at line 56 of file CSCTMBTrailer.h.

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

unsigned short int CSCTMBTrailer::theFirmwareVersion
private

Definition at line 58 of file CSCTMBTrailer.h.

Referenced by crcOffset(), and de0fOffset().

int CSCTMBTrailer::thePadding
private

Definition at line 57 of file CSCTMBTrailer.h.

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