CMS 3D CMS Logo

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

Author
J. Mans - UMD

Definition at line 18 of file HcalDTCHeader.h.

Constructor & Destructor Documentation

◆ HcalDTCHeader()

HcalDTCHeader::HcalDTCHeader ( )

Definition at line 13 of file HcalDTCHeader.cc.

13 {}

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

Member Function Documentation

◆ BOEshouldBe5Always()

unsigned short HcalDTCHeader::BOEshouldBe5Always ( ) const
inline

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

Definition at line 43 of file HcalDTCHeader.h.

43 { return ((commondataformat1 >> 28) & 0x0F); }

References commondataformat1.

◆ BOEshouldBeZeroAlways()

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 53 of file HcalDTCHeader.h.

53 { return ((commondataformat3 >> 28) & 0x0F); }

References commondataformat3.

◆ clear()

void HcalDTCHeader::clear ( void  )

clear the contents of this header

Definition at line 37 of file HcalDTCHeader.cc.

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 }

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

◆ copySlotData()

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.

53  {
54  if (slot_id == 0 || slot_id > (unsigned int)SLOT_COUNT)
55  return;
56  // construct the slot info
57  slotInfo[slot_id - 1] = (data.getRawLength()) | 0xc000;
58  if (valid)
59  slotInfo[slot_id - 1] |= 0x2000;
60  // status info...
61  // if (valid) dcch0|=(1<<(slot_id+14));
62  // copy
63  unsigned int lenSoFar = 0;
64  for (unsigned int i = 1; i < slot_id; i++)
65  lenSoFar += getSlotDataLength(i);
66  unsigned short* startingPoint = ((unsigned short*)this) + sizeof(HcalDTCHeader) / sizeof(unsigned short) + lenSoFar;
67  memcpy(startingPoint, data.getRawData(), sizeof(unsigned short) * data.getRawLength());
68  // update the trailer...
69  lenSoFar += data.getRawLength();
70  uint32_t* trailer = ((uint32_t*)this) + sizeof(HcalDTCHeader) / sizeof(uint32_t) + lenSoFar / 2;
71  int len64 = sizeof(HcalDTCHeader) / 8 + lenSoFar / 4 + 1;
72  trailer[1] = 0;
73  trailer[0] = 0xA0000000u | len64;
74 }

References data, getSlotDataLength(), HcalDTCHeader(), mps_fire::i, SLOT_COUNT, slotInfo, and RunInfoPI::valid.

◆ getBunchId()

int HcalDTCHeader::getBunchId ( ) const
inline

get the bunch id from the CDF header

Definition at line 37 of file HcalDTCHeader.h.

37 { return (commondataformat0 >> 20) & 0xFFF; }

References commondataformat0.

◆ getCalibType()

HcalCalibrationEventType HcalDTCHeader::getCalibType ( ) const
inline

Definition at line 57 of file HcalDTCHeader.h.

57  {
58  return HcalCalibrationEventType((commondataformat3 >> 24) & 0x0000000F);
59  }

References commondataformat3.

Referenced by isCalibType().

◆ getCDFEventType()

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 41 of file HcalDTCHeader.h.

41 { return ((commondataformat1 >> 24) & 0x0F); }

References commondataformat1.

◆ getCDFversionNumber()

short HcalDTCHeader::getCDFversionNumber ( ) const
inline

Get the Format Version of the Common Data Format

Definition at line 33 of file HcalDTCHeader.h.

33 { return ((commondataformat0 >> 4) & 0x0F); }

References commondataformat0.

◆ getDTCDataFormatVersion()

short HcalDTCHeader::getDTCDataFormatVersion ( ) const
inline

Definition at line 62 of file HcalDTCHeader.h.

62 { return (dcch0 & 0xFF); }

References dcch0.

◆ getDTCEventNumber()

unsigned long HcalDTCHeader::getDTCEventNumber ( ) const
inline

get the Event Number from the CDF header

Definition at line 39 of file HcalDTCHeader.h.

39 { return (commondataformat1 & 0x00FFFFFF); }

References commondataformat1.

◆ getOrbitNumber()

unsigned int HcalDTCHeader::getOrbitNumber ( ) const
inline

Get the Orbit Number from the CDF.

Definition at line 49 of file HcalDTCHeader.h.

49 { return (((commondataformat3 & 0xF) << 28) + (commondataformat2 >> 4)); }

References commondataformat2, and commondataformat3.

◆ getSlink64ReservedBits()

unsigned int HcalDTCHeader::getSlink64ReservedBits ( ) const
inline

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

Definition at line 51 of file HcalDTCHeader.h.

51 { return ((commondataformat3 >> 4) & 0x00FFFFFF); }

References commondataformat3.

◆ getSlotCRCError()

bool HcalDTCHeader::getSlotCRCError ( unsigned int  nslot) const
inline

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

Definition at line 93 of file HcalDTCHeader.h.

93  {
94  return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x1000);
95  }

References slotInfo.

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

◆ getSlotData()

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 22 of file HcalDTCHeader.cc.

22  {
23  const uint16_t* base = ((const uint16_t*)this) + sizeof(HcalDTCHeader) / sizeof(uint16_t);
24  int offset = 0, i, len = 0;
25  for (i = 1; i <= nslot; i++) {
26  offset += len;
27  len = (slotInfo[i - 1] & 0xFFF);
28  }
29  if ((offset + len + sizeof(HcalDTCHeader) / sizeof(uint16_t)) < (validSize / sizeof(uint16_t))) {
30  decodeTool.adoptData(base + offset, len);
31  return 0;
32  } else {
33  return -1;
34  }
35 }

References HcalHTRData::adoptData(), newFWLiteAna::base, HcalDTCHeader(), mps_fire::i, hltrates_dqm_sourceclient-live_cfg::offset, and slotInfo.

Referenced by HcalUnpacker::unpackVME().

◆ getSlotDataLength()

unsigned int HcalDTCHeader::getSlotDataLength ( int  nslot) const
inline

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

Definition at line 76 of file HcalDTCHeader.h.

76  {
77  return (nslot < 1 || nslot > 12) ? (0) : (slotInfo[nslot - 1] & 0xfff);
78  }

References slotInfo.

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

◆ getSlotEnabled()

bool HcalDTCHeader::getSlotEnabled ( unsigned int  nslot) const
inline

Read the "ENABLED" bit for this slot.

Definition at line 81 of file HcalDTCHeader.h.

81  {
82  return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x8000);
83  }

References slotInfo.

Referenced by operator<<().

◆ getSlotPresent()

bool HcalDTCHeader::getSlotPresent ( unsigned int  nslot) const
inline

Read the "PRESENT" bit for this slot.

Definition at line 85 of file HcalDTCHeader.h.

85  {
86  return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x4000);
87  }

References slotInfo.

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

◆ getSlotSummary()

int HcalDTCHeader::getSlotSummary ( int  nslot) const
inline

Get a given slot summary from the DTC Header

Definition at line 67 of file HcalDTCHeader.h.

67 { return slotInfo[nslot]; }

References slotInfo.

◆ getSlotValid()

bool HcalDTCHeader::getSlotValid ( unsigned int  nslot) const
inline

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

Definition at line 89 of file HcalDTCHeader.h.

89  {
90  return (nslot < 1 || nslot > 12) ? (false) : (slotInfo[nslot - 1] & 0x2000);
91  }

References slotInfo.

Referenced by operator<<().

◆ getSourceId()

int HcalDTCHeader::getSourceId ( ) const
inline

get the source id from the CDF header

Definition at line 35 of file HcalDTCHeader.h.

35 { return (commondataformat0 >> 8) & 0xFFF; }

References commondataformat0.

Referenced by HcalUnpacker::unpackVME().

◆ getTotalLengthBytes()

unsigned int HcalDTCHeader::getTotalLengthBytes ( ) const

Determine the expected total length of this packet in bytes

Definition at line 15 of file HcalDTCHeader.cc.

15  {
16  unsigned int totalSize = sizeof(HcalDTCHeader);
17  for (int i = 0; i < SLOT_COUNT; i++)
18  totalSize += (slotInfo[i] & 0xFFF) * sizeof(uint16_t);
19  return totalSize;
20 }

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

◆ isCalibType()

bool HcalDTCHeader::isCalibType ( ) const
inline

Get the Calibration Type

Definition at line 56 of file HcalDTCHeader.h.

56 { return (0 != getCalibType()); }

References getCalibType().

◆ nDTCWords()

int HcalDTCHeader::nDTCWords ( ) const
inline

Definition at line 64 of file HcalDTCHeader.h.

64 { return ((dcch0 >> 8) & 0x00000FFF); }

References dcch0.

◆ nSlotWords()

int HcalDTCHeader::nSlotWords ( ) const
inline

Definition at line 63 of file HcalDTCHeader.h.

63 { return ((dcch0 >> 20) & 0x0000000F); }

References dcch0.

◆ setHeader()

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

setup the header

Definition at line 48 of file HcalDTCHeader.cc.

48  {
49  commondataformat0 = 0x8 | ((sourceid & 0xFFF) << 8) | ((bcn & 0xFFF) << 20);
50  commondataformat1 = 0x50000000u | (l1aN & 0xFFFFFF);
51 }

References commondataformat0, and commondataformat1.

◆ thereIsASecondCDFHeaderWord()

bool HcalDTCHeader::thereIsASecondCDFHeaderWord ( ) const
inline

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

Definition at line 31 of file HcalDTCHeader.h.

31 { return ((commondataformat0 >> 3) & 0x0001); }

References commondataformat0.

◆ thereIsAThirdCDFHeaderWord()

bool HcalDTCHeader::thereIsAThirdCDFHeaderWord ( ) const
inline

Check the third bit of second Slink64 CDF word

Definition at line 47 of file HcalDTCHeader.h.

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

References commondataformat2.

Member Data Documentation

◆ commondataformat0

uint32_t HcalDTCHeader::commondataformat0
private

◆ commondataformat1

uint32_t HcalDTCHeader::commondataformat1
private

◆ commondataformat2

uint32_t HcalDTCHeader::commondataformat2
private

Definition at line 115 of file HcalDTCHeader.h.

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

◆ commondataformat3

uint32_t HcalDTCHeader::commondataformat3
private

◆ dcch0

uint32_t HcalDTCHeader::dcch0
private

Definition at line 117 of file HcalDTCHeader.h.

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

◆ dcch1

uint32_t HcalDTCHeader::dcch1
private

Definition at line 118 of file HcalDTCHeader.h.

Referenced by clear().

◆ MAXIMUM_SLOT

const int HcalDTCHeader::MAXIMUM_SLOT = 12
static

Definition at line 22 of file HcalDTCHeader.h.

Referenced by HcalUnpacker::unpackVME().

◆ MINIMUM_SLOT

const int HcalDTCHeader::MINIMUM_SLOT = 1
static

Definition at line 21 of file HcalDTCHeader.h.

◆ SLOT_COUNT

const int HcalDTCHeader::SLOT_COUNT = 12
static

Definition at line 20 of file HcalDTCHeader.h.

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

◆ slotInfo

uint16_t HcalDTCHeader::slotInfo[12]
private
mps_fire.i
i
Definition: mps_fire.py:428
HcalDTCHeader::getSlotDataLength
unsigned int getSlotDataLength(int nslot) const
Definition: HcalDTCHeader.h:76
HcalDTCHeader::dcch0
uint32_t dcch0
Definition: HcalDTCHeader.h:117
HcalDTCHeader::getCalibType
HcalCalibrationEventType getCalibType() const
Definition: HcalDTCHeader.h:57
HcalDTCHeader::SLOT_COUNT
static const int SLOT_COUNT
Definition: HcalDTCHeader.h:20
HcalCalibrationEventType
HcalCalibrationEventType
Definition: HcalCalibrationEventTypes.h:4
HcalDTCHeader::commondataformat2
uint32_t commondataformat2
Definition: HcalDTCHeader.h:115
HcalDTCHeader::commondataformat1
uint32_t commondataformat1
Definition: HcalDTCHeader.h:114
HcalHTRData::adoptData
void adoptData(const unsigned short *data, int length)
Definition: HcalHTRData.cc:46
HcalDTCHeader::commondataformat3
uint32_t commondataformat3
Definition: HcalDTCHeader.h:116
HcalDTCHeader::HcalDTCHeader
HcalDTCHeader()
Definition: HcalDTCHeader.cc:13
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
HcalDTCHeader::dcch1
uint32_t dcch1
Definition: HcalDTCHeader.h:118
HcalDTCHeader::slotInfo
uint16_t slotInfo[12]
Definition: HcalDTCHeader.h:119
HcalDTCHeader::commondataformat0
uint32_t commondataformat0
Definition: HcalDTCHeader.h:113
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
HcalDTCHeader
Definition: HcalDTCHeader.h:18