#include <CastorMergerData.h>
Public Member Functions | |
void | adoptData (const unsigned short *data, int length) |
void | allocate (int version_to_create=0) |
CastorMergerData (const unsigned short *data, int length) | |
CastorMergerData (const CastorMergerData &) | |
CastorMergerData () | |
CastorMergerData (int version_to_create) | |
bool | check () const |
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event. | |
unsigned int | getBunchNumber () const |
Get the HTR bunch number. | |
unsigned int | getErrorsWord () const |
Get the errors word. | |
unsigned int | getExtHdr1 () const |
Get the Merger Ext Header words. | |
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. | |
int | getFormatVersion () const |
Get the version number of this event. | |
unsigned int | getL1ANumber () const |
Get the HTR event number. | |
unsigned int | getOrbitNumber () const |
Get the HTR orbit number. | |
const unsigned short * | getRawData () const |
Get a pointer to the raw data. | |
const int | getRawLength () const |
Get the length of the raw data. | |
CastorMergerData & | operator= (const CastorMergerData &) |
void | pack (unsigned char *tp_lengths, unsigned short *tp_samples) |
Unpack the HTR data into TP and DAQ data sorted by channel. | |
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) | |
void | unpack (unsigned char *tp_lengths, unsigned short *tp_samples) const |
Unpack the HTR data into TP and DAQ data sorted by channel. | |
~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 |
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.
Definition at line 16 of file CastorMergerData.h.
CastorMergerData::CastorMergerData | ( | ) |
Definition at line 15 of file CastorMergerData.cc.
: m_formatVersion(-2), m_rawLength(0), m_rawConst(0), m_ownData(0) { }
CastorMergerData::~CastorMergerData | ( | ) | [inline] |
Definition at line 20 of file CastorMergerData.h.
References m_ownData.
CastorMergerData::CastorMergerData | ( | int | version_to_create | ) |
Definition at line 22 of file CastorMergerData.cc.
References allocate().
: m_formatVersion(version_to_create) { allocate(version_to_create); }
CastorMergerData::CastorMergerData | ( | const unsigned short * | data, |
int | length | ||
) |
Definition at line 16 of file CastorMergerData.cc.
References adoptData(), and m_ownData.
CastorMergerData::CastorMergerData | ( | const CastorMergerData & | hd | ) |
Definition at line 20 of file CastorMergerData.cc.
: m_formatVersion(hd.m_formatVersion), m_rawLength(hd.m_rawLength), m_rawConst(hd.m_rawConst), m_ownData(0) { }
void CastorMergerData::adoptData | ( | const unsigned short * | data, |
int | length | ||
) |
Definition at line 45 of file CastorMergerData.cc.
References AlCaHLTBitMon_QueryRunRegistry::data, m_formatVersion, m_rawConst, and m_rawLength.
Referenced by CastorMergerData().
{ m_rawLength=length; m_rawConst=data; if (m_rawLength<5) { m_formatVersion=-2; // invalid! } else { m_formatVersion=(m_rawConst[4]>>12)&0xF; } }
void CastorMergerData::allocate | ( | int | version_to_create = 0 | ) |
Definition at line 26 of file CastorMergerData.cc.
References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.
Referenced by CastorMergerData().
{ m_formatVersion=version_to_create; // the needed space is for the biggest possible event... const int needed=0x200; // create a buffer big enough... m_ownData=new unsigned short[needed]; m_rawLength=0; m_rawConst=m_ownData; }
bool CastorMergerData::check | ( | ) | const |
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event.
Definition at line 58 of file CastorMergerData.cc.
References m_rawConst, and m_rawLength.
{ // length checks // minimum length if (m_rawLength<6+12) return false; // matches wordcount if (m_rawLength!=m_rawConst[m_rawLength-3]) return false; return true; }
void CastorMergerData::determineSectionLengths | ( | int & | tpWords, |
int & | headerWords, | ||
int & | trailerWords | ||
) | const [protected] |
Definition at line 88 of file CastorMergerData.cc.
References m_rawConst.
Referenced by unpack().
{ tpWords=m_rawConst[5]>>8; // should be 8 but could be up to 12 headerWords=8; trailerWords=0; // minimum, may be more... }
void CastorMergerData::determineStaticLengths | ( | int & | headerWords, |
int & | trailerWords | ||
) | const [protected] |
Definition at line 95 of file CastorMergerData.cc.
Referenced by pack().
{
headerWords=8;
trailerWords=0; // minimum, may be more...
}
unsigned int CastorMergerData::getBunchNumber | ( | ) | const [inline] |
Get the HTR bunch number.
Definition at line 78 of file CastorMergerData.h.
References m_rawConst.
{ return (m_rawConst[4]&0xFFF); }
unsigned int CastorMergerData::getErrorsWord | ( | ) | const [inline] |
Get the errors word.
Definition at line 32 of file CastorMergerData.h.
References m_rawConst.
Referenced by CastorCTDCHeader::copyMergerData().
{ return m_rawConst[2]&0xFFFF; }
unsigned int CastorMergerData::getExtHdr1 | ( | ) | const [inline] |
Get the Merger Ext Header words.
Definition at line 86 of file CastorMergerData.h.
References m_rawConst.
{ return (m_rawConst[0]);}
unsigned int CastorMergerData::getExtHdr2 | ( | ) | const [inline] |
Definition at line 88 of file CastorMergerData.h.
References m_rawConst.
{ return (m_rawConst[1]); }
unsigned int CastorMergerData::getExtHdr3 | ( | ) | const [inline] |
unsigned int CastorMergerData::getExtHdr4 | ( | ) | const [inline] |
Definition at line 92 of file CastorMergerData.h.
References m_rawConst.
{ return (m_rawConst[3]); }
unsigned int CastorMergerData::getExtHdr5 | ( | ) | const [inline] |
unsigned int CastorMergerData::getExtHdr6 | ( | ) | const [inline] |
unsigned int CastorMergerData::getExtHdr7 | ( | ) | const [inline] |
unsigned int CastorMergerData::getExtHdr8 | ( | ) | const [inline] |
Definition at line 100 of file CastorMergerData.h.
References m_rawConst.
{ return (m_rawConst[7]);}
unsigned int CastorMergerData::getFirmwareRevision | ( | ) | const |
Get the Merger firmware version.
Definition at line 149 of file CastorMergerData.cc.
References m_rawConst.
{ return (m_rawConst[6]); }
int CastorMergerData::getFormatVersion | ( | ) | const [inline] |
Get the version number of this event.
Definition at line 36 of file CastorMergerData.h.
References m_formatVersion.
{ return m_formatVersion; }
unsigned int CastorMergerData::getL1ANumber | ( | ) | const [inline] |
Get the HTR event number.
Definition at line 74 of file CastorMergerData.h.
References m_rawConst.
{ return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8); }
unsigned int CastorMergerData::getOrbitNumber | ( | ) | const |
Get the HTR orbit number.
Definition at line 145 of file CastorMergerData.cc.
References m_rawConst.
{ return (m_rawConst[3]>>11); }
const unsigned short* CastorMergerData::getRawData | ( | ) | const [inline] |
Get a pointer to the raw data.
Definition at line 39 of file CastorMergerData.h.
References m_rawConst.
Referenced by CastorCTDCHeader::copyMergerData().
{ return m_rawConst; }
const int CastorMergerData::getRawLength | ( | ) | const [inline] |
Get the length of the raw data.
Definition at line 42 of file CastorMergerData.h.
References m_rawLength.
Referenced by CastorCTDCHeader::copyMergerData(), and CastorCtdcPacker::pack().
{ return m_rawLength; }
CastorMergerData & CastorMergerData::operator= | ( | const CastorMergerData & | hd | ) |
Definition at line 36 of file CastorMergerData.cc.
References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.
{ if (m_ownData==0) { m_formatVersion=hd.m_formatVersion; m_rawLength=hd.m_rawLength; m_rawConst=hd.m_rawConst; } return (*this); }
void CastorMergerData::pack | ( | unsigned char * | tp_lengths, |
unsigned short * | tp_samples | ||
) |
Unpack the HTR data into TP and DAQ data sorted by channel.
daq_lengths | unsigned char[24] of lengths |
daq_samples | unsigned short [24*20] of data |
tp_lengths | unsigned char[24] of lengths |
tp_samples | unsigned short [24*20] of data |
Definition at line 100 of file CastorMergerData.cc.
References determineStaticLengths(), m_ownData, and m_rawLength.
{ int tp_words_total=0, headerLen, trailerLen; determineStaticLengths(headerLen,trailerLen); tp_words_total=0; int isample; // trigger words unsigned short* ptr=m_ownData+headerLen; if (tp_samples!=0 && tp_lengths!=0) { for (isample=0; isample<tp_lengths[0] && isample<12; isample++) { ptr[tp_words_total]=tp_samples[isample]; tp_words_total++; } } m_ownData[5]=(tp_words_total<<8)|0x1; unsigned short totalLen=headerLen+tp_words_total+trailerLen; m_rawLength=totalLen; m_ownData[totalLen-2]=totalLen/2; // 32-bit words m_ownData[totalLen-3]=totalLen; m_ownData[totalLen-4]=tp_words_total; }
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 128 of file CastorMergerData.cc.
References m_formatVersion, m_ownData, and m_rawLength.
{ m_ownData[0]=L1Anumber&0xFF; m_ownData[1]=(L1Anumber&0xFFFF00)>>8; m_ownData[2]=0x8000; // Version is valid, no error bits - status bits need definition m_ownData[3]=((orbitn&0x1F)<<11)|(submodule&0x7FF); m_ownData[4]=((m_formatVersion&0xF)<<12)|(bcn&0xFFF); m_ownData[5]|=((nps&0xF)<<4)|0x1; m_ownData[6]=((firmwareRev&0x70000)>>3)|(firmwareRev&0x1FFF); m_ownData[7]=(pipeline&0xFF) | ((ndd&0x1F)<<8); m_ownData[m_rawLength-4]&=0x7FF; m_ownData[m_rawLength-4]|=(ndd&0x1F)<<11; m_ownData[m_rawLength-2]=m_rawLength/2; // 32-bit words m_ownData[m_rawLength-1]=(L1Anumber&0xFF)<<8; }
void CastorMergerData::unpack | ( | unsigned char * | tp_lengths, |
unsigned short * | tp_samples | ||
) | const |
Unpack the HTR data into TP and DAQ data sorted by channel.
daq_lengths | unsigned char[24] of lengths. High bit set indicates error with this channel |
daq_samples | unsigned short [24*20] of data |
tp_lengths | unsigned char[24] of lengths |
tp_samples | unsigned short [24*20] of data |
Definition at line 69 of file CastorMergerData.cc.
References determineSectionLengths(), and m_rawConst.
{ if (tp_lengths!=0) memset(tp_lengths,0,1); int tp_words_total,headerLen,trailerLen; determineSectionLengths(tp_words_total,headerLen,trailerLen); int wordPtr; const unsigned short* tpBase=m_rawConst+headerLen; // process the trigger primitive words if (tp_lengths!=0) { for (wordPtr=0; wordPtr<tp_words_total; wordPtr++) { tp_samples[tp_lengths[0]]=tpBase[wordPtr]; tp_lengths[0]++; } } }
int CastorMergerData::m_formatVersion [protected] |
Definition at line 109 of file CastorMergerData.h.
Referenced by adoptData(), allocate(), getFormatVersion(), operator=(), and packHeaderTrailer().
unsigned short* CastorMergerData::m_ownData [protected] |
Definition at line 112 of file CastorMergerData.h.
Referenced by allocate(), CastorMergerData(), operator=(), pack(), packHeaderTrailer(), and ~CastorMergerData().
const unsigned short* CastorMergerData::m_rawConst [protected] |
Definition at line 111 of file CastorMergerData.h.
Referenced by adoptData(), allocate(), check(), determineSectionLengths(), getBunchNumber(), getErrorsWord(), getExtHdr1(), getExtHdr2(), getExtHdr3(), getExtHdr4(), getExtHdr5(), getExtHdr6(), getExtHdr7(), getExtHdr8(), getFirmwareRevision(), getL1ANumber(), getOrbitNumber(), getRawData(), operator=(), and unpack().
int CastorMergerData::m_rawLength [protected] |
Definition at line 110 of file CastorMergerData.h.
Referenced by adoptData(), allocate(), check(), getRawLength(), operator=(), pack(), and packHeaderTrailer().
unsigned short* CastorMergerData::m_unpackedData [protected] |
Definition at line 113 of file CastorMergerData.h.