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
HcalDTCHeader Class Reference

#include <HcalDTCHeader.h>

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! More...
 
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. More...
 
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. More...
 
bool getSlotPresent (unsigned int nslot) const
 Read the "PRESENT" bit for this slot. More...
 
int getSlotSummary (int nslot) const
 
bool getSlotValid (unsigned int nslot) const
 Read the "VALID" bit for this slot; TTC EvN matched HTR EvN. More...
 
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().

15 { }

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.

45 { return ( (commondataformat1>>28) & 0x0F ); }
uint32_t commondataformat1
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.

55 { return ( (commondataformat3>>28) & 0x0F); }
uint32_t commondataformat3
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.

Referenced by Vispa.Views.WidgetView.WidgetView::closeEvent(), Vispa.Views.BoxDecayView.BoxDecayView::closeEvent(), Vispa.Share.FindAlgorithm.FindAlgorithm::findUsingFindDialog(), Vispa.Views.LineDecayView.LineDecayView::setDataObjects(), Vispa.Views.WidgetView.WidgetView::setDataObjects(), Vispa.Views.TreeView.TreeView::updateContent(), Vispa.Views.TableView.TableView::updateContent(), Vispa.Views.BoxDecayView.BoxDecayView::updateContent(), and Vispa.Views.PropertyView.PropertyView::updateContent().

37  {
39  commondataformat1=0x50000000u;
42  dcch0=0x1; // format version 1
43  dcch1=0;
44  for (int i=0; i<SLOT_COUNT; i++)
45  slotInfo[i]=0;
46 }
int i
Definition: DBlmapReader.cc:9
uint16_t slotInfo[12]
uint32_t commondataformat0
uint32_t commondataformat2
uint32_t dcch1
uint32_t commondataformat1
uint32_t dcch0
uint32_t commondataformat3
static const int SLOT_COUNT
Definition: HcalDTCHeader.h:22
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.

53  {
54  if (slot_id==0 || slot_id>(unsigned int)SLOT_COUNT) return;
55  // construct the slot info
56  slotInfo[slot_id-1]=(data.getRawLength())|0xc000;
57  if (valid) slotInfo[slot_id-1]|=0x2000;
58  // status info...
59  // if (valid) dcch0|=(1<<(slot_id+14));
60  // copy
61  unsigned int lenSoFar=0;
62  for (unsigned int i=1; i<slot_id; i++) lenSoFar+=getSlotDataLength(i);
63  unsigned short* startingPoint=((unsigned short*)this)+sizeof(HcalDTCHeader)/sizeof(unsigned short)+lenSoFar;
64  memcpy(startingPoint,data.getRawData(),sizeof(unsigned short)*data.getRawLength());
65  // update the trailer...
66  lenSoFar+=data.getRawLength();
67  uint32_t* trailer=((uint32_t*)this)+sizeof(HcalDTCHeader)/sizeof(uint32_t)+lenSoFar/2;
68  int len64=sizeof(HcalDTCHeader)/8+lenSoFar/4+1;
69  trailer[1]=0;
70  trailer[0]=0xA0000000u|len64;
71 }
int i
Definition: DBlmapReader.cc:9
uint16_t slotInfo[12]
const int getRawLength() const
Get the length of the raw data.
Definition: HcalHTRData.h:41
const unsigned short * getRawData() const
Get a pointer to the raw data.
Definition: HcalHTRData.h:38
unsigned int getSlotDataLength(int nslot) const
Definition: HcalDTCHeader.h:77
static const int SLOT_COUNT
Definition: HcalDTCHeader.h:22
int HcalDTCHeader::getBunchId ( ) const
inline

get the bunch id from the CDF header

Definition at line 39 of file HcalDTCHeader.h.

References commondataformat0.

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

Definition at line 59 of file HcalDTCHeader.h.

References commondataformat3.

Referenced by isCalibType().

59 { return HcalCalibrationEventType ((commondataformat3>>24)&0x0000000F);}
HcalCalibrationEventType
uint32_t commondataformat3
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.

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

Get the Format Version of the Common Data Format

Definition at line 35 of file HcalDTCHeader.h.

References commondataformat0.

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

Definition at line 62 of file HcalDTCHeader.h.

References dcch0.

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

get the Event Number from the CDF header

Definition at line 41 of file HcalDTCHeader.h.

References commondataformat1.

41 { return (commondataformat1 & 0x00FFFFFF); }
uint32_t commondataformat1
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.

51 { return ( ((commondataformat3 && 0xF) << 28) + ( commondataformat2>>4) ); }
uint32_t commondataformat2
uint32_t commondataformat3
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.

53 { return ( (commondataformat3>>4)&0x00FFFFFF ); }
uint32_t commondataformat3
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().

86 { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x1000); }
uint16_t slotInfo[12]
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(), newFWLiteAna::base, HcalDTCHeader(), i, evf::evtn::offset(), and slotInfo.

Referenced by HcalUnpacker::unpack().

24  {
25  const unsigned short* base=((unsigned short*)this)+sizeof(HcalDTCHeader)/sizeof(unsigned short);
26  int offset=0,i,len=0;
27  for (i=1; i<=nslot; i++) {
28  offset+=len;
29  len=(slotInfo[i-1]&0xFFF);
30  }
31  if ((offset+len+sizeof(HcalDTCHeader)/sizeof(unsigned short))<(validSize/sizeof(unsigned short))) {
32  decodeTool.adoptData(base+offset,len);
33  return 0;
34  } else { return -1; }
35 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
int i
Definition: DBlmapReader.cc:9
uint16_t slotInfo[12]
unsigned int offset(bool)
void adoptData(const unsigned short *data, int length)
Definition: HcalHTRData.cc:49
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<<().

77 { return (nslot<1 || nslot>12)?(0):(slotInfo[nslot-1]&0xfff); }
uint16_t slotInfo[12]
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<<().

80 { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x8000); }
uint16_t slotInfo[12]
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().

82 { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x4000); }
uint16_t slotInfo[12]
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.

67 { return slotInfo[nslot]; }
uint16_t slotInfo[12]
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<<().

84 { return (nslot<1 || nslot>12)?(false):(slotInfo[nslot-1]&0x2000); }
uint16_t slotInfo[12]
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().

37 { return (commondataformat0>>8)&0xFFF; }
uint32_t commondataformat0
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.

17  {
18  unsigned int totalSize=sizeof(HcalDTCHeader);
19  for (int i=0; i<SLOT_COUNT; i++)
20  totalSize+=(slotInfo[i]&0xFFF)*sizeof(uint16_t);
21  return totalSize;
22 }
int i
Definition: DBlmapReader.cc:9
uint16_t slotInfo[12]
static const int SLOT_COUNT
Definition: HcalDTCHeader.h:22
bool HcalDTCHeader::isCalibType ( ) const
inline

Get the Calibration Type

Definition at line 58 of file HcalDTCHeader.h.

References getCalibType().

58 { return ( 0 != getCalibType ());}
HcalCalibrationEventType getCalibType() const
Definition: HcalDTCHeader.h:59
int HcalDTCHeader::nDTCWords ( ) const
inline

Definition at line 64 of file HcalDTCHeader.h.

References dcch0.

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

Definition at line 63 of file HcalDTCHeader.h.

References dcch0.

63 { return ((dcch0>>20)& 0x0000000F); }
uint32_t dcch0
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.

48  {
49  commondataformat0=0x8|((sourceid&0xFFF)<<8)|((bcn&0xFFF)<<20);
50  commondataformat1=0x50000000u|(l1aN&0xFFFFFF);
51 }
uint32_t commondataformat0
uint32_t commondataformat1
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.

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

Check the third bit of second Slink64 CDF word

Definition at line 49 of file HcalDTCHeader.h.

References commondataformat2.

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

Member Data Documentation

uint32_t HcalDTCHeader::commondataformat0
private
uint32_t HcalDTCHeader::commondataformat1
private
uint32_t HcalDTCHeader::commondataformat2
private

Definition at line 106 of file HcalDTCHeader.h.

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

uint32_t HcalDTCHeader::commondataformat3
private
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