CMS 3D CMS Logo

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::CastorMergerData ( )

Definition at line 13 of file CastorMergerData.cc.

Referenced by ~CastorMergerData().

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

Definition at line 18 of file CastorMergerData.h.

References adoptData(), allocate(), CastorMergerData(), data, getFirmwareRevision(), m_ownData, and operator=().

18 { if (m_ownData!=0) delete [] m_ownData; }
unsigned short * m_ownData
CastorMergerData::CastorMergerData ( int  version_to_create)

Definition at line 20 of file CastorMergerData.cc.

References allocate().

20  : m_formatVersion(version_to_create) {
21  allocate(version_to_create);
22 }
void allocate(int version_to_create=0)
CastorMergerData::CastorMergerData ( const unsigned short *  data,
int  length 
)

Definition at line 14 of file CastorMergerData.cc.

References adoptData(), and m_ownData.

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

Definition at line 18 of file CastorMergerData.cc.

Member Function Documentation

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

Definition at line 43 of file CastorMergerData.cc.

References data, m_formatVersion, m_rawConst, and m_rawLength.

Referenced by CastorMergerData(), and ~CastorMergerData().

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

Definition at line 24 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

Referenced by CastorMergerData(), and ~CastorMergerData().

24  {
25  m_formatVersion=version_to_create;
26  // the needed space is for the biggest possible event...
27  const int needed=0x200;
28  // create a buffer big enough...
29  m_ownData=new unsigned short[needed];
30  m_rawLength=0;
32 }
const unsigned short * m_rawConst
unsigned short * 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 56 of file CastorMergerData.cc.

References m_rawConst, and m_rawLength.

Referenced by getRawLength().

56  {
57  // length checks
58  // minimum length
59  if (m_rawLength<6+12) return false;
60  // matches wordcount
61  if (m_rawLength!=m_rawConst[m_rawLength-3]) return false;
62 
63  return true;
64 }
const unsigned short * m_rawConst
void CastorMergerData::determineSectionLengths ( int &  tpWords,
int &  headerWords,
int &  trailerWords 
) const
protected

Definition at line 86 of file CastorMergerData.cc.

References m_rawConst.

Referenced by getExtHdr8(), and unpack().

86  {
87 
88  tpWords=m_rawConst[5]>>8; // should be 8 but could be up to 12
89  headerWords=8;
90  trailerWords=0; // minimum, may be more...
91 }
const unsigned short * m_rawConst
void CastorMergerData::determineStaticLengths ( int &  headerWords,
int &  trailerWords 
) const
protected

Definition at line 93 of file CastorMergerData.cc.

Referenced by getExtHdr8(), and pack().

93  {
94  headerWords=8;
95  trailerWords=0; // minimum, may be more...
96 
97 }
unsigned int CastorMergerData::getBunchNumber ( ) const
inline

Get the HTR bunch number.

Definition at line 76 of file CastorMergerData.h.

References getOrbitNumber(), and m_rawConst.

76  {
77  return (m_rawConst[4]&0xFFF);
78  }
const unsigned short * m_rawConst
unsigned int CastorMergerData::getErrorsWord ( ) const
inline

Get the errors word.

Definition at line 30 of file CastorMergerData.h.

References m_rawConst.

Referenced by CastorCTDCHeader::copyMergerData().

30  {
31  return m_rawConst[2]&0xFFFF; }
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr1 ( ) const
inline

Get the Merger Ext Header words.

Definition at line 84 of file CastorMergerData.h.

References m_rawConst.

84  {
85  return (m_rawConst[0]);}
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr2 ( ) const
inline

Definition at line 86 of file CastorMergerData.h.

References m_rawConst.

86  {
87  return (m_rawConst[1]); }
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr3 ( ) const
inline

Definition at line 88 of file CastorMergerData.h.

References m_rawConst.

88  {
89  return (m_rawConst[2]);}
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr4 ( ) const
inline

Definition at line 90 of file CastorMergerData.h.

References m_rawConst.

90  {
91  return (m_rawConst[3]); }
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr5 ( ) const
inline

Definition at line 92 of file CastorMergerData.h.

References m_rawConst.

92  {
93  return (m_rawConst[4]);}
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr6 ( ) const
inline

Definition at line 94 of file CastorMergerData.h.

References m_rawConst.

94  {
95  return (m_rawConst[5]);}
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr7 ( ) const
inline

Definition at line 96 of file CastorMergerData.h.

References m_rawConst.

96  {
97  return (m_rawConst[6]);}
const unsigned short * m_rawConst
unsigned int CastorMergerData::getExtHdr8 ( ) const
inline

Definition at line 98 of file CastorMergerData.h.

References determineSectionLengths(), determineStaticLengths(), and m_rawConst.

98  {
99  return (m_rawConst[7]);}
const unsigned short * m_rawConst
unsigned int CastorMergerData::getFirmwareRevision ( ) const

Get the Merger firmware version.

Definition at line 147 of file CastorMergerData.cc.

References m_rawConst.

Referenced by ~CastorMergerData().

147  {
148  return (m_rawConst[6]);
149 }
const unsigned short * m_rawConst
int CastorMergerData::getFormatVersion ( ) const
inline

Get the version number of this event.

Definition at line 34 of file CastorMergerData.h.

References m_formatVersion.

34 { return m_formatVersion; }
unsigned int CastorMergerData::getL1ANumber ( ) const
inline

Get the HTR event number.

Definition at line 72 of file CastorMergerData.h.

References m_rawConst.

72  {
73  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
74  }
const unsigned short * m_rawConst
unsigned int CastorMergerData::getOrbitNumber ( ) const

Get the HTR orbit number.

Definition at line 143 of file CastorMergerData.cc.

References m_rawConst.

Referenced by getBunchNumber().

143  {
144  return (m_rawConst[3]>>11);
145 }
const unsigned short * m_rawConst
const unsigned short* CastorMergerData::getRawData ( ) const
inline

Get a pointer to the raw data.

Definition at line 37 of file CastorMergerData.h.

References m_rawConst.

Referenced by CastorCTDCHeader::copyMergerData().

37 { return m_rawConst; }
const unsigned short * m_rawConst
const int CastorMergerData::getRawLength ( ) const
inline

Get the length of the raw data.

Definition at line 40 of file CastorMergerData.h.

References check(), m_rawLength, pack(), packHeaderTrailer(), and unpack().

Referenced by CastorCTDCHeader::copyMergerData(), and CastorCtdcPacker::pack().

40 { return m_rawLength; }
CastorMergerData & CastorMergerData::operator= ( const CastorMergerData hd)

Definition at line 34 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

Referenced by ~CastorMergerData().

34  {
35  if (m_ownData==0) {
39  }
40  return (*this);
41 }
const unsigned short * m_rawConst
unsigned short * m_ownData
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 98 of file CastorMergerData.cc.

References determineStaticLengths(), m_ownData, and m_rawLength.

Referenced by pyrootRender.interactiveRender::draw(), and getRawLength().

99  {
100 
101  int tp_words_total=0, headerLen, trailerLen;
102  determineStaticLengths(headerLen,trailerLen);
103 
104  tp_words_total=0;
105  int isample;
106 
107  // trigger words
108  unsigned short* ptr=m_ownData+headerLen;
109  if (tp_samples!=0 && tp_lengths!=0) {
110  for (isample=0; isample<tp_lengths[0] && isample<12; isample++) {
111  ptr[tp_words_total]=tp_samples[isample];
112  tp_words_total++;
113  }
114  }
115 
116  m_ownData[5]=(tp_words_total<<8)|0x1;
117  unsigned short totalLen=headerLen+tp_words_total+trailerLen;
118 
119  m_rawLength=totalLen;
120  m_ownData[totalLen-2]=totalLen/2; // 32-bit words
121  m_ownData[totalLen-3]=totalLen;
122  m_ownData[totalLen-4]=tp_words_total;
123 
124 }
unsigned short * m_ownData
void determineStaticLengths(int &headerWords, int &trailerWords) const
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 126 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, and m_rawLength.

Referenced by getRawLength().

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

References determineSectionLengths(), and m_rawConst.

Referenced by getRawLength().

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

Member Data Documentation

int CastorMergerData::m_formatVersion
protected
unsigned short* CastorMergerData::m_ownData
protected
const unsigned short* CastorMergerData::m_rawConst
protected
int CastorMergerData::m_rawLength
protected
unsigned short* CastorMergerData::m_unpackedData
protected

Definition at line 111 of file CastorMergerData.h.