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.

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

13 {}

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.

References commondataformat1.

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

References commondataformat3.

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

◆ clear()

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, mps_fire::i, SLOT_COUNT, and slotInfo.

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 }
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:20

◆ 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.

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

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 }
uint16_t slotInfo[12]
unsigned int getSlotDataLength(int nslot) const
Definition: HcalDTCHeader.h:76
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
static const int SLOT_COUNT
Definition: HcalDTCHeader.h:20

◆ getBunchId()

int HcalDTCHeader::getBunchId ( ) const
inline

get the bunch id from the CDF header

Definition at line 37 of file HcalDTCHeader.h.

References commondataformat0.

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

◆ getCalibType()

HcalCalibrationEventType HcalDTCHeader::getCalibType ( ) const
inline

Definition at line 57 of file HcalDTCHeader.h.

References commondataformat3.

Referenced by isCalibType().

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

◆ 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.

References commondataformat1.

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

◆ getCDFversionNumber()

short HcalDTCHeader::getCDFversionNumber ( ) const
inline

Get the Format Version of the Common Data Format

Definition at line 33 of file HcalDTCHeader.h.

References commondataformat0.

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

◆ getDTCDataFormatVersion()

short HcalDTCHeader::getDTCDataFormatVersion ( ) const
inline

Definition at line 62 of file HcalDTCHeader.h.

References dcch0.

62 { return (dcch0 & 0xFF); }
uint32_t dcch0

◆ getDTCEventNumber()

unsigned long HcalDTCHeader::getDTCEventNumber ( ) const
inline

get the Event Number from the CDF header

Definition at line 39 of file HcalDTCHeader.h.

References commondataformat1.

39 { return (commondataformat1 & 0x00FFFFFF); }
uint32_t commondataformat1

◆ getOrbitNumber()

unsigned int HcalDTCHeader::getOrbitNumber ( ) const
inline

Get the Orbit Number from the CDF.

Definition at line 49 of file HcalDTCHeader.h.

References commondataformat2, and commondataformat3.

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

References commondataformat3.

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

References slotInfo.

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

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

◆ 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.

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

Referenced by HcalUnpacker::unpackVME().

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 }
uint16_t slotInfo[12]
void adoptData(const unsigned short *data, int length)
Definition: HcalHTRData.cc:46

◆ 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.

References slotInfo.

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

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

◆ getSlotEnabled()

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

Read the "ENABLED" bit for this slot.

Definition at line 81 of file HcalDTCHeader.h.

References slotInfo.

Referenced by operator<<().

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

◆ getSlotPresent()

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

Read the "PRESENT" bit for this slot.

Definition at line 85 of file HcalDTCHeader.h.

References slotInfo.

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

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

◆ 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.

References slotInfo.

67 { return slotInfo[nslot]; }
uint16_t slotInfo[12]

◆ 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.

References slotInfo.

Referenced by operator<<().

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

◆ getSourceId()

int HcalDTCHeader::getSourceId ( ) const
inline

get the source id from the CDF header

Definition at line 35 of file HcalDTCHeader.h.

References commondataformat0.

Referenced by HcalUnpacker::unpackVME().

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

◆ getTotalLengthBytes()

unsigned int HcalDTCHeader::getTotalLengthBytes ( ) const

Determine the expected total length of this packet in bytes

Definition at line 15 of file HcalDTCHeader.cc.

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

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 }
uint16_t slotInfo[12]
static const int SLOT_COUNT
Definition: HcalDTCHeader.h:20

◆ isCalibType()

bool HcalDTCHeader::isCalibType ( ) const
inline

Get the Calibration Type

Definition at line 56 of file HcalDTCHeader.h.

References getCalibType().

56 { return (0 != getCalibType()); }
HcalCalibrationEventType getCalibType() const
Definition: HcalDTCHeader.h:57

◆ nDTCWords()

int HcalDTCHeader::nDTCWords ( ) const
inline

Definition at line 64 of file HcalDTCHeader.h.

References dcch0.

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

◆ nSlotWords()

int HcalDTCHeader::nSlotWords ( ) const
inline

Definition at line 63 of file HcalDTCHeader.h.

References dcch0.

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

◆ setHeader()

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

◆ 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.

References commondataformat0.

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

◆ thereIsAThirdCDFHeaderWord()

bool HcalDTCHeader::thereIsAThirdCDFHeaderWord ( ) const
inline

Check the third bit of second Slink64 CDF word

Definition at line 47 of file HcalDTCHeader.h.

References commondataformat2.

47 { return ((commondataformat2 >> 3) & 0x0001); }
uint32_t 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