CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Private Attributes

HcalDTCHeader Class Reference

#include <HcalDTCHeader.h>

List of all members.

Public Member Functions

unsigned short BOEshouldBe5Always () const
short BOEshouldBeZeroAlways () const
void clear ()
void copySlotData (unsigned int slot_id, const HcalHTRData &data, bool valid=true)
 Add the given HcalHTRData as the given slot's data. This should be done in increasing slot order!
int getBunchId () const
HcalCalibrationEventType getCalibType () const
unsigned short getCDFEventType () const
short getCDFversionNumber () const
short getDTCDataFormatVersion () const
unsigned long getDTCEventNumber () const
unsigned int getOrbitNumber () const
unsigned int getSlink64ReservedBits () const
bool getSlotCRCError (unsigned int nslot) const
 Read the "CRC-Mismatch" bit for this slot.
int getSlotData (int nslot, HcalHTRData &decodeTool, int validSize) const
unsigned int getSlotDataLength (int nslot) const
bool getSlotEnabled (unsigned int nslot) const
 Read the "ENABLED" bit for this slot.
bool getSlotPresent (unsigned int nslot) const
 Read the "PRESENT" bit for this slot.
int getSlotSummary (int nslot) const
bool getSlotValid (unsigned int nslot) const
 Read the "VALID" bit for this slot; TTC EvN matched HTR EvN.
int getSourceId () const
unsigned int getTotalLengthBytes () const
 HcalDTCHeader ()
bool isCalibType () const
int nDTCWords () const
int nSlotWords () const
void setHeader (int sourceid, int bcn, int l1aN, int orbN)
bool thereIsASecondCDFHeaderWord () const
bool thereIsAThirdCDFHeaderWord () const

Static Public Attributes

static const int MAXIMUM_SLOT = 12
static const int MINIMUM_SLOT = 1
static const int SLOT_COUNT = 12

Private Attributes

uint32_t commondataformat0
uint32_t commondataformat1
uint32_t commondataformat2
uint32_t commondataformat3
uint32_t dcch0
uint32_t dcch1
uint16_t slotInfo [12]

Detailed Description

Interpretive class for the header of a FED-format data block from the DTC -- the uTCA DAQ and timing card also called an AMC13

Date:
2012/10/22 14:05:56
Revision:
1.1
Author:
J. Mans - UMD

Definition at line 20 of file HcalDTCHeader.h.


Constructor & Destructor Documentation

HcalDTCHeader::HcalDTCHeader ( )

Definition at line 15 of file HcalDTCHeader.cc.

Referenced by copySlotData(), getSlotData(), and getTotalLengthBytes().

{ }

Member Function Documentation

unsigned short HcalDTCHeader::BOEshouldBe5Always ( ) const [inline]

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

Definition at line 45 of file HcalDTCHeader.h.

References commondataformat1.

{ return ( (commondataformat1>>28) & 0x0F ); }
short HcalDTCHeader::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 55 of file HcalDTCHeader.h.

References commondataformat3.

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

clear the contents of this header

Definition at line 37 of file HcalDTCHeader.cc.

References commondataformat0, commondataformat1, commondataformat2, commondataformat3, dcch0, dcch1, i, SLOT_COUNT, and slotInfo.

                          {
  commondataformat0=0;
  commondataformat1=0x50000000u;
  commondataformat2=0;
  commondataformat3=0;
  dcch0=0x1; // format version 1
  dcch1=0;
  for (int i=0; i<SLOT_COUNT; i++) 
    slotInfo[i]=0;
}
void HcalDTCHeader::copySlotData ( unsigned int  slot_id,
const HcalHTRData data,
bool  valid = true 
)

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

Parameters:
slot_id
slot_data
validflag
LRB_error_word

Definition at line 53 of file HcalDTCHeader.cc.

References HcalHTRData::getRawData(), HcalHTRData::getRawLength(), getSlotDataLength(), HcalDTCHeader(), i, SLOT_COUNT, and slotInfo.

                                                                                          {
  if (slot_id==0 || slot_id>(unsigned int)SLOT_COUNT) return;
  // construct the slot info
  slotInfo[slot_id-1]=(data.getRawLength())|0xc000;
  if (valid) slotInfo[slot_id-1]|=0x2000;
  // status info...
  //  if (valid) dcch0|=(1<<(slot_id+14));
  // copy
  unsigned int lenSoFar=0;
  for (unsigned int i=1; i<slot_id; i++) lenSoFar+=getSlotDataLength(i);
  unsigned short* startingPoint=((unsigned short*)this)+sizeof(HcalDTCHeader)/sizeof(unsigned short)+lenSoFar;
  memcpy(startingPoint,data.getRawData(),sizeof(unsigned short)*data.getRawLength());
  // update the trailer...
  lenSoFar+=data.getRawLength(); 
  uint32_t* trailer=((uint32_t*)this)+sizeof(HcalDTCHeader)/sizeof(uint32_t)+lenSoFar/2;
  int len64=sizeof(HcalDTCHeader)/8+lenSoFar/4+1; 
  trailer[1]=0;
  trailer[0]=0xA0000000u|len64;
}
int HcalDTCHeader::getBunchId ( ) const [inline]

get the bunch id from the CDF header

Definition at line 39 of file HcalDTCHeader.h.

References commondataformat0.

{ return (commondataformat0>>20)&0xFFF; }
HcalCalibrationEventType HcalDTCHeader::getCalibType ( ) const [inline]

Definition at line 59 of file HcalDTCHeader.h.

References commondataformat3.

Referenced by isCalibType().

{ return HcalCalibrationEventType ((commondataformat3>>24)&0x0000000F);}
unsigned short HcalDTCHeader::getCDFEventType ( ) const [inline]

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

Definition at line 43 of file HcalDTCHeader.h.

References commondataformat1.

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

Get the Format Version of the Common Data Format

Definition at line 35 of file HcalDTCHeader.h.

References commondataformat0.

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

Definition at line 62 of file HcalDTCHeader.h.

References dcch0.

{ return (dcch0 & 0xFF); }
unsigned long HcalDTCHeader::getDTCEventNumber ( ) const [inline]

get the Event Number from the CDF header

Definition at line 41 of file HcalDTCHeader.h.

References commondataformat1.

{ return (commondataformat1 & 0x00FFFFFF); }
unsigned int HcalDTCHeader::getOrbitNumber ( ) const [inline]

Get the Orbit Number from the CDF.

Definition at line 51 of file HcalDTCHeader.h.

References commondataformat2, and commondataformat3.

{ return ( ((commondataformat3 && 0xF) << 28) + ( commondataformat2>>4) ); }
unsigned int HcalDTCHeader::getSlink64ReservedBits ( ) const [inline]

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

Definition at line 53 of file HcalDTCHeader.h.

References commondataformat3.

{ return (  (commondataformat3>>4)&0x00FFFFFF ); }
bool HcalDTCHeader::getSlotCRCError ( unsigned int  nslot) const [inline]

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

Definition at line 86 of file HcalDTCHeader.h.

References slotInfo.

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

{ return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x1000); }
int HcalDTCHeader::getSlotData ( int  nslot,
HcalHTRData decodeTool,
int  validSize 
) const

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

Definition at line 24 of file HcalDTCHeader.cc.

References HcalHTRData::adoptData(), HcalDTCHeader(), i, evf::evtn::offset(), and slotInfo.

Referenced by HcalUnpacker::unpack().

                                                                                      {
  const unsigned short* base=((unsigned short*)this)+sizeof(HcalDTCHeader)/sizeof(unsigned short);
  int offset=0,i,len=0;
  for (i=1; i<=nslot; i++) {
    offset+=len;
    len=(slotInfo[i-1]&0xFFF);
  }
  if ((offset+len+sizeof(HcalDTCHeader)/sizeof(unsigned short))<(validSize/sizeof(unsigned short))) {
    decodeTool.adoptData(base+offset,len);
    return 0;
  } else { return -1; }
}
unsigned int HcalDTCHeader::getSlotDataLength ( int  nslot) const [inline]

Get the size (in 16-bit words) of the data from this slot

Definition at line 77 of file HcalDTCHeader.h.

References slotInfo.

Referenced by copySlotData(), and operator<<().

{ return (nslot<1 || nslot>12)?(0):(slotInfo[nslot-1]&0xfff); }
bool HcalDTCHeader::getSlotEnabled ( unsigned int  nslot) const [inline]

Read the "ENABLED" bit for this slot.

Definition at line 80 of file HcalDTCHeader.h.

References slotInfo.

Referenced by operator<<().

{ return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x8000); }
bool HcalDTCHeader::getSlotPresent ( unsigned int  nslot) const [inline]

Read the "PRESENT" bit for this slot.

Definition at line 82 of file HcalDTCHeader.h.

References slotInfo.

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

{ return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x4000); }
int HcalDTCHeader::getSlotSummary ( int  nslot) const [inline]

Get a given slot summary from the DTC Header

Definition at line 67 of file HcalDTCHeader.h.

References slotInfo.

{ return slotInfo[nslot]; }
bool HcalDTCHeader::getSlotValid ( unsigned int  nslot) const [inline]

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

Definition at line 84 of file HcalDTCHeader.h.

References slotInfo.

Referenced by operator<<().

{ return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x2000); }
int HcalDTCHeader::getSourceId ( ) const [inline]

get the source id from the CDF header

Definition at line 37 of file HcalDTCHeader.h.

References commondataformat0.

Referenced by HcalUnpacker::unpack().

{ return (commondataformat0>>8)&0xFFF; }
unsigned int HcalDTCHeader::getTotalLengthBytes ( ) const

Determine the expected total length of this packet in bytes

Definition at line 17 of file HcalDTCHeader.cc.

References HcalDTCHeader(), i, SLOT_COUNT, and slotInfo.

                                                      { 
  unsigned int totalSize=sizeof(HcalDTCHeader);
  for (int i=0; i<SLOT_COUNT; i++) 
    totalSize+=(slotInfo[i]&0xFFF)*sizeof(uint16_t);
  return totalSize;
}
bool HcalDTCHeader::isCalibType ( ) const [inline]

Get the Calibration Type

Definition at line 58 of file HcalDTCHeader.h.

References getCalibType().

{ return ( 0 != getCalibType ());}
int HcalDTCHeader::nDTCWords ( ) const [inline]

Definition at line 64 of file HcalDTCHeader.h.

References dcch0.

{ return ((dcch0>>8)& 0x00000FFF); }
int HcalDTCHeader::nSlotWords ( ) const [inline]

Definition at line 63 of file HcalDTCHeader.h.

References dcch0.

{ return ((dcch0>>20)& 0x0000000F); }
void HcalDTCHeader::setHeader ( int  sourceid,
int  bcn,
int  l1aN,
int  orbN 
)

setup the header

Definition at line 48 of file HcalDTCHeader.cc.

References commondataformat0, and commondataformat1.

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

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

Definition at line 33 of file HcalDTCHeader.h.

References commondataformat0.

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

Check the third bit of second Slink64 CDF word

Definition at line 49 of file HcalDTCHeader.h.

References commondataformat2.

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

Member Data Documentation

Definition at line 106 of file HcalDTCHeader.h.

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

uint32_t HcalDTCHeader::dcch0 [private]

Definition at line 108 of file HcalDTCHeader.h.

Referenced by clear(), getDTCDataFormatVersion(), nDTCWords(), and nSlotWords().

uint32_t HcalDTCHeader::dcch1 [private]

Definition at line 109 of file HcalDTCHeader.h.

Referenced by clear().

const int HcalDTCHeader::MAXIMUM_SLOT = 12 [static]

Definition at line 24 of file HcalDTCHeader.h.

Referenced by HcalUnpacker::unpack().

const int HcalDTCHeader::MINIMUM_SLOT = 1 [static]

Definition at line 23 of file HcalDTCHeader.h.

const int HcalDTCHeader::SLOT_COUNT = 12 [static]

Definition at line 22 of file HcalDTCHeader.h.

Referenced by clear(), copySlotData(), getTotalLengthBytes(), and operator<<().

uint16_t HcalDTCHeader::slotInfo[12] [private]