CMS 3D CMS Logo

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

#include <CastorCORData.h>

Public Member Functions

void adoptData (const unsigned short *data, int length)
 
void allocate (int version_to_create=0)
 
 CastorCORData ()
 
 CastorCORData (int version_to_create)
 
 CastorCORData (const unsigned short *data, int length)
 
 CastorCORData (const CastorCORData &)
 
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 getDLLunlock () const
 Get DLLunlock bits. More...
 
unsigned int getErrorsWord () const
 Get the errors word. More...
 
unsigned int getExtHdr1 () const
 Get the COR 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 getFib1OrbMsgBCN () const
 Get the BCN of the Fiber Orbit Messages. More...
 
unsigned int getFib2OrbMsgBCN () const
 
unsigned int getFib3OrbMsgBCN () const
 
unsigned int getFib4OrbMsgBCN () const
 
unsigned int getFib5OrbMsgBCN () const
 
unsigned int getFib6OrbMsgBCN () const
 
unsigned int getFib7OrbMsgBCN () const
 
unsigned int getFib8OrbMsgBCN () const
 
unsigned int getFirmwareRevision () const
 Get the COR firmware version. More...
 
int getFormatVersion () const
 Get the version number of this event. More...
 
void getHistogramFibers (int &a, int &b) const
 Get the fiber numbers for the data present in this event (only in histogram mode!) More...
 
unsigned int getL1ANumber () const
 Get the HTR event number. More...
 
int getNDD () const
 Get the number of daq data samples per channel when not zero-suppressed. More...
 
int getNPrecisionWords () const
 Get the total number of precision data 16-bit words. More...
 
int getNPS () const
 Get the number of presamples in daq data. More...
 
int getNTP () const
 Get the number of trigger data samples when not zero-suppressed (not available after FW 4) More...
 
unsigned int getOrbitNumber () const
 Get the HTR orbit number. More...
 
unsigned int getPipelineLength () const
 Get the pipeline length used for this event. 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...
 
unsigned int getSubmodule () const
 Get the HTR submodule number. More...
 
unsigned int getTTCready () const
 Get TTCready bits. More...
 
unsigned int htrSlot () const
 HcalElectronicsId-style HTR slot. More...
 
unsigned int htrTopBottom () const
 HcalElectronicsId-style HTR top/bottom (1=top/0=bottom) More...
 
bool isCalibrationStream () const
 Is this event a calibration-stream event? More...
 
bool isHistogramEvent () const
 Is this event a histogram event? (do not call standard unpack in this case!!!!!) More...
 
bool isPatternRAMEvent () const
 Is this event a pattern-ram event? More...
 
bool isUnsuppressed () const
 Is this event an unsuppresed event? More...
 
CastorCORDataoperator= (const CastorCORData &)
 
void pack (unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples, bool do_capid=false)
 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...
 
unsigned int readoutVMECrateId () const
 HcalElectronicsId-style VME crate number. More...
 
void unpack (unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples) const
 Obtain the starting and ending pointers for external unpacking of the data. More...
 
bool unpackHistogram (int fiber, int fiberchan, int capid, unsigned short *histogram) const
 Unpack special histogramming mode data. More...
 
bool wasMarkAndPassZS (int fiber, int fiberchan) const
 Was this channel passed as part of Mark&Pass ZS? More...
 
 ~CastorCORData ()
 

Static Public Attributes

static const int CHANNELS_PER_SPIGOT = 36
 
static const int MAXIMUM_SAMPLES_PER_CHANNEL = 20
 

Protected Member Functions

void determineSectionLengths (int &tpWords, int &daqWords, int &headerWords, int &trailerWords, int &triggerWords) const
 Was there an error on the given fiber for this event (only in histogram mode!) More...
 
void determineStaticLengths (int &headerWords, int &trailerWords, int &triggerWords) 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 CastorCORDat 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 CastorCORData.h.

Constructor & Destructor Documentation

CastorCORData::CastorCORData ( )

Definition at line 22 of file CastorCORData.cc.

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

Definition at line 22 of file CastorCORData.h.

References m_ownData.

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

Definition at line 29 of file CastorCORData.cc.

References allocate().

29  : m_formatVersion(version_to_create) {
30  allocate(version_to_create);
31 }
void allocate(int version_to_create=0)
CastorCORData::CastorCORData ( const unsigned short *  data,
int  length 
)

Definition at line 23 of file CastorCORData.cc.

References adoptData(), and m_ownData.

23  {
24  adoptData(data,length);
25  m_ownData=0;
26 }
void adoptData(const unsigned short *data, int length)
unsigned short * m_ownData
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
CastorCORData::CastorCORData ( const CastorCORData hd)

Definition at line 27 of file CastorCORData.cc.

unsigned short * m_ownData
const unsigned short * m_rawConst

Member Function Documentation

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

Definition at line 52 of file CastorCORData.cc.

References data, m_formatVersion, m_rawConst, and m_rawLength.

Referenced by CastorCORData(), and CastorCTDCHeader::getSpigotData().

52  {
53  m_rawLength=length;
55  if (m_rawLength<5) {
56  m_formatVersion=-2; // invalid!
57  } else {
58  m_formatVersion=(m_rawConst[4]>>12)&0xF;
59  }
60 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned short * m_rawConst
void CastorCORData::allocate ( int  version_to_create = 0)

Definition at line 33 of file CastorCORData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

Referenced by CastorCORData(), and CastorCtdcPacker::pack().

33  {
34  m_formatVersion=version_to_create;
35  // the needed space is for the biggest possible event...
36  const int needed=0x200;
37  // create a buffer big enough...
38  m_ownData=new unsigned short[needed];
39  m_rawLength=0;
41 }
unsigned short * m_ownData
const unsigned short * m_rawConst
bool CastorCORData::check ( ) const

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

Definition at line 65 of file CastorCORData.cc.

References determineSectionLengths(), m_rawConst, and m_rawLength.

Referenced by CastorCtdcUnpacker::unpack().

65  {
66  // length checks
67  // minimum length
68  if (m_rawLength<6+12) return false;
69  // matches wordcount
70  if (m_rawLength!=m_rawConst[m_rawLength-3]) return false;
71 
72  // daq/tp length check
73  int tp, daq, header, trailer, trigger;
74  determineSectionLengths(tp,daq,header,trailer,trigger);
75  if (trigger+daq+header+trailer>m_rawLength) return false;
76 
77  return true;
78 }
const unsigned short * m_rawConst
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords, int &triggerWords) const
Was there an error on the given fiber for this event (only in histogram mode!)
void CastorCORData::determineSectionLengths ( int &  tpWords,
int &  daqWords,
int &  headerWords,
int &  trailerWords,
int &  triggerWords 
) const
protected

Was there an error on the given fiber for this event (only in histogram mode!)

Definition at line 80 of file CastorCORData.cc.

References m_rawConst, and m_rawLength.

Referenced by check(), and unpack().

80  {
81 
82  tpWords=m_rawConst[5]>>8; // should be 8 but could be up to 12
83  if (m_rawLength>4)
84  daqWords=m_rawConst[m_rawLength-4]&0x7FF; // no zero suppression supported
85  // there are 24 16bit words per time sample
86  // these contain the data from 36 channels
87  // daqWords is number of 16 bit words of qie data
88  // hence #qie data values id daqWords*3/2
89  headerWords=8;
90  triggerLen=12; // total space reserved for trigger information
91  trailerWords=12; // minimum, may be more...
92 }
const unsigned short * m_rawConst
void CastorCORData::determineStaticLengths ( int &  headerWords,
int &  trailerWords,
int &  triggerWords 
) const
protected

Definition at line 94 of file CastorCORData.cc.

Referenced by pack().

94  {
95  headerWords=8;
96  triggerLen=12; // total space reserved for trigger information
97  trailerWords=12; // minimum, may be more...
98 
99 }
unsigned int CastorCORData::getBunchNumber ( ) const
inline

Get the HTR bunch number.

Definition at line 96 of file CastorCORData.h.

References m_rawConst.

96  {
97  return (m_rawConst[4]&0xFFF);
98  }
const unsigned short * m_rawConst
unsigned int CastorCORData::getDLLunlock ( ) const
inline

Get DLLunlock bits.

Definition at line 145 of file CastorCORData.h.

References m_rawConst.

145  {
146  return (m_rawConst[5]>>2)&0x3; }
const unsigned short * m_rawConst
unsigned int CastorCORData::getErrorsWord ( ) const
inline

Get the errors word.

Definition at line 132 of file CastorCORData.h.

References m_rawConst.

Referenced by CastorCTDCHeader::copySpigotData().

132  {
133  return m_rawConst[2]&0xFFFF; }
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr1 ( ) const
inline

Get the COR Ext Header words.

Definition at line 187 of file CastorCORData.h.

References m_rawConst.

187  {
188  return (m_rawConst[0]);}
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr2 ( ) const
inline

Definition at line 189 of file CastorCORData.h.

References m_rawConst.

189  {
190  return (m_rawConst[1]); }
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr3 ( ) const
inline

Definition at line 191 of file CastorCORData.h.

References m_rawConst.

191  {
192  return (m_rawConst[2]);}
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr4 ( ) const
inline

Definition at line 193 of file CastorCORData.h.

References m_rawConst.

193  {
194  return (m_rawConst[3]); }
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr5 ( ) const
inline

Definition at line 195 of file CastorCORData.h.

References m_rawConst.

195  {
196  return (m_rawConst[4]);}
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr6 ( ) const
inline

Definition at line 197 of file CastorCORData.h.

References m_rawConst.

197  {
198  return (m_rawConst[5]);}
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr7 ( ) const
inline

Definition at line 199 of file CastorCORData.h.

References m_rawConst.

199  {
200  return (m_rawConst[6]);}
const unsigned short * m_rawConst
unsigned int CastorCORData::getExtHdr8 ( ) const
inline

Definition at line 201 of file CastorCORData.h.

References m_rawConst.

201  {
202  return (m_rawConst[7]);}
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib1OrbMsgBCN ( ) const
inline

Get the BCN of the Fiber Orbit Messages.

Definition at line 153 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

153  {
154  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-12]&0xFFF);
155 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib2OrbMsgBCN ( ) const
inline

Definition at line 156 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

156  {
157  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-11]&0xFFF);
158 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib3OrbMsgBCN ( ) const
inline

Definition at line 160 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

160  {
161  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-10]&0xFFF);
162 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib4OrbMsgBCN ( ) const
inline

Definition at line 164 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

164  {
165  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-9]&0xFFF);
166 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib5OrbMsgBCN ( ) const
inline

Definition at line 168 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

168  {
169  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-8]&0xFFF);
170 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib6OrbMsgBCN ( ) const
inline

Definition at line 172 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

172  {
173  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-7]&0xFFF);
174 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib7OrbMsgBCN ( ) const
inline

Definition at line 176 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

176  {
177  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-6]&0xFFF);
178 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFib8OrbMsgBCN ( ) const
inline

Definition at line 180 of file CastorCORData.h.

References m_formatVersion, m_rawConst, and m_rawLength.

180  {
181  return (m_formatVersion==-1)?(0):(m_rawConst[m_rawLength-5]&0xFFF);
182 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getFirmwareRevision ( ) const

Get the COR firmware version.

Definition at line 318 of file CastorCORData.cc.

References m_rawConst.

318  {
319  return (m_rawConst[6]);
320 }
const unsigned short * m_rawConst
int CastorCORData::getFormatVersion ( ) const
inline

Get the version number of this event.

Definition at line 32 of file CastorCORData.h.

References m_formatVersion.

32 { return m_formatVersion; }
void CastorCORData::getHistogramFibers ( int &  a,
int &  b 
) const

Get the fiber numbers for the data present in this event (only in histogram mode!)

Definition at line 322 of file CastorCORData.cc.

References m_formatVersion, and m_rawConst.

Referenced by unpackHistogram().

322  {
323  a=-1;
324  b=-1;
325  if (m_formatVersion==-1) {
326  a=((m_rawConst[2]&0x0F00)>>8);
327  b=((m_rawConst[2]&0xF000)>>12);
328  } else {
329  a=((m_rawConst[5]&0x0F00)>>8);
330  b=((m_rawConst[5]&0xF000)>>12);
331  }
332 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
const unsigned short * m_rawConst
unsigned int CastorCORData::getL1ANumber ( ) const
inline

Get the HTR event number.

Definition at line 92 of file CastorCORData.h.

References m_rawConst.

92  {
93  return (m_rawConst[0]&0xFF)+(m_rawConst[1]<<8);
94  }
const unsigned short * m_rawConst
int CastorCORData::getNDD ( ) const

Get the number of daq data samples per channel when not zero-suppressed.

Definition at line 300 of file CastorCORData.cc.

References m_formatVersion, m_rawConst, and m_rawLength.

300  {
301  return (m_formatVersion==-1)?(m_rawConst[m_rawLength-4]>>8):(m_rawConst[m_rawLength-4]>>11);
302 }
const unsigned short * m_rawConst
int CastorCORData::getNPrecisionWords ( ) const

Get the total number of precision data 16-bit words.

Definition at line 309 of file CastorCORData.cc.

References m_formatVersion, m_rawConst, and m_rawLength.

309  {
310  return (m_formatVersion==-1)?(m_rawConst[m_rawLength-4]&0xFF):(m_rawConst[m_rawLength-4]&0x7FF);
311 }
const unsigned short * m_rawConst
int CastorCORData::getNPS ( ) const

Get the number of presamples in daq data.

Definition at line 312 of file CastorCORData.cc.

References m_formatVersion, and m_rawConst.

Referenced by CastorCtdcUnpacker::unpack().

312  {
313  return (m_formatVersion==-1)?(0):((m_rawConst[5]>>4)&0xF);
314 }
const unsigned short * m_rawConst
int CastorCORData::getNTP ( ) const

Get the number of trigger data samples when not zero-suppressed (not available after FW 4)

Definition at line 303 of file CastorCORData.cc.

References m_formatVersion, m_rawConst, and m_rawLength.

303  {
304  int retval=-1;
305  if (m_formatVersion==-1) retval=m_rawConst[m_rawLength-4]&0xFF;
306  else if (m_formatVersion<3) retval=m_rawConst[m_rawLength-4]>>11;
307  return retval;
308 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getOrbitNumber ( ) const

Get the HTR orbit number.

Definition at line 262 of file CastorCORData.cc.

References m_rawConst.

262  {
263  return (m_rawConst[3]>>11);
264 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getPipelineLength ( ) const

Get the pipeline length used for this event.

Definition at line 315 of file CastorCORData.cc.

References m_rawConst.

315  {
316  return (m_rawConst[7]&0xFF);
317 }
const unsigned short * m_rawConst
const unsigned short* CastorCORData::getRawData ( ) const
inline

Get a pointer to the raw data.

Definition at line 35 of file CastorCORData.h.

References m_rawConst.

Referenced by CastorCTDCHeader::copySpigotData().

35 { return m_rawConst; }
const unsigned short * m_rawConst
const int CastorCORData::getRawLength ( ) const
inline

Get the length of the raw data.

Definition at line 38 of file CastorCORData.h.

References m_rawLength.

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

38 { return m_rawLength; }
unsigned int CastorCORData::getSubmodule ( ) const

Get the HTR submodule number.

Definition at line 265 of file CastorCORData.cc.

References m_rawConst.

Referenced by htrSlot(), htrTopBottom(), and readoutVMECrateId().

265  {
266  return (m_rawConst[3]&0x7FF);
267 }
const unsigned short * m_rawConst
unsigned int CastorCORData::getTTCready ( ) const
inline

Get TTCready bits.

Definition at line 149 of file CastorCORData.h.

References m_rawConst.

149  {
150  return m_rawConst[5]&0x3; }
const unsigned short * m_rawConst
unsigned int CastorCORData::htrSlot ( ) const

HcalElectronicsId-style HTR slot.

Definition at line 268 of file CastorCORData.cc.

References getSubmodule().

268  {
269  const unsigned int smid = getSubmodule();
270  return ((smid>>1)&0x1F);
271 }
unsigned int getSubmodule() const
Get the HTR submodule number.
unsigned int CastorCORData::htrTopBottom ( ) const

HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)

Definition at line 272 of file CastorCORData.cc.

References getSubmodule().

272  {
273  const unsigned int smid = getSubmodule();
274  return (smid&0x01);
275 }
unsigned int getSubmodule() const
Get the HTR submodule number.
bool CastorCORData::isCalibrationStream ( ) const

Is this event a calibration-stream event?

Definition at line 280 of file CastorCORData.cc.

References m_formatVersion, and m_rawConst.

280  {
281  return (m_formatVersion==-1)?(false):(m_rawConst[2]&0x4000);
282 }
const unsigned short * m_rawConst
bool CastorCORData::isHistogramEvent ( ) const

Is this event a histogram event? (do not call standard unpack in this case!!!!!)

Definition at line 297 of file CastorCORData.cc.

References m_formatVersion, and m_rawConst.

Referenced by CastorCtdcUnpacker::unpack(), and unpackHistogram().

297  {
298  return (m_formatVersion==-1)?(m_rawConst[2]&0x2):(m_rawConst[2]&0x2000);
299 }
const unsigned short * m_rawConst
bool CastorCORData::isPatternRAMEvent ( ) const

Is this event a pattern-ram event?

Definition at line 294 of file CastorCORData.cc.

References m_formatVersion, and m_rawConst.

294  {
295  return (m_formatVersion==-1)?(false):(m_rawConst[2]&0x1000);
296 }
const unsigned short * m_rawConst
bool CastorCORData::isUnsuppressed ( ) const

Is this event an unsuppresed event?

Definition at line 283 of file CastorCORData.cc.

References m_formatVersion, and m_rawConst.

Referenced by wasMarkAndPassZS().

283  {
284  return (m_formatVersion<4)?(false):(m_rawConst[6]&0x8000);
285 }
const unsigned short * m_rawConst
CastorCORData & CastorCORData::operator= ( const CastorCORData hd)

Definition at line 43 of file CastorCORData.cc.

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

43  {
44  if (m_ownData==0) {
48  }
49  return (*this);
50 }
unsigned short * m_ownData
const unsigned short * m_rawConst
void CastorCORData::pack ( unsigned char *  daq_lengths,
unsigned short *  daq_samples,
unsigned char *  tp_lengths,
unsigned short *  tp_samples,
bool  do_capid = false 
)

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 157 of file CastorCORData.cc.

References determineStaticLengths(), j, m_ownData, m_rawLength, MAXIMUM_SAMPLES_PER_CHANNEL, min, and indexGen::s2.

Referenced by pyrootRender.interactiveRender::draw(), and CastorCtdcPacker::pack().

158  {
159 
160  int tp_words_total=0, daq_words_total=0, headerLen, trailerLen, triggerLen;
161  determineStaticLengths(headerLen,trailerLen,triggerLen);
162 
163  tp_words_total=0;
164  daq_words_total=0;
165  int isample;
166 
167  // trigger words
168  unsigned short* ptr=m_ownData+headerLen;
169  if (tp_samples!=0 && tp_lengths!=0) {
170  for (isample=0; isample<tp_lengths[0] && isample<12; isample++) {
171  ptr[tp_words_total]=tp_samples[isample];
172  tp_words_total++;
173  }
174  }
175 
176  // daq words
177  ptr=m_ownData+headerLen+triggerLen;
178  int timesamples = std::min (daq_lengths[0]&0x3f,MAXIMUM_SAMPLES_PER_CHANNEL) ;
179  int ts, capid, j;
180  unsigned long dat;
181  unsigned short s1,s2,s3;
182  bool somevalid;
183 
184  for (ts=0; ts<timesamples; ts++){
185  capid = ts%4;
186  for (j=0; j<12 ; j++) {
187  somevalid = false;
188  if ( daq_lengths[j*3] == 0 || ( daq_lengths[j*3] & 0xc0 ) ) {
189  s1 = 0x400; // ER !DV
190  } else {
191  s1 = daq_samples[(j*3 )*MAXIMUM_SAMPLES_PER_CHANNEL+ts];
192  somevalid = true;
193  }
194  if ( daq_lengths[j*3+1] == 0 || ( daq_lengths[j*3+1] & 0xc0 ) ) {
195  s2 = 0x400; // ER !DV
196  } else {
197  s2 = daq_samples[(j*3+1)*MAXIMUM_SAMPLES_PER_CHANNEL+ts];
198  somevalid = true;
199  }
200  if ( daq_lengths[j*3+2] == 0 || ( daq_lengths[j*3+2] & 0xc0 ) ) {
201  s3 = 0x400; // ER !DV
202  } else {
203  s3 = daq_samples[(j*3+2)*MAXIMUM_SAMPLES_PER_CHANNEL+ts];
204  somevalid = true;
205  }
206  //dat = 0x80000001 // msb is dv for the fibre
210  //| ( daq_samples[(j*3 )*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x1ff ) << 21
211  //| ( daq_samples[(j*3+1)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x1ff ) << 11
212  //| ( daq_samples[(j*3+2)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x1ff ) << 1
213  //| ( daq_samples[(j*3 )*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x400 ) << 20
214  //| ( daq_samples[(j*3+1)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x400 ) << 10
215  //| ( daq_samples[(j*3+2)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x400 ) ;
216  dat = 0x00000001 // msb is dv for the fibre
217  // sample data is ER(1)+CAPID(2)+EXP(2)+Mantissa(5)
218  // daq_samples has ER(1)+DV(1)+CAPID(2)+EXP(2)+Mantissa(5)
219  // should check daq_lengths for the 3 channels here ??
220  | ( s1 & 0x1ff ) << 21
221  | ( s2 & 0x1ff ) << 11
222  | ( s3 & 0x1ff ) << 1
223  | ( s1 & 0x400 ) << 20
224  | ( s2 & 0x400 ) << 10
225  | ( s3 & 0x400 ) ;
226  if ( somevalid ) dat |= 0x80000000;
227  // should we set dv from daq_samples ??
228  if (do_capid) dat = ( dat & 0xcff3fcff ) | capid << 28 | capid << 18 | capid << 8;
229  ptr[daq_words_total++] = dat >> 16;
230  ptr[daq_words_total++] = dat & 0xffff;
231 
232  }
233  }
234 
235  m_ownData[5]=(tp_words_total<<8)|0x1;
236  unsigned short totalLen=headerLen+12+daq_words_total+trailerLen;
237 
238  m_rawLength=totalLen;
239  m_ownData[totalLen-2]=totalLen/2; // 32-bit words
240  m_ownData[totalLen-3]=totalLen;
241  m_ownData[totalLen-4]=daq_words_total;
242 
243 }
#define min(a, b)
Definition: mlp_lapack.h:161
tuple s2
Definition: indexGen.py:106
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:19
int j
Definition: DBlmapReader.cc:9
unsigned short * m_ownData
void determineStaticLengths(int &headerWords, int &trailerWords, int &triggerWords) const
void CastorCORData::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 245 of file CastorCORData.cc.

References m_formatVersion, m_ownData, and m_rawLength.

Referenced by CastorCtdcPacker::pack().

245  {
246  m_ownData[0]=L1Anumber&0xFF;
247  m_ownData[1]=(L1Anumber&0xFFFF00)>>8;
248 
249  m_ownData[2]=0x8000; // Version is valid, no error bits - status bits need definition
250  m_ownData[3]=((orbitn&0x1F)<<11)|(submodule&0x7FF);
251  m_ownData[4]=((m_formatVersion&0xF)<<12)|(bcn&0xFFF);
252  m_ownData[5]|=((nps&0xF)<<4)|0x1;
253  m_ownData[6]=((firmwareRev&0x70000)>>3)|(firmwareRev&0x1FFF);
254  m_ownData[7]=(pipeline&0xFF) | ((ndd&0x1F)<<8);
255  m_ownData[m_rawLength-4]&=0x7FF;
256  m_ownData[m_rawLength-4]|=(ndd&0x1F)<<11;
257 
258  m_ownData[m_rawLength-2]=m_rawLength/2; // 32-bit words
259  m_ownData[m_rawLength-1]=(L1Anumber&0xFF)<<8;
260 }
unsigned short * m_ownData
unsigned int CastorCORData::readoutVMECrateId ( ) const

HcalElectronicsId-style VME crate number.

Definition at line 276 of file CastorCORData.cc.

References getSubmodule().

276  {
277  const unsigned int smid = getSubmodule();
278  return ((smid>>6)&0x1F);
279 }
unsigned int getSubmodule() const
Get the HTR submodule number.
void CastorCORData::unpack ( unsigned char *  daq_lengths,
unsigned short *  daq_samples,
unsigned char *  tp_lengths,
unsigned short *  tp_samples 
) const

Obtain the starting and ending pointers for external unpacking of the data.

Parameters
daq_firstPointer to a pointer to the start of the DAQ data
daq_lastPointer to a pointer to the end of the DAQ data
tp_firstPointer to a pointer to the start of the TP data
tp_lastPointer to a pointer to the end of the TP dataUnpack the HTR data into TP and DAQ data sorted by channel
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 102 of file CastorCORData.cc.

References CHANNELS_PER_SPIGOT, determineSectionLengths(), j, m_rawConst, and MAXIMUM_SAMPLES_PER_CHANNEL.

Referenced by CastorCtdcUnpacker::unpack().

103  {
104 
105  if (daq_lengths!=0) memset(daq_lengths,0,CHANNELS_PER_SPIGOT);
106  if (tp_lengths!=0) memset(tp_lengths,0,1);
107 
108  int tp_words_total = 0;
109  int daq_words_total = 0;
110  int headerLen = 0;
111  int trailerLen = 0;
112  int triggerLen = 0;
113  determineSectionLengths(tp_words_total,daq_words_total,headerLen,trailerLen,triggerLen);
114 
115  int wordPtr;
116  const unsigned short* tpBase=m_rawConst+headerLen;
117  // process the trigger primitive words
118  if (tp_lengths!=0) {
119  for (wordPtr=0; wordPtr<tp_words_total; wordPtr++) {
120  tp_samples[tp_lengths[0]]=tpBase[wordPtr];
121  tp_lengths[0]++;
122  }
123  }
124 
125  const unsigned short* daqBase=m_rawConst+headerLen+triggerLen;
126  unsigned long dat;
127  // process the DAQ words
128  int lastCapid=0;
129  int ts,dv;
130  int tsamples = daq_words_total/24;
131  if (daq_lengths!=0) {
132  for ( ts = 0; ts < tsamples; ts++ ) {
133  for (int j=0; j<12 ; j++) {
134  dat = daqBase[(ts*12+j)*2]<<16 | daqBase[(ts*12+j)*2+1];
135  dv = ( dat & 0x80000000 ) >> 31;
136  daq_samples[(j*3) *MAXIMUM_SAMPLES_PER_CHANNEL+ts]= (( dat & 0x40000000 ) >> 20 ) | (( dat & 0x3fe00000 ) >> 21 ) | ( dv << 9 );
137  daq_samples[(j*3+1)*MAXIMUM_SAMPLES_PER_CHANNEL+ts]= (( dat & 0x00100000 ) >> 10 ) | (( dat & 0x000ff800 ) >> 11 ) | ( dv << 9 );
138  daq_samples[(j*3+2)*MAXIMUM_SAMPLES_PER_CHANNEL+ts]= (( dat & 0x00000400 ) ) | (( dat & 0x000003fe ) >> 1 ) | ( dv << 9 );
139  }
140  }
141  // now loop over channels - set daq_lengths with error bits
142  int ichan;
143  for ( ichan = 0; ichan<CHANNELS_PER_SPIGOT; ichan++) {
144  daq_lengths[ichan]=tsamples;
145  for ( ts = 0; ts < tsamples; ts++ ) {
146  int erdv =(daq_samples[ichan*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x600 ) >> 9;
147  int capid=(daq_samples[ichan*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x180 ) >> 7;
148  if ( erdv!=1 || ( ts!=0 && (capid!=((lastCapid+1)%4)))) {
149  daq_lengths[ichan]|=0x80;
150  }
151  lastCapid=capid;
152  }
153  }
154  }
155 }
static const int CHANNELS_PER_SPIGOT
Definition: CastorCORData.h:18
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:19
int j
Definition: DBlmapReader.cc:9
const unsigned short * m_rawConst
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords, int &triggerWords) const
Was there an error on the given fiber for this event (only in histogram mode!)
bool CastorCORData::unpackHistogram ( int  fiber,
int  fiberchan,
int  capid,
unsigned short *  histogram 
) const

Unpack special histogramming mode data.

Parameters
fiber
fiberchan
capidCapacitor id for which to extract a histogram
histogramunsigned int[32] into which the data should be deposited

Definition at line 334 of file CastorCORData.cc.

References getHistogramFibers(), i, isHistogramEvent(), m_formatVersion, m_rawConst, and evf::evtn::offset().

334  {
335  // check for histogram mode
336  if (!isHistogramEvent()) return false;
337 
338  int fiber1, fiber2;
339  getHistogramFibers(fiber1,fiber2);
340  if (fiber1!=myfiber && fiber2!=myfiber) return false;
341 
342  if (m_formatVersion==-1) {
343  int offset=6+mysc*4*32+capid*32;
344  if (myfiber==fiber2) offset+=3*4*32; // skip to the second half...
345  for (int i=0; i<32; i++)
346  histogram[i]=m_rawConst[offset+i];
347  return true;
348  } else {
349  int offset=8+mysc*4*32+capid*32;
350  if (myfiber==fiber2) offset+=3*4*32; // skip to the second half...
351  for (int i=0; i<32; i++)
352  histogram[i]=m_rawConst[offset+i];
353  return true;
354  }
355 }
int i
Definition: DBlmapReader.cc:9
unsigned int offset(bool)
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
const unsigned short * m_rawConst
bool CastorCORData::wasMarkAndPassZS ( int  fiber,
int  fiberchan 
) const

Was this channel passed as part of Mark&Pass ZS?

Definition at line 286 of file CastorCORData.cc.

References isUnsuppressed(), m_formatVersion, m_rawConst, m_rawLength, and edm::shift.

286  {
287  if (fiber<1 || fiber>8 || fiberchan<0 || fiberchan>2) return false;
288  if (!isUnsuppressed() || m_formatVersion<5) return false;
289  unsigned short val=(fiber<5)?(m_rawConst[m_rawLength-12]):(m_rawConst[m_rawLength-11]);
290  int shift=(((fiber-1)%4)*3)+fiberchan;
291  return ((val>>shift)&0x1)!=0;
292 }
bool isUnsuppressed() const
Is this event an unsuppresed event?
static unsigned int const shift
const unsigned short * m_rawConst

Member Data Documentation

const int CastorCORData::CHANNELS_PER_SPIGOT = 36
static

Definition at line 18 of file CastorCORData.h.

Referenced by CastorCtdcPacker::pack(), CastorCtdcUnpacker::unpack(), and unpack().

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

Definition at line 226 of file CastorCORData.h.

const int CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL = 20
static

Definition at line 19 of file CastorCORData.h.

Referenced by CastorCtdcPacker::pack(), pack(), CastorCtdcUnpacker::unpack(), and unpack().