CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
CastorMergerData Class Reference

#include <CastorMergerData.h>

Public Member Functions

void adoptData (const unsigned short *data, int length)
 
void allocate (int version_to_create=0)
 
 CastorMergerData ()
 
 CastorMergerData (int version_to_create)
 
 CastorMergerData (const unsigned short *data, int length)
 
 CastorMergerData (const CastorMergerData &)
 
bool check () const
 Check for a good event Requires a minimum length, matching wordcount and length, not an empty event. More...
 
unsigned int getBunchNumber () const
 Get the HTR bunch number. More...
 
unsigned int getErrorsWord () const
 Get the errors word. More...
 
unsigned int getExtHdr1 () const
 Get the Merger Ext Header words. More...
 
unsigned int getExtHdr2 () const
 
unsigned int getExtHdr3 () const
 
unsigned int getExtHdr4 () const
 
unsigned int getExtHdr5 () const
 
unsigned int getExtHdr6 () const
 
unsigned int getExtHdr7 () const
 
unsigned int getExtHdr8 () const
 
unsigned int getFirmwareRevision () const
 Get the Merger firmware version. More...
 
int getFormatVersion () const
 Get the version number of this event. More...
 
unsigned int getL1ANumber () const
 Get the HTR event number. More...
 
unsigned int getOrbitNumber () const
 Get the HTR orbit number. More...
 
const unsigned short * getRawData () const
 Get a pointer to the raw data. More...
 
const int getRawLength () const
 Get the length of the raw data. More...
 
CastorMergerDataoperator= (const CastorMergerData &)
 
void pack (unsigned char *tp_lengths, unsigned short *tp_samples)
 Unpack the HTR data into TP and DAQ data sorted by channel. More...
 
void packHeaderTrailer (int L1Anumber, int bcn, int submodule, int orbitn, int pipeline, int ndd, int nps, int firmwareRev=0)
 pack header and trailer (call after pack) More...
 
void unpack (unsigned char *tp_lengths, unsigned short *tp_samples) const
 Unpack the HTR data into TP and DAQ data sorted by channel. More...
 
 ~CastorMergerData ()
 

Protected Member Functions

void determineSectionLengths (int &tpWords, int &headerWords, int &trailerWords) const
 
void determineStaticLengths (int &headerWords, int &trailerWords) const
 

Protected Attributes

int m_formatVersion
 
unsigned short * m_ownData
 
const unsigned short * m_rawConst
 
int m_rawLength
 
unsigned short * m_unpackedData
 

Detailed Description

Interpretive class for CastorMergerData Since this class requires external specification of the length of the data, it is implemented as an interpreter, rather than a cast-able header class.

Author
A. Campbell - DESY

Definition at line 14 of file CastorMergerData.h.

Constructor & Destructor Documentation

◆ CastorMergerData() [1/4]

CastorMergerData::CastorMergerData ( )

Definition at line 13 of file CastorMergerData.cc.

13 : m_formatVersion(-2), m_rawLength(0), m_rawConst(nullptr), m_ownData(nullptr) {}
const unsigned short * m_rawConst
unsigned short * m_ownData

◆ ~CastorMergerData()

CastorMergerData::~CastorMergerData ( )
inline

Definition at line 17 of file CastorMergerData.h.

References m_ownData.

17  {
18  if (m_ownData != nullptr)
19  delete[] m_ownData;
20  }
unsigned short * m_ownData

◆ CastorMergerData() [2/4]

CastorMergerData::CastorMergerData ( int  version_to_create)

Definition at line 21 of file CastorMergerData.cc.

References allocate().

21  : m_formatVersion(version_to_create) {
22  allocate(version_to_create);
23 }
void allocate(int version_to_create=0)

◆ CastorMergerData() [3/4]

CastorMergerData::CastorMergerData ( const unsigned short *  data,
int  length 
)

Definition at line 14 of file CastorMergerData.cc.

References adoptData(), data, and m_ownData.

14  {
15  adoptData(data, length);
16  m_ownData = nullptr;
17 }
void adoptData(const unsigned short *data, int length)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
unsigned short * m_ownData

◆ CastorMergerData() [4/4]

CastorMergerData::CastorMergerData ( const CastorMergerData hd)

Definition at line 18 of file CastorMergerData.cc.

Member Function Documentation

◆ adoptData()

void CastorMergerData::adoptData ( const unsigned short *  data,
int  length 
)

Definition at line 44 of file CastorMergerData.cc.

References data, m_formatVersion, m_rawConst, and m_rawLength.

Referenced by CastorMergerData().

44  {
45  m_rawLength = length;
46  m_rawConst = data;
47  if (m_rawLength < 5) {
48  m_formatVersion = -2; // invalid!
49  } else {
50  m_formatVersion = (m_rawConst[4] >> 12) & 0xF;
51  }
52 }
const unsigned short * m_rawConst
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ allocate()

void CastorMergerData::allocate ( int  version_to_create = 0)

Definition at line 25 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

Referenced by CastorMergerData().

25  {
26  m_formatVersion = version_to_create;
27  // the needed space is for the biggest possible event...
28  const int needed = 0x200;
29  // create a buffer big enough...
30  m_ownData = new unsigned short[needed];
31  m_rawLength = 0;
33 }
const unsigned short * m_rawConst
unsigned short * m_ownData

◆ check()

bool CastorMergerData::check ( ) const

Check for a good event Requires a minimum length, matching wordcount and length, not an empty event.

Definition at line 57 of file CastorMergerData.cc.

References m_rawConst, and m_rawLength.

57  {
58  // length checks
59  // minimum length
60  if (m_rawLength < 6 + 12)
61  return false;
62  // matches wordcount
64  return false;
65 
66  return true;
67 }
const unsigned short * m_rawConst

◆ determineSectionLengths()

void CastorMergerData::determineSectionLengths ( int &  tpWords,
int &  headerWords,
int &  trailerWords 
) const
protected

Definition at line 86 of file CastorMergerData.cc.

References m_rawConst.

Referenced by unpack().

86  {
87  tpWords = m_rawConst[5] >> 8; // should be 8 but could be up to 12
88  headerWords = 8;
89  trailerWords = 0; // minimum, may be more...
90 }
const unsigned short * m_rawConst

◆ determineStaticLengths()

void CastorMergerData::determineStaticLengths ( int &  headerWords,
int &  trailerWords 
) const
protected

Definition at line 92 of file CastorMergerData.cc.

Referenced by pack().

92  {
93  headerWords = 8;
94  trailerWords = 0; // minimum, may be more...
95 }

◆ getBunchNumber()

unsigned int CastorMergerData::getBunchNumber ( ) const
inline

Get the HTR bunch number.

Definition at line 71 of file CastorMergerData.h.

References m_rawConst.

71 { return (m_rawConst[4] & 0xFFF); }
const unsigned short * m_rawConst

◆ getErrorsWord()

unsigned int CastorMergerData::getErrorsWord ( ) const
inline

Get the errors word.

Definition at line 32 of file CastorMergerData.h.

References m_rawConst.

32 { return m_rawConst[2] & 0xFFFF; }
const unsigned short * m_rawConst

◆ getExtHdr1()

unsigned int CastorMergerData::getExtHdr1 ( ) const
inline

Get the Merger Ext Header words.

Definition at line 76 of file CastorMergerData.h.

References m_rawConst.

76 { return (m_rawConst[0]); }
const unsigned short * m_rawConst

◆ getExtHdr2()

unsigned int CastorMergerData::getExtHdr2 ( ) const
inline

Definition at line 77 of file CastorMergerData.h.

References m_rawConst.

77 { return (m_rawConst[1]); }
const unsigned short * m_rawConst

◆ getExtHdr3()

unsigned int CastorMergerData::getExtHdr3 ( ) const
inline

Definition at line 78 of file CastorMergerData.h.

References m_rawConst.

78 { return (m_rawConst[2]); }
const unsigned short * m_rawConst

◆ getExtHdr4()

unsigned int CastorMergerData::getExtHdr4 ( ) const
inline

Definition at line 79 of file CastorMergerData.h.

References m_rawConst.

79 { return (m_rawConst[3]); }
const unsigned short * m_rawConst

◆ getExtHdr5()

unsigned int CastorMergerData::getExtHdr5 ( ) const
inline

Definition at line 80 of file CastorMergerData.h.

References m_rawConst.

80 { return (m_rawConst[4]); }
const unsigned short * m_rawConst

◆ getExtHdr6()

unsigned int CastorMergerData::getExtHdr6 ( ) const
inline

Definition at line 81 of file CastorMergerData.h.

References m_rawConst.

81 { return (m_rawConst[5]); }
const unsigned short * m_rawConst

◆ getExtHdr7()

unsigned int CastorMergerData::getExtHdr7 ( ) const
inline

Definition at line 82 of file CastorMergerData.h.

References m_rawConst.

82 { return (m_rawConst[6]); }
const unsigned short * m_rawConst

◆ getExtHdr8()

unsigned int CastorMergerData::getExtHdr8 ( ) const
inline

Definition at line 83 of file CastorMergerData.h.

References m_rawConst.

83 { return (m_rawConst[7]); }
const unsigned short * m_rawConst

◆ getFirmwareRevision()

unsigned int CastorMergerData::getFirmwareRevision ( ) const

Get the Merger firmware version.

Definition at line 141 of file CastorMergerData.cc.

References m_rawConst.

141 { return (m_rawConst[6]); }
const unsigned short * m_rawConst

◆ getFormatVersion()

int CastorMergerData::getFormatVersion ( ) const
inline

Get the version number of this event.

Definition at line 35 of file CastorMergerData.h.

References m_formatVersion.

35 { return m_formatVersion; }

◆ getL1ANumber()

unsigned int CastorMergerData::getL1ANumber ( ) const
inline

Get the HTR event number.

Definition at line 69 of file CastorMergerData.h.

References m_rawConst.

69 { return (m_rawConst[0] & 0xFF) + (m_rawConst[1] << 8); }
const unsigned short * m_rawConst

◆ getOrbitNumber()

unsigned int CastorMergerData::getOrbitNumber ( ) const

Get the HTR orbit number.

Definition at line 139 of file CastorMergerData.cc.

References m_rawConst.

139 { return (m_rawConst[3] >> 11); }
const unsigned short * m_rawConst

◆ getRawData()

const unsigned short* CastorMergerData::getRawData ( ) const
inline

Get a pointer to the raw data.

Definition at line 38 of file CastorMergerData.h.

References m_rawConst.

38 { return m_rawConst; }
const unsigned short * m_rawConst

◆ getRawLength()

const int CastorMergerData::getRawLength ( ) const
inline

Get the length of the raw data.

Definition at line 41 of file CastorMergerData.h.

References m_rawLength.

Referenced by CastorCtdcPacker::pack().

41 { return m_rawLength; }

◆ operator=()

CastorMergerData & CastorMergerData::operator= ( const CastorMergerData hd)

Definition at line 35 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

35  {
36  if (m_ownData == nullptr) {
40  }
41  return (*this);
42 }
const unsigned short * m_rawConst
unsigned short * m_ownData

◆ pack()

void CastorMergerData::pack ( unsigned char *  tp_lengths,
unsigned short *  tp_samples 
)

Unpack the HTR data into TP and DAQ data sorted by channel.

Parameters
daq_lengthsunsigned char[24] of lengths
daq_samplesunsigned short [24*20] of data
tp_lengthsunsigned char[24] of lengths
tp_samplesunsigned short [24*20] of data

Definition at line 96 of file CastorMergerData.cc.

References determineStaticLengths(), m_ownData, m_rawLength, and testProducerWithPsetDescEmpty_cfi::x1.

96  {
97  int tp_words_total = 0, headerLen, trailerLen;
98  determineStaticLengths(headerLen, trailerLen);
99 
100  tp_words_total = 0;
101  int isample;
102 
103  // trigger words
104  unsigned short* ptr = m_ownData + headerLen;
105  if (tp_samples != nullptr && tp_lengths != nullptr) {
106  for (isample = 0; isample < tp_lengths[0] && isample < 12; isample++) {
107  ptr[tp_words_total] = tp_samples[isample];
108  tp_words_total++;
109  }
110  }
111 
112  m_ownData[5] = (tp_words_total << 8) | 0x1;
113  unsigned short totalLen = headerLen + tp_words_total + trailerLen;
114 
115  m_rawLength = totalLen;
116  m_ownData[totalLen - 2] = totalLen / 2; // 32-bit words
117  m_ownData[totalLen - 3] = totalLen;
118  m_ownData[totalLen - 4] = tp_words_total;
119 }
unsigned short * m_ownData
void determineStaticLengths(int &headerWords, int &trailerWords) const

◆ packHeaderTrailer()

void CastorMergerData::packHeaderTrailer ( int  L1Anumber,
int  bcn,
int  submodule,
int  orbitn,
int  pipeline,
int  ndd,
int  nps,
int  firmwareRev = 0 
)

pack header and trailer (call after pack)

Definition at line 121 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, and m_rawLength.

122  {
123  m_ownData[0] = L1Anumber & 0xFF;
124  m_ownData[1] = (L1Anumber & 0xFFFF00) >> 8;
125 
126  m_ownData[2] = 0x8000; // Version is valid, no error bits - status bits need definition
127  m_ownData[3] = ((orbitn & 0x1F) << 11) | (submodule & 0x7FF);
128  m_ownData[4] = ((m_formatVersion & 0xF) << 12) | (bcn & 0xFFF);
129  m_ownData[5] |= ((nps & 0xF) << 4) | 0x1;
130  m_ownData[6] = ((firmwareRev & 0x70000) >> 3) | (firmwareRev & 0x1FFF);
131  m_ownData[7] = (pipeline & 0xFF) | ((ndd & 0x1F) << 8);
132  m_ownData[m_rawLength - 4] &= 0x7FF;
133  m_ownData[m_rawLength - 4] |= (ndd & 0x1F) << 11;
134 
135  m_ownData[m_rawLength - 2] = m_rawLength / 2; // 32-bit words
136  m_ownData[m_rawLength - 1] = (L1Anumber & 0xFF) << 8;
137 }
unsigned short * m_ownData

◆ unpack()

void CastorMergerData::unpack ( unsigned char *  tp_lengths,
unsigned short *  tp_samples 
) const

Unpack the HTR data into TP and DAQ data sorted by channel.

Parameters
daq_lengthsunsigned char[24] of lengths. High bit set indicates error with this channel
daq_samplesunsigned short [24*20] of data
tp_lengthsunsigned char[24] of lengths
tp_samplesunsigned short [24*20] of data

Definition at line 69 of file CastorMergerData.cc.

References determineSectionLengths(), and m_rawConst.

69  {
70  if (tp_lengths != nullptr)
71  memset(tp_lengths, 0, 1);
72 
73  int tp_words_total, headerLen, trailerLen;
74  determineSectionLengths(tp_words_total, headerLen, trailerLen);
75 
76  int wordPtr;
77  const unsigned short* tpBase = m_rawConst + headerLen;
78  // process the trigger primitive words
79  if (tp_lengths != nullptr) {
80  for (wordPtr = 0; wordPtr < tp_words_total; wordPtr++) {
81  tp_samples[tp_lengths[0]] = tpBase[wordPtr];
82  tp_lengths[0]++;
83  }
84  }
85 }
const unsigned short * m_rawConst
void determineSectionLengths(int &tpWords, int &headerWords, int &trailerWords) const

Member Data Documentation

◆ m_formatVersion

int CastorMergerData::m_formatVersion
protected

◆ m_ownData

unsigned short* CastorMergerData::m_ownData
protected

◆ m_rawConst

const unsigned short* CastorMergerData::m_rawConst
protected

◆ m_rawLength

int CastorMergerData::m_rawLength
protected

◆ m_unpackedData

unsigned short* CastorMergerData::m_unpackedData
protected

Definition at line 93 of file CastorMergerData.h.