CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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.

Date:
2009/02/20 17:46:27
Revision:
1.1
Author
A. Campbell - DESY

Definition at line 16 of file CastorMergerData.h.

Constructor & Destructor Documentation

CastorMergerData::CastorMergerData ( )

Definition at line 15 of file CastorMergerData.cc.

15 : 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 20 of file CastorMergerData.h.

References m_ownData.

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

Definition at line 22 of file CastorMergerData.cc.

References allocate().

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

Definition at line 16 of file CastorMergerData.cc.

References adoptData(), and m_ownData.

16  {
17  adoptData(data,length);
18  m_ownData=0;
19 }
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 20 of file CastorMergerData.cc.

Member Function Documentation

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

Definition at line 45 of file CastorMergerData.cc.

References data, m_formatVersion, m_rawConst, and m_rawLength.

Referenced by CastorMergerData().

45  {
46  m_rawLength=length;
48  if (m_rawLength<5) {
49  m_formatVersion=-2; // invalid!
50  } else {
51  m_formatVersion=(m_rawConst[4]>>12)&0xF;
52  }
53 }
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 26 of file CastorMergerData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

Referenced by CastorMergerData().

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

References m_rawConst, and m_rawLength.

58  {
59  // length checks
60  // minimum length
61  if (m_rawLength<6+12) return false;
62  // matches wordcount
63  if (m_rawLength!=m_rawConst[m_rawLength-3]) return false;
64 
65  return true;
66 }
const unsigned short * m_rawConst
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().

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

Definition at line 95 of file CastorMergerData.cc.

Referenced by pack().

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

Get the HTR bunch number.

Definition at line 78 of file CastorMergerData.h.

References m_rawConst.

78  {
79  return (m_rawConst[4]&0xFFF);
80  }
const unsigned short * m_rawConst
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().

32  {
33  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 86 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 88 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 90 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 92 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 94 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 96 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 98 of file CastorMergerData.h.

References m_rawConst.

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

Definition at line 100 of file CastorMergerData.h.

References m_rawConst.

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

Get the Merger firmware version.

Definition at line 149 of file CastorMergerData.cc.

References m_rawConst.

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

Get the version number of this event.

Definition at line 36 of file CastorMergerData.h.

References m_formatVersion.

36 { 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.

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

Get the HTR orbit number.

Definition at line 145 of file CastorMergerData.cc.

References m_rawConst.

145  {
146  return (m_rawConst[3]>>11);
147 }
const unsigned short * m_rawConst
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().

39 { return m_rawConst; }
const unsigned short * 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().

42 { 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.

36  {
37  if (m_ownData==0) {
41  }
42  return (*this);
43 }
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 100 of file CastorMergerData.cc.

References determineStaticLengths(), m_ownData, and m_rawLength.

Referenced by pyrootRender.interactiveRender::draw().

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

References m_formatVersion, m_ownData, and m_rawLength.

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

References determineSectionLengths(), and m_rawConst.

70  {
71 
72  if (tp_lengths!=0) memset(tp_lengths,0,1);
73 
74  int tp_words_total,headerLen,trailerLen;
75  determineSectionLengths(tp_words_total,headerLen,trailerLen);
76 
77  int wordPtr;
78  const unsigned short* tpBase=m_rawConst+headerLen;
79  // process the trigger primitive words
80  if (tp_lengths!=0) {
81  for (wordPtr=0; wordPtr<tp_words_total; wordPtr++) {
82  tp_samples[tp_lengths[0]]=tpBase[wordPtr];
83  tp_lengths[0]++;
84  }
85  }
86 
87 }
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 113 of file CastorMergerData.h.