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 Attributes | Private Attributes
CastorCTDCHeader Class Reference

#include <CastorCTDCHeader.h>

Public Member Functions

unsigned short BOEshouldBe5Always () const
 
short BOEshouldBeZeroAlways () const
 
 CastorCTDCHeader ()
 
void clear ()
 
void copyMergerData (const CastorMergerData &data, bool valid)
 
void copySpigotData (unsigned int spigot_id, const CastorCORData &data, bool valid=true, unsigned char LRB_error_word=0)
 Add the given CastorCORData as the given spigot's data. This should be done in increasing spigot order! More...
 
int getAcceptTimeTTS () const
 
int getBunchId () const
 
bool getBxMismatchWithDCC (unsigned int nspigot) const
 Read the "BxID FAILS TO MATCH WITH DCC" bit for this spigot. More...
 
int getByte1Zeroes () const
 
int getByte3Zeroes () const
 
int getByte567Zeroes () const
 
unsigned short getCDFEventType () const
 
short getCDFversionNumber () const
 
short getDCCDataFormatVersion () const
 
unsigned long getDCCEventNumber () const
 
int getDCCStatus () const
 
int getHTRStatusBits () const
 
unsigned char getLRBErrorBits (unsigned int nspigot) const
 Access the Link Receiver Board error bits (decoding tbd) More...
 
unsigned int getOrbitNumber () const
 
unsigned int getSlink64ReservedBits () const
 
int getSourceId () const
 
bool getSpigotCRCError (unsigned int nspigot) const
 Read the "CRC-Mismatch" bit for this spigot. More...
 
int getSpigotData (int nspigot, CastorCORData &decodeTool, int validSize) const
 
unsigned int getSpigotDataLength (int nspigot) const
 
bool getSpigotDataTruncated (unsigned int nspigot) const
 Read the "TRUNCATED" bit for this spigot; LRB truncated data (took too long) More...
 
bool getSpigotEnabled (unsigned int nspigot) const
 Read the "ENABLED" bit for this spigot. More...
 
unsigned char getSpigotErrorBits (unsigned int nspigot) const
 Access the HTR error bits (decoding tbd) More...
 
bool getSpigotErrorFlag (int nspigot) const
 
bool getSpigotPresent (unsigned int nspigot) const
 Read the "PRESENT" bit for this spigot. More...
 
int getSpigotSummary (int nspigot) const
 
bool getSpigotValid (unsigned int nspigot) const
 Read the "VALID" bit for this spigot; TTC EvN matched HTR EvN. More...
 
unsigned int getTotalLengthBytes () const
 
bool SawCT_BcN_MxMx () const
 
bool SawCT_EvN_MxMx () const
 
bool SawL1A_BcN_MxMx () const
 
bool SawL1A_EvN_MxMx () const
 
bool SawOrbitLengthErr () const
 
bool SawTTC_DoubErr () const
 
bool SawTTC_SingErr () const
 
bool SawTTS_BSY () const
 
bool SawTTS_OFW () const
 
bool SawTTS_SYN () const
 
void setHeader (int sourceid, int bcn, int l1aN, int orbN)
 
bool thereIsASecondCDFHeaderWord () const
 
bool thereIsAThirdCDFHeaderWord () const
 

Static Public Attributes

static const int SPIGOT_COUNT = 2
 

Private Attributes

unsigned int commondataformat0
 
unsigned int commondataformat1
 
unsigned int commondataformat2
 
unsigned int commondataformat3
 
unsigned int ctdch0
 
unsigned int ctdch1
 
unsigned int spigotInfo [4]
 

Detailed Description

Interpretive class for an CastorCTDCHeader

Author
A. Campbell - DESY

Definition at line 17 of file CastorCTDCHeader.h.

Constructor & Destructor Documentation

CastorCTDCHeader::CastorCTDCHeader ( )

Definition at line 13 of file CastorCTDCHeader.cc.

Referenced by copyMergerData(), copySpigotData(), getSpigotData(), and getTotalLengthBytes().

13 { }

Member Function Documentation

unsigned short CastorCTDCHeader::BOEshouldBe5Always ( ) const
inline

Get the inviolable '5' in the highest 4 bits of the CDF header.

Definition at line 40 of file CastorCTDCHeader.h.

short CastorCTDCHeader::BOEshouldBeZeroAlways ( ) const
inline

Get the Beginning Of Event bits. If it's not the first or last CDF Slink64 word, the high 4 bits must be zero.

Definition at line 50 of file CastorCTDCHeader.h.

void CastorCTDCHeader::clear ( void  )

clear the contents of this header

Definition at line 35 of file CastorCTDCHeader.cc.

References commondataformat0, commondataformat1, commondataformat2, commondataformat3, ctdch0, ctdch1, i, and spigotInfo.

Referenced by Vispa.Views.WidgetView.WidgetView::closeEvent(), Vispa.Share.FindAlgorithm.FindAlgorithm::findUsingFindDialog(), CastorCtdcPacker::pack(), and Vispa.Views.WidgetView.WidgetView::setDataObjects().

35  {
37  commondataformat1=0x50000000u;
40  ctdch0=0x1; // format version 1
41  ctdch1=0;
42  for (int i=0; i<3; i++)
43  spigotInfo[i]=0;
44  spigotInfo[3]=0x12345678; // end DCC header pattern
45 
46 }
int i
Definition: DBlmapReader.cc:9
unsigned int commondataformat0
unsigned int commondataformat3
unsigned int spigotInfo[4]
unsigned int commondataformat2
unsigned int commondataformat1
unsigned int ctdch1
unsigned int ctdch0
void CastorCTDCHeader::copyMergerData ( const CastorMergerData data,
bool  valid 
)

Definition at line 74 of file CastorCTDCHeader.cc.

References CastorCTDCHeader(), ctdch0, CastorMergerData::getErrorsWord(), CastorMergerData::getRawData(), CastorMergerData::getRawLength(), getSpigotDataLength(), i, and spigotInfo.

Referenced by CastorCtdcPacker::pack().

74  {
75  unsigned int spigot_id = 2;
76  // construct the spigot info
77  spigotInfo[spigot_id]=(data.getRawLength()/2)|0xc000; // Enabled & Present
78  if (valid) spigotInfo[spigot_id]|=0x2000; // Valid
79  spigotInfo[spigot_id]|=((data.getErrorsWord()&0xFF)<<24);
80  // status info...
81  if (valid) ctdch0|=(1<<(spigot_id+14));
82  // copy
83  unsigned int lenSoFar=0;
84  for (unsigned int i=0; i<spigot_id; i++) lenSoFar+=getSpigotDataLength(i);
85  unsigned short* startingPoint=((unsigned short*)this)+sizeof(CastorCTDCHeader)/sizeof(unsigned short)+lenSoFar*2;
86  memcpy(startingPoint,data.getRawData(),sizeof(unsigned short)*data.getRawLength());
87  // update the trailer...
88  lenSoFar+=data.getRawLength()/2; // 32-bit words
89  uint32_t* trailer=((uint32_t*)this)+sizeof(CastorCTDCHeader)/sizeof(uint32_t)+lenSoFar;
90  int len64=sizeof(CastorCTDCHeader)/8+lenSoFar/2+1;
91  trailer[1]=0;
92  trailer[0]=0xA0000000u|len64;
93 }
int i
Definition: DBlmapReader.cc:9
const int getRawLength() const
Get the length of the raw data.
unsigned int getErrorsWord() const
Get the errors word.
unsigned int spigotInfo[4]
unsigned int getSpigotDataLength(int nspigot) const
const unsigned short * getRawData() const
Get a pointer to the raw data.
unsigned int ctdch0
void CastorCTDCHeader::copySpigotData ( unsigned int  spigot_id,
const CastorCORData data,
bool  valid = true,
unsigned char  LRB_error_word = 0 
)

Add the given CastorCORData as the given spigot's data. This should be done in increasing spigot order!

Parameters
spigot_id
spigot_data
validflag
LRB_error_word

Definition at line 53 of file CastorCTDCHeader.cc.

References CastorCTDCHeader(), ctdch0, CastorCORData::getErrorsWord(), CastorCORData::getRawData(), CastorCORData::getRawLength(), getSpigotDataLength(), i, SPIGOT_COUNT, and spigotInfo.

Referenced by CastorCtdcPacker::pack().

53  {
54  if (spigot_id>=(unsigned int)SPIGOT_COUNT) return;
55  // construct the spigot info
56  spigotInfo[spigot_id]=(data.getRawLength()/2)|0xc000;
57  if (valid) spigotInfo[spigot_id]|=0x2000;
58  spigotInfo[spigot_id]|=(LRB_error_word<<16)|((data.getErrorsWord()&0xFF)<<24);
59  // status info...
60  if (valid) ctdch0|=(1<<(spigot_id+14));
61  // copy
62  unsigned int lenSoFar=0;
63  for (unsigned int i=0; i<spigot_id; i++) lenSoFar+=getSpigotDataLength(i);
64  unsigned short* startingPoint=((unsigned short*)this)+sizeof(CastorCTDCHeader)/sizeof(unsigned short)+lenSoFar*2;
65  memcpy(startingPoint,data.getRawData(),sizeof(unsigned short)*data.getRawLength());
66  // update the trailer...
67  lenSoFar+=data.getRawLength()/2; // 32-bit words
68  uint32_t* trailer=((uint32_t*)this)+sizeof(CastorCTDCHeader)/sizeof(uint32_t)+lenSoFar;
69  int len64=sizeof(CastorCTDCHeader)/8+lenSoFar/2+1;
70  trailer[1]=0;
71  trailer[0]=0xA0000000u|len64;
72 }
int i
Definition: DBlmapReader.cc:9
unsigned int getErrorsWord() const
Get the errors word.
static const int SPIGOT_COUNT
unsigned int spigotInfo[4]
unsigned int getSpigotDataLength(int nspigot) const
const int getRawLength() const
Get the length of the raw data.
Definition: CastorCORData.h:36
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: CastorCORData.h:33
unsigned int ctdch0
int CastorCTDCHeader::getAcceptTimeTTS ( ) const
inline

Definition at line 54 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getBunchId ( ) const
inline

get the bunch id from the CDF header

Definition at line 34 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::getBxMismatchWithDCC ( unsigned int  nspigot) const
inline

Read the "BxID FAILS TO MATCH WITH DCC" bit for this spigot.

Definition at line 94 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getByte1Zeroes ( ) const
inline

Definition at line 55 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getByte3Zeroes ( ) const
inline

Definition at line 57 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getByte567Zeroes ( ) const
inline

Definition at line 59 of file CastorCTDCHeader.h.

unsigned short CastorCTDCHeader::getCDFEventType ( ) const
inline

Get the Event Type value (2007.11.03 - Not defined, but should stay consistent among events.)

Definition at line 38 of file CastorCTDCHeader.h.

short CastorCTDCHeader::getCDFversionNumber ( ) const
inline

Get the Format Version of the Common Data Format

Definition at line 30 of file CastorCTDCHeader.h.

short CastorCTDCHeader::getDCCDataFormatVersion ( ) const
inline

Definition at line 53 of file CastorCTDCHeader.h.

unsigned long CastorCTDCHeader::getDCCEventNumber ( ) const
inline

get the Event Number from the CDF header

Definition at line 36 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getDCCStatus ( ) const
inline

Definition at line 58 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getHTRStatusBits ( ) const
inline

Definition at line 56 of file CastorCTDCHeader.h.

unsigned char CastorCTDCHeader::getLRBErrorBits ( unsigned int  nspigot) const
inline

Access the Link Receiver Board error bits (decoding tbd)

Definition at line 104 of file CastorCTDCHeader.h.

unsigned int CastorCTDCHeader::getOrbitNumber ( ) const
inline

Get the Orbit Number from the CDF.

Definition at line 46 of file CastorCTDCHeader.h.

unsigned int CastorCTDCHeader::getSlink64ReservedBits ( ) const
inline

get the (undefined) 'Reserved' part of the second Slink64 CDF word

Definition at line 48 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getSourceId ( ) const
inline

get the source id from the CDF header

Definition at line 32 of file CastorCTDCHeader.h.

Referenced by CastorCtdcUnpacker::unpack().

bool CastorCTDCHeader::getSpigotCRCError ( unsigned int  nspigot) const
inline

Read the "CRC-Mismatch" bit for this spigot.

Definition at line 100 of file CastorCTDCHeader.h.

int CastorCTDCHeader::getSpigotData ( int  nspigot,
CastorCORData decodeTool,
int  validSize 
) const

Load the given decoder with the pointer and length from this spigot Returns 0 on success Returns -1 if spigot points to data area beyond validSize

Definition at line 22 of file CastorCTDCHeader.cc.

References CastorCORData::adoptData(), newFWLiteAna::base, CastorCTDCHeader(), i, hltrates_dqm_sourceclient-live_cfg::offset, and spigotInfo.

Referenced by CastorCtdcUnpacker::unpack().

22  {
23  const unsigned short* base=((unsigned short*)this)+sizeof(CastorCTDCHeader)/sizeof(unsigned short);
24  int offset=0,i,len=0;
25  for (i=0; i<=nspigot; i++) {
26  offset+=len;
27  len=(spigotInfo[i]&0x3FF)*2;
28  }
29  if ((offset+len+sizeof(CastorCTDCHeader)/sizeof(unsigned short))<(validSize/sizeof(unsigned short))) {
30  decodeTool.adoptData(base+offset,len);
31  return 0;
32  } else { return -1; }
33 }
tuple base
Main Program
Definition: newFWLiteAna.py:91
int i
Definition: DBlmapReader.cc:9
void adoptData(const unsigned short *data, int length)
unsigned int spigotInfo[4]
unsigned int CastorCTDCHeader::getSpigotDataLength ( int  nspigot) const
inline

Get the size (in 32-bit words) of the data from this spigot

Definition at line 87 of file CastorCTDCHeader.h.

Referenced by copyMergerData(), copySpigotData(), and operator<<().

bool CastorCTDCHeader::getSpigotDataTruncated ( unsigned int  nspigot) const
inline

Read the "TRUNCATED" bit for this spigot; LRB truncated data (took too long)

Definition at line 98 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::getSpigotEnabled ( unsigned int  nspigot) const
inline

Read the "ENABLED" bit for this spigot.

Definition at line 90 of file CastorCTDCHeader.h.

Referenced by operator<<().

unsigned char CastorCTDCHeader::getSpigotErrorBits ( unsigned int  nspigot) const
inline

Access the HTR error bits (decoding tbd)

Definition at line 102 of file CastorCTDCHeader.h.

Referenced by operator<<().

bool CastorCTDCHeader::getSpigotErrorFlag ( int  nspigot) const
inline

Get the value flagging a spigot's summary of error flags.

Definition at line 62 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::getSpigotPresent ( unsigned int  nspigot) const
inline

Read the "PRESENT" bit for this spigot.

Definition at line 92 of file CastorCTDCHeader.h.

Referenced by operator<<(), and CastorCtdcUnpacker::unpack().

int CastorCTDCHeader::getSpigotSummary ( int  nspigot) const
inline

Get a given spigot summary from the DCC Header

Definition at line 78 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::getSpigotValid ( unsigned int  nspigot) const
inline

Read the "VALID" bit for this spigot; TTC EvN matched HTR EvN.

Definition at line 96 of file CastorCTDCHeader.h.

Referenced by operator<<().

unsigned int CastorCTDCHeader::getTotalLengthBytes ( ) const

Determine the expected total length of this packet in bytes

Definition at line 15 of file CastorCTDCHeader.cc.

References CastorCTDCHeader(), i, SPIGOT_COUNT, and spigotInfo.

15  {
16  unsigned int totalSize=sizeof(CastorCTDCHeader);
17  for (int i=0; i<SPIGOT_COUNT+1; i++) // includes merger pay load
18  totalSize+=(spigotInfo[i]&0x3FF)*4;
19  return totalSize; // doesn't include the trailer
20 }
int i
Definition: DBlmapReader.cc:9
static const int SPIGOT_COUNT
unsigned int spigotInfo[4]
bool CastorCTDCHeader::SawCT_BcN_MxMx ( ) const
inline

Definition at line 72 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawCT_EvN_MxMx ( ) const
inline

Definition at line 71 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawL1A_BcN_MxMx ( ) const
inline

Definition at line 70 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawL1A_EvN_MxMx ( ) const
inline

Definition at line 69 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawOrbitLengthErr ( ) const
inline

Definition at line 73 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawTTC_DoubErr ( ) const
inline

Definition at line 75 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawTTC_SingErr ( ) const
inline

Definition at line 74 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawTTS_BSY ( ) const
inline

Definition at line 67 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawTTS_OFW ( ) const
inline

Get the status of these error counters in the DCC motherboard.

Definition at line 66 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::SawTTS_SYN ( ) const
inline

Definition at line 68 of file CastorCTDCHeader.h.

void CastorCTDCHeader::setHeader ( int  sourceid,
int  bcn,
int  l1aN,
int  orbN 
)

setup the header

Definition at line 48 of file CastorCTDCHeader.cc.

References commondataformat0, and commondataformat1.

Referenced by CastorCtdcPacker::pack().

48  {
49  commondataformat0=0x8|((sourceid&0xFFF)<<8)|((bcn&0xFFF)<<20);
50  commondataformat1=0x50000000u|(l1aN&0xFFFFFF);
51 }
unsigned int commondataformat0
unsigned int commondataformat1
bool CastorCTDCHeader::thereIsASecondCDFHeaderWord ( ) const
inline

get the bit indicating that another CDF header Slink64 word follows the first one.

Definition at line 28 of file CastorCTDCHeader.h.

bool CastorCTDCHeader::thereIsAThirdCDFHeaderWord ( ) const
inline

Check the third bit of second Slink64 CDF word

Definition at line 44 of file CastorCTDCHeader.h.

Member Data Documentation

unsigned int CastorCTDCHeader::commondataformat0
private

Definition at line 124 of file CastorCTDCHeader.h.

Referenced by clear(), and setHeader().

unsigned int CastorCTDCHeader::commondataformat1
private

Definition at line 125 of file CastorCTDCHeader.h.

Referenced by clear(), and setHeader().

unsigned int CastorCTDCHeader::commondataformat2
private

Definition at line 126 of file CastorCTDCHeader.h.

Referenced by clear().

unsigned int CastorCTDCHeader::commondataformat3
private

Definition at line 127 of file CastorCTDCHeader.h.

Referenced by clear().

unsigned int CastorCTDCHeader::ctdch0
private

Definition at line 128 of file CastorCTDCHeader.h.

Referenced by clear(), copyMergerData(), and copySpigotData().

unsigned int CastorCTDCHeader::ctdch1
private

Definition at line 129 of file CastorCTDCHeader.h.

Referenced by clear().

const int CastorCTDCHeader::SPIGOT_COUNT = 2
static
unsigned int CastorCTDCHeader::spigotInfo[4]
private