CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Private Attributes

CastorCTDCHeader Class Reference

#include <CastorCTDCHeader.h>

List of all members.

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!
int getAcceptTimeTTS () const
int getBunchId () const
bool getBxMismatchWithDCC (unsigned int nspigot) const
 Read the "BxID FAILS TO MATCH WITH DCC" bit for this spigot.
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)
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.
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)
bool getSpigotEnabled (unsigned int nspigot) const
 Read the "ENABLED" bit for this spigot.
unsigned char getSpigotErrorBits (unsigned int nspigot) const
 Access the HTR error bits (decoding tbd)
bool getSpigotErrorFlag (int nspigot) const
bool getSpigotPresent (unsigned int nspigot) const
 Read the "PRESENT" bit for this spigot.
int getSpigotSummary (int nspigot) const
bool getSpigotValid (unsigned int nspigot) const
 Read the "VALID" bit for this spigot; TTC EvN matched HTR EvN.
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

Date:
2009/02/20 17:46:27
Revision:
1.1
Author:
A. Campbell - DESY

Definition at line 19 of file CastorCTDCHeader.h.


Constructor & Destructor Documentation

CastorCTDCHeader::CastorCTDCHeader ( )

Definition at line 15 of file CastorCTDCHeader.cc.

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

{ }

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 42 of file CastorCTDCHeader.h.

References commondataformat1.

{ return ( (commondataformat1>>28) & 0x0F ); }
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 52 of file CastorCTDCHeader.h.

References commondataformat3.

{ return ( (commondataformat3>>28) & 0x0F); }
void CastorCTDCHeader::clear ( void  )

clear the contents of this header

Definition at line 37 of file CastorCTDCHeader.cc.

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

Referenced by CastorCtdcPacker::pack().

                             {
  commondataformat0=0;
  commondataformat1=0x50000000u;
  commondataformat2=0;
  commondataformat3=0;
  ctdch0=0x1; // format version 1
  ctdch1=0;
  for (int i=0; i<3; i++) 
    spigotInfo[i]=0;
  spigotInfo[3]=0x12345678; // end DCC header pattern

}
void CastorCTDCHeader::copyMergerData ( const CastorMergerData data,
bool  valid 
)

Definition at line 76 of file CastorCTDCHeader.cc.

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

Referenced by CastorCtdcPacker::pack().

                                                                              {
  unsigned int spigot_id = 2;
  // construct the spigot info
  spigotInfo[spigot_id]=(data.getRawLength()/2)|0xc000; // Enabled & Present
  if (valid) spigotInfo[spigot_id]|=0x2000; // Valid
  spigotInfo[spigot_id]|=((data.getErrorsWord()&0xFF)<<24);
  // status info...
  if (valid) ctdch0|=(1<<(spigot_id+14));
  // copy
  unsigned int lenSoFar=0;
  for (unsigned int i=0; i<spigot_id; i++) lenSoFar+=getSpigotDataLength(i);
  unsigned short* startingPoint=((unsigned short*)this)+sizeof(CastorCTDCHeader)/sizeof(unsigned short)+lenSoFar*2;
  memcpy(startingPoint,data.getRawData(),sizeof(unsigned short)*data.getRawLength());
  // update the trailer...
  lenSoFar+=data.getRawLength()/2; // 32-bit words
  uint32_t* trailer=((uint32_t*)this)+sizeof(CastorCTDCHeader)/sizeof(uint32_t)+lenSoFar;
  int len64=sizeof(CastorCTDCHeader)/8+lenSoFar/2+1; 
  trailer[1]=0;
  trailer[0]=0xA0000000u|len64;
}
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 55 of file CastorCTDCHeader.cc.

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

Referenced by CastorCtdcPacker::pack().

                                                                                                                                 {
  if (spigot_id>=(unsigned int)SPIGOT_COUNT) return;
  // construct the spigot info
  spigotInfo[spigot_id]=(data.getRawLength()/2)|0xc000;
  if (valid) spigotInfo[spigot_id]|=0x2000;
  spigotInfo[spigot_id]|=(LRB_error_word<<16)|((data.getErrorsWord()&0xFF)<<24);
  // status info...
  if (valid) ctdch0|=(1<<(spigot_id+14));
  // copy
  unsigned int lenSoFar=0;
  for (unsigned int i=0; i<spigot_id; i++) lenSoFar+=getSpigotDataLength(i);
  unsigned short* startingPoint=((unsigned short*)this)+sizeof(CastorCTDCHeader)/sizeof(unsigned short)+lenSoFar*2;
  memcpy(startingPoint,data.getRawData(),sizeof(unsigned short)*data.getRawLength());
  // update the trailer...
  lenSoFar+=data.getRawLength()/2; // 32-bit words
  uint32_t* trailer=((uint32_t*)this)+sizeof(CastorCTDCHeader)/sizeof(uint32_t)+lenSoFar;
  int len64=sizeof(CastorCTDCHeader)/8+lenSoFar/2+1; 
  trailer[1]=0;
  trailer[0]=0xA0000000u|len64;
}
int CastorCTDCHeader::getAcceptTimeTTS ( ) const [inline]

Definition at line 56 of file CastorCTDCHeader.h.

References ctdch0.

{ return ((ctdch0>>8)& 0x0000000F); }
int CastorCTDCHeader::getBunchId ( ) const [inline]

get the bunch id from the CDF header

Definition at line 36 of file CastorCTDCHeader.h.

References commondataformat0.

{ return (commondataformat0>>20)&0xFFF; }
bool CastorCTDCHeader::getBxMismatchWithDCC ( unsigned int  nspigot) const [inline]

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

Definition at line 96 of file CastorCTDCHeader.h.

References spigotInfo.

{ return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x2000); }
int CastorCTDCHeader::getByte1Zeroes ( ) const [inline]

Definition at line 57 of file CastorCTDCHeader.h.

References ctdch0.

{  return ((ctdch0>>12)& 0x00000003); }
int CastorCTDCHeader::getByte3Zeroes ( ) const [inline]

Definition at line 59 of file CastorCTDCHeader.h.

References ctdch0.

{  return ((ctdch0>>29)& 0x00000007); }
int CastorCTDCHeader::getByte567Zeroes ( ) const [inline]

Definition at line 61 of file CastorCTDCHeader.h.

References ctdch1.

{  return (ctdch1 & 0xFF00FC00); }
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 40 of file CastorCTDCHeader.h.

References commondataformat1.

{ return ( (commondataformat1>>24) & 0x0F ); }
short CastorCTDCHeader::getCDFversionNumber ( ) const [inline]

Get the Format Version of the Common Data Format

Definition at line 32 of file CastorCTDCHeader.h.

References commondataformat0.

{return ((commondataformat0>>4) & 0x0F); }
short CastorCTDCHeader::getDCCDataFormatVersion ( ) const [inline]

Definition at line 55 of file CastorCTDCHeader.h.

References ctdch0.

{ return (ctdch0 & 0xFF); }
unsigned long CastorCTDCHeader::getDCCEventNumber ( ) const [inline]

get the Event Number from the CDF header

Definition at line 38 of file CastorCTDCHeader.h.

References commondataformat1.

{ return (commondataformat1 & 0x00FFFFFF); }
int CastorCTDCHeader::getDCCStatus ( ) const [inline]
int CastorCTDCHeader::getHTRStatusBits ( ) const [inline]

Definition at line 58 of file CastorCTDCHeader.h.

References ctdch0.

{ return ((ctdch0>>14)& 0x00007FFF); }
unsigned char CastorCTDCHeader::getLRBErrorBits ( unsigned int  nspigot) const [inline]

Access the Link Receiver Board error bits (decoding tbd)

Definition at line 106 of file CastorCTDCHeader.h.

References spigotInfo.

{ return (nspigot>=3)?(0):((unsigned char)(spigotInfo[nspigot]>>16)); }
unsigned int CastorCTDCHeader::getOrbitNumber ( ) const [inline]

Get the Orbit Number from the CDF.

Definition at line 48 of file CastorCTDCHeader.h.

References commondataformat2.

{ return (commondataformat2>>4); }
unsigned int CastorCTDCHeader::getSlink64ReservedBits ( ) const [inline]

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

Definition at line 50 of file CastorCTDCHeader.h.

References commondataformat3.

{ return (  (commondataformat3>>4)&0x00FFFFFF ); }
int CastorCTDCHeader::getSourceId ( ) const [inline]

get the source id from the CDF header

Definition at line 34 of file CastorCTDCHeader.h.

References commondataformat0.

Referenced by CastorCtdcUnpacker::unpack().

{ return (commondataformat0>>8)&0xFFF; }
bool CastorCTDCHeader::getSpigotCRCError ( unsigned int  nspigot) const [inline]

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

Definition at line 102 of file CastorCTDCHeader.h.

References spigotInfo.

{ return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x0400); }
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 24 of file CastorCTDCHeader.cc.

References CastorCORData::adoptData(), CastorCTDCHeader(), i, evf::evtn::offset(), and spigotInfo.

Referenced by CastorCtdcUnpacker::unpack().

                                                                                               {
  const unsigned short* base=((unsigned short*)this)+sizeof(CastorCTDCHeader)/sizeof(unsigned short);
  int offset=0,i,len=0;
  for (i=0; i<=nspigot; i++) {
    offset+=len;
    len=(spigotInfo[i]&0x3FF)*2;
  }
  if ((offset+len+sizeof(CastorCTDCHeader)/sizeof(unsigned short))<(validSize/sizeof(unsigned short))) {
    decodeTool.adoptData(base+offset,len);
    return 0;
  } else { return -1; }
}
unsigned int CastorCTDCHeader::getSpigotDataLength ( int  nspigot) const [inline]

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

Definition at line 89 of file CastorCTDCHeader.h.

References spigotInfo.

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

{ return (nspigot>=3)?(0):(spigotInfo[nspigot]&0x3ff); }
bool CastorCTDCHeader::getSpigotDataTruncated ( unsigned int  nspigot) const [inline]

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

Definition at line 100 of file CastorCTDCHeader.h.

References spigotInfo.

{ return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x0800); }
bool CastorCTDCHeader::getSpigotEnabled ( unsigned int  nspigot) const [inline]

Read the "ENABLED" bit for this spigot.

Definition at line 92 of file CastorCTDCHeader.h.

References spigotInfo.

Referenced by operator<<().

{ return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x8000); }
unsigned char CastorCTDCHeader::getSpigotErrorBits ( unsigned int  nspigot) const [inline]

Access the HTR error bits (decoding tbd)

Definition at line 104 of file CastorCTDCHeader.h.

References spigotInfo.

Referenced by operator<<().

{ return (nspigot>=3)?(0):((unsigned char)(spigotInfo[nspigot]>>24)); }
bool CastorCTDCHeader::getSpigotErrorFlag ( int  nspigot) const [inline]

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

Definition at line 64 of file CastorCTDCHeader.h.

References ctdch0.

                                                    { 
    return (( ctdch0>>(14+nspigot) )&0x0001);  }
bool CastorCTDCHeader::getSpigotPresent ( unsigned int  nspigot) const [inline]

Read the "PRESENT" bit for this spigot.

Definition at line 94 of file CastorCTDCHeader.h.

References spigotInfo.

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

{ return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x4000); }
int CastorCTDCHeader::getSpigotSummary ( int  nspigot) const [inline]

Get a given spigot summary from the DCC Header

Definition at line 80 of file CastorCTDCHeader.h.

References spigotInfo.

{ return spigotInfo[nspigot]; }
bool CastorCTDCHeader::getSpigotValid ( unsigned int  nspigot) const [inline]

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

Definition at line 98 of file CastorCTDCHeader.h.

References spigotInfo.

Referenced by operator<<().

{ return (nspigot>=3)?(false):(spigotInfo[nspigot]&0x1000); }
unsigned int CastorCTDCHeader::getTotalLengthBytes ( ) const

Determine the expected total length of this packet in bytes

Definition at line 17 of file CastorCTDCHeader.cc.

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

                                                         { 
  unsigned int totalSize=sizeof(CastorCTDCHeader);
  for (int i=0; i<SPIGOT_COUNT+1; i++)    // includes merger pay load
    totalSize+=(spigotInfo[i]&0x3FF)*4;
  return totalSize; // doesn't include the trailer
}  
bool CastorCTDCHeader::SawCT_BcN_MxMx ( ) const [inline]

Definition at line 74 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>6) & 0x00000001);}
bool CastorCTDCHeader::SawCT_EvN_MxMx ( ) const [inline]

Definition at line 73 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>5) & 0x00000001);}
bool CastorCTDCHeader::SawL1A_BcN_MxMx ( ) const [inline]

Definition at line 72 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>4) & 0x00000001);}
bool CastorCTDCHeader::SawL1A_EvN_MxMx ( ) const [inline]

Definition at line 71 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>3) & 0x00000001);}
bool CastorCTDCHeader::SawOrbitLengthErr ( ) const [inline]

Definition at line 75 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>7) & 0x00000001);}
bool CastorCTDCHeader::SawTTC_DoubErr ( ) const [inline]

Definition at line 77 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>9) & 0x00000001);}
bool CastorCTDCHeader::SawTTC_SingErr ( ) const [inline]

Definition at line 76 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>8) & 0x00000001);}
bool CastorCTDCHeader::SawTTS_BSY ( ) const [inline]

Definition at line 69 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>1) & 0x00000001);}
bool CastorCTDCHeader::SawTTS_OFW ( ) const [inline]

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

Definition at line 68 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>0) & 0x00000001);}
bool CastorCTDCHeader::SawTTS_SYN ( ) const [inline]

Definition at line 70 of file CastorCTDCHeader.h.

References getDCCStatus().

{ return ((getDCCStatus()>>2) & 0x00000001);}
void CastorCTDCHeader::setHeader ( int  sourceid,
int  bcn,
int  l1aN,
int  orbN 
)

setup the header

Definition at line 50 of file CastorCTDCHeader.cc.

References commondataformat0, and commondataformat1.

Referenced by CastorCtdcPacker::pack().

                                                                          {
  commondataformat0=0x8|((sourceid&0xFFF)<<8)|((bcn&0xFFF)<<20);
  commondataformat1=0x50000000u|(l1aN&0xFFFFFF);
}
bool CastorCTDCHeader::thereIsASecondCDFHeaderWord ( ) const [inline]

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

Definition at line 30 of file CastorCTDCHeader.h.

References commondataformat0.

{return ((commondataformat0>>3) & 0x0001); }
bool CastorCTDCHeader::thereIsAThirdCDFHeaderWord ( ) const [inline]

Check the third bit of second Slink64 CDF word

Definition at line 46 of file CastorCTDCHeader.h.

References commondataformat2.

{return ((commondataformat2>>3) & 0x0001); }

Member Data Documentation

unsigned int CastorCTDCHeader::commondataformat0 [private]
unsigned int CastorCTDCHeader::commondataformat1 [private]
unsigned int CastorCTDCHeader::commondataformat2 [private]

Definition at line 128 of file CastorCTDCHeader.h.

Referenced by clear(), getOrbitNumber(), and thereIsAThirdCDFHeaderWord().

unsigned int CastorCTDCHeader::commondataformat3 [private]

Definition at line 129 of file CastorCTDCHeader.h.

Referenced by BOEshouldBeZeroAlways(), clear(), and getSlink64ReservedBits().

unsigned int CastorCTDCHeader::ctdch0 [private]
unsigned int CastorCTDCHeader::ctdch1 [private]

Definition at line 131 of file CastorCTDCHeader.h.

Referenced by clear(), getByte567Zeroes(), and getDCCStatus().

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