CMS 3D CMS Logo

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 (const CastorCORData &)
 
 CastorCORData (const unsigned short *data, int length)
 
 CastorCORData (int version_to_create)
 
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.

Author
A. Campbell - DESY

Definition at line 14 of file CastorCORData.h.

Constructor & Destructor Documentation

◆ CastorCORData() [1/4]

CastorCORData::CastorCORData ( )

Definition at line 20 of file CastorCORData.cc.

20 : m_formatVersion(-2), m_rawLength(0), m_rawConst(nullptr), m_ownData(nullptr) {}

◆ ~CastorCORData()

CastorCORData::~CastorCORData ( )
inline

Definition at line 20 of file CastorCORData.h.

20  {
21  if (m_ownData != nullptr)
22  delete[] m_ownData;
23  }

References m_ownData.

◆ CastorCORData() [2/4]

CastorCORData::CastorCORData ( int  version_to_create)

Definition at line 28 of file CastorCORData.cc.

28  : m_formatVersion(version_to_create) {
29  allocate(version_to_create);
30 }

References allocate().

◆ CastorCORData() [3/4]

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

Definition at line 21 of file CastorCORData.cc.

21  {
22  adoptData(data, length);
23  m_ownData = nullptr;
24 }

References adoptData(), data, and m_ownData.

◆ CastorCORData() [4/4]

CastorCORData::CastorCORData ( const CastorCORData hd)

Definition at line 25 of file CastorCORData.cc.

Member Function Documentation

◆ adoptData()

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

Definition at line 51 of file CastorCORData.cc.

51  {
52  m_rawLength = length;
53  m_rawConst = data;
54  if (m_rawLength < 5) {
55  m_formatVersion = -2; // invalid!
56  } else {
57  m_formatVersion = (m_rawConst[4] >> 12) & 0xF;
58  }
59 }

References data, m_formatVersion, m_rawConst, and m_rawLength.

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

◆ allocate()

void CastorCORData::allocate ( int  version_to_create = 0)

Definition at line 32 of file CastorCORData.cc.

32  {
33  m_formatVersion = version_to_create;
34  // the needed space is for the biggest possible event...
35  const int needed = 0x200;
36  // create a buffer big enough...
37  m_ownData = new unsigned short[needed];
38  m_rawLength = 0;
40 }

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

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

◆ check()

bool CastorCORData::check ( ) const

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

Definition at line 64 of file CastorCORData.cc.

64  {
65  // length checks
66  // minimum length
67  if (m_rawLength < 6 + 12)
68  return false;
69  // matches wordcount
71  return false;
72 
73  // daq/tp length check
74  int tp, daq, header, trailer, trigger;
75  determineSectionLengths(tp, daq, header, trailer, trigger);
76  if (trigger + daq + header + trailer > m_rawLength)
77  return false;
78 
79  return true;
80 }

References determineSectionLengths(), RecoTauValidation_cfi::header, m_rawConst, m_rawLength, and cmsswSequenceInfo::tp.

Referenced by CastorCtdcUnpacker::unpack().

◆ determineSectionLengths()

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

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

References m_rawConst, and m_rawLength.

Referenced by check(), and unpack().

◆ determineStaticLengths()

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

Definition at line 96 of file CastorCORData.cc.

96  {
97  headerWords = 8;
98  triggerLen = 12; // total space reserved for trigger information
99  trailerWords = 12; // minimum, may be more...
100 }

Referenced by pack().

◆ getBunchNumber()

unsigned int CastorCORData::getBunchNumber ( ) const
inline

Get the HTR bunch number.

Definition at line 97 of file CastorCORData.h.

97 { return (m_rawConst[4] & 0xFFF); }

References m_rawConst.

◆ getDLLunlock()

unsigned int CastorCORData::getDLLunlock ( ) const
inline

Get DLLunlock bits.

Definition at line 143 of file CastorCORData.h.

143 { return (m_rawConst[5] >> 2) & 0x3; }

References m_rawConst.

◆ getErrorsWord()

unsigned int CastorCORData::getErrorsWord ( ) const
inline

Get the errors word.

Definition at line 131 of file CastorCORData.h.

131 { return m_rawConst[2] & 0xFFFF; }

References m_rawConst.

◆ getExtHdr1()

unsigned int CastorCORData::getExtHdr1 ( ) const
inline

Get the COR Ext Header words.

Definition at line 181 of file CastorCORData.h.

181 { return (m_rawConst[0]); }

References m_rawConst.

◆ getExtHdr2()

unsigned int CastorCORData::getExtHdr2 ( ) const
inline

Definition at line 182 of file CastorCORData.h.

182 { return (m_rawConst[1]); }

References m_rawConst.

◆ getExtHdr3()

unsigned int CastorCORData::getExtHdr3 ( ) const
inline

Definition at line 183 of file CastorCORData.h.

183 { return (m_rawConst[2]); }

References m_rawConst.

◆ getExtHdr4()

unsigned int CastorCORData::getExtHdr4 ( ) const
inline

Definition at line 184 of file CastorCORData.h.

184 { return (m_rawConst[3]); }

References m_rawConst.

◆ getExtHdr5()

unsigned int CastorCORData::getExtHdr5 ( ) const
inline

Definition at line 185 of file CastorCORData.h.

185 { return (m_rawConst[4]); }

References m_rawConst.

◆ getExtHdr6()

unsigned int CastorCORData::getExtHdr6 ( ) const
inline

Definition at line 186 of file CastorCORData.h.

186 { return (m_rawConst[5]); }

References m_rawConst.

◆ getExtHdr7()

unsigned int CastorCORData::getExtHdr7 ( ) const
inline

Definition at line 187 of file CastorCORData.h.

187 { return (m_rawConst[6]); }

References m_rawConst.

◆ getExtHdr8()

unsigned int CastorCORData::getExtHdr8 ( ) const
inline

Definition at line 188 of file CastorCORData.h.

188 { return (m_rawConst[7]); }

References m_rawConst.

◆ getFib1OrbMsgBCN()

unsigned int CastorCORData::getFib1OrbMsgBCN ( ) const
inline

Get the BCN of the Fiber Orbit Messages.

Definition at line 149 of file CastorCORData.h.

149  {
150  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 12] & 0xFFF);
151  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib2OrbMsgBCN()

unsigned int CastorCORData::getFib2OrbMsgBCN ( ) const
inline

Definition at line 152 of file CastorCORData.h.

152  {
153  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 11] & 0xFFF);
154  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib3OrbMsgBCN()

unsigned int CastorCORData::getFib3OrbMsgBCN ( ) const
inline

Definition at line 156 of file CastorCORData.h.

156  {
157  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 10] & 0xFFF);
158  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib4OrbMsgBCN()

unsigned int CastorCORData::getFib4OrbMsgBCN ( ) const
inline

Definition at line 160 of file CastorCORData.h.

160  {
161  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 9] & 0xFFF);
162  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib5OrbMsgBCN()

unsigned int CastorCORData::getFib5OrbMsgBCN ( ) const
inline

Definition at line 164 of file CastorCORData.h.

164  {
165  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 8] & 0xFFF);
166  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib6OrbMsgBCN()

unsigned int CastorCORData::getFib6OrbMsgBCN ( ) const
inline

Definition at line 168 of file CastorCORData.h.

168  {
169  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 7] & 0xFFF);
170  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib7OrbMsgBCN()

unsigned int CastorCORData::getFib7OrbMsgBCN ( ) const
inline

Definition at line 172 of file CastorCORData.h.

172  {
173  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 6] & 0xFFF);
174  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFib8OrbMsgBCN()

unsigned int CastorCORData::getFib8OrbMsgBCN ( ) const
inline

Definition at line 176 of file CastorCORData.h.

176  {
177  return (m_formatVersion == -1) ? (0) : (m_rawConst[m_rawLength - 5] & 0xFFF);
178  }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getFirmwareRevision()

unsigned int CastorCORData::getFirmwareRevision ( ) const

Get the COR firmware version.

Definition at line 313 of file CastorCORData.cc.

313 { return (m_rawConst[6]); }

References m_rawConst.

◆ getFormatVersion()

int CastorCORData::getFormatVersion ( ) const
inline

Get the version number of this event.

Definition at line 33 of file CastorCORData.h.

33 { return m_formatVersion; }

References m_formatVersion.

◆ getHistogramFibers()

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

315  {
316  a = -1;
317  b = -1;
318  if (m_formatVersion == -1) {
319  a = ((m_rawConst[2] & 0x0F00) >> 8);
320  b = ((m_rawConst[2] & 0xF000) >> 12);
321  } else {
322  a = ((m_rawConst[5] & 0x0F00) >> 8);
323  b = ((m_rawConst[5] & 0xF000) >> 12);
324  }
325 }

References a, b, m_formatVersion, and m_rawConst.

Referenced by unpackHistogram().

◆ getL1ANumber()

unsigned int CastorCORData::getL1ANumber ( ) const
inline

Get the HTR event number.

Definition at line 95 of file CastorCORData.h.

95 { return (m_rawConst[0] & 0xFF) + (m_rawConst[1] << 8); }

References m_rawConst.

◆ getNDD()

int CastorCORData::getNDD ( ) const

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

Definition at line 297 of file CastorCORData.cc.

297  {
298  return (m_formatVersion == -1) ? (m_rawConst[m_rawLength - 4] >> 8) : (m_rawConst[m_rawLength - 4] >> 11);
299 }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getNPrecisionWords()

int CastorCORData::getNPrecisionWords ( ) const

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

Definition at line 308 of file CastorCORData.cc.

308  {
309  return (m_formatVersion == -1) ? (m_rawConst[m_rawLength - 4] & 0xFF) : (m_rawConst[m_rawLength - 4] & 0x7FF);
310 }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getNPS()

int CastorCORData::getNPS ( ) const

Get the number of presamples in daq data.

Definition at line 311 of file CastorCORData.cc.

311 { return (m_formatVersion == -1) ? (0) : ((m_rawConst[5] >> 4) & 0xF); }

References m_formatVersion, and m_rawConst.

Referenced by CastorCtdcUnpacker::unpack().

◆ getNTP()

int CastorCORData::getNTP ( ) const

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

Definition at line 300 of file CastorCORData.cc.

300  {
301  int retval = -1;
302  if (m_formatVersion == -1)
303  retval = m_rawConst[m_rawLength - 4] & 0xFF;
304  else if (m_formatVersion < 3)
305  retval = m_rawConst[m_rawLength - 4] >> 11;
306  return retval;
307 }

References m_formatVersion, m_rawConst, and m_rawLength.

◆ getOrbitNumber()

unsigned int CastorCORData::getOrbitNumber ( ) const

Get the HTR orbit number.

Definition at line 267 of file CastorCORData.cc.

267 { return (m_rawConst[3] >> 11); }

References m_rawConst.

◆ getPipelineLength()

unsigned int CastorCORData::getPipelineLength ( ) const

Get the pipeline length used for this event.

Definition at line 312 of file CastorCORData.cc.

312 { return (m_rawConst[7] & 0xFF); }

References m_rawConst.

◆ getRawData()

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

Get a pointer to the raw data.

Definition at line 36 of file CastorCORData.h.

36 { return m_rawConst; }

References m_rawConst.

◆ getRawLength()

const int CastorCORData::getRawLength ( ) const
inline

Get the length of the raw data.

Definition at line 39 of file CastorCORData.h.

39 { return m_rawLength; }

References m_rawLength.

Referenced by CastorCtdcPacker::pack().

◆ getSubmodule()

unsigned int CastorCORData::getSubmodule ( ) const

Get the HTR submodule number.

Definition at line 268 of file CastorCORData.cc.

268 { return (m_rawConst[3] & 0x7FF); }

References m_rawConst.

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

◆ getTTCready()

unsigned int CastorCORData::getTTCready ( ) const
inline

Get TTCready bits.

Definition at line 146 of file CastorCORData.h.

146 { return m_rawConst[5] & 0x3; }

References m_rawConst.

◆ htrSlot()

unsigned int CastorCORData::htrSlot ( ) const

HcalElectronicsId-style HTR slot.

Definition at line 269 of file CastorCORData.cc.

269  {
270  const unsigned int smid = getSubmodule();
271  return ((smid >> 1) & 0x1F);
272 }

References getSubmodule().

◆ htrTopBottom()

unsigned int CastorCORData::htrTopBottom ( ) const

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

Definition at line 273 of file CastorCORData.cc.

273  {
274  const unsigned int smid = getSubmodule();
275  return (smid & 0x01);
276 }

References getSubmodule().

◆ isCalibrationStream()

bool CastorCORData::isCalibrationStream ( ) const

Is this event a calibration-stream event?

Definition at line 281 of file CastorCORData.cc.

281 { return (m_formatVersion == -1) ? (false) : (m_rawConst[2] & 0x4000); }

References m_formatVersion, and m_rawConst.

◆ isHistogramEvent()

bool CastorCORData::isHistogramEvent ( ) const

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

Definition at line 294 of file CastorCORData.cc.

294  {
295  return (m_formatVersion == -1) ? (m_rawConst[2] & 0x2) : (m_rawConst[2] & 0x2000);
296 }

References m_formatVersion, and m_rawConst.

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

◆ isPatternRAMEvent()

bool CastorCORData::isPatternRAMEvent ( ) const

Is this event a pattern-ram event?

Definition at line 293 of file CastorCORData.cc.

293 { return (m_formatVersion == -1) ? (false) : (m_rawConst[2] & 0x1000); }

References m_formatVersion, and m_rawConst.

◆ isUnsuppressed()

bool CastorCORData::isUnsuppressed ( ) const

Is this event an unsuppresed event?

Definition at line 282 of file CastorCORData.cc.

282 { return (m_formatVersion < 4) ? (false) : (m_rawConst[6] & 0x8000); }

References m_formatVersion, and m_rawConst.

Referenced by wasMarkAndPassZS().

◆ operator=()

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

Definition at line 42 of file CastorCORData.cc.

42  {
43  if (m_ownData == nullptr) {
47  }
48  return (*this);
49 }

References m_formatVersion, m_ownData, m_rawConst, and m_rawLength.

◆ pack()

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

167  {
168  int tp_words_total = 0, daq_words_total = 0, headerLen, trailerLen, triggerLen;
169  determineStaticLengths(headerLen, trailerLen, triggerLen);
170 
171  tp_words_total = 0;
172  daq_words_total = 0;
173  int isample;
174 
175  // trigger words
176  unsigned short* ptr = m_ownData + headerLen;
177  if (tp_samples != nullptr && tp_lengths != nullptr) {
178  for (isample = 0; isample < tp_lengths[0] && isample < 12; isample++) {
179  ptr[tp_words_total] = tp_samples[isample];
180  tp_words_total++;
181  }
182  }
183 
184  // daq words
185  ptr = m_ownData + headerLen + triggerLen;
186  int timesamples = std::min(daq_lengths[0] & 0x3f, MAXIMUM_SAMPLES_PER_CHANNEL);
187  int ts, capid, j;
188  unsigned long dat;
189  unsigned short s1, s2, s3;
190  bool somevalid;
191 
192  for (ts = 0; ts < timesamples; ts++) {
193  capid = ts % 4;
194  for (j = 0; j < 12; j++) {
195  somevalid = false;
196  if (daq_lengths[j * 3] == 0 || (daq_lengths[j * 3] & 0xc0)) {
197  s1 = 0x400; // ER !DV
198  } else {
199  s1 = daq_samples[(j * 3) * MAXIMUM_SAMPLES_PER_CHANNEL + ts];
200  somevalid = true;
201  }
202  if (daq_lengths[j * 3 + 1] == 0 || (daq_lengths[j * 3 + 1] & 0xc0)) {
203  s2 = 0x400; // ER !DV
204  } else {
205  s2 = daq_samples[(j * 3 + 1) * MAXIMUM_SAMPLES_PER_CHANNEL + ts];
206  somevalid = true;
207  }
208  if (daq_lengths[j * 3 + 2] == 0 || (daq_lengths[j * 3 + 2] & 0xc0)) {
209  s3 = 0x400; // ER !DV
210  } else {
211  s3 = daq_samples[(j * 3 + 2) * MAXIMUM_SAMPLES_PER_CHANNEL + ts];
212  somevalid = true;
213  }
214  //dat = 0x80000001 // msb is dv for the fibre
218  //| ( daq_samples[(j*3 )*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x1ff ) << 21
219  //| ( daq_samples[(j*3+1)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x1ff ) << 11
220  //| ( daq_samples[(j*3+2)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x1ff ) << 1
221  //| ( daq_samples[(j*3 )*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x400 ) << 20
222  //| ( daq_samples[(j*3+1)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x400 ) << 10
223  //| ( daq_samples[(j*3+2)*MAXIMUM_SAMPLES_PER_CHANNEL+ts] & 0x400 ) ;
224  dat = 0x00000001 // msb is dv for the fibre
225  // sample data is ER(1)+CAPID(2)+EXP(2)+Mantissa(5)
226  // daq_samples has ER(1)+DV(1)+CAPID(2)+EXP(2)+Mantissa(5)
227  // should check daq_lengths for the 3 channels here ??
228  | (s1 & 0x1ff) << 21 | (s2 & 0x1ff) << 11 | (s3 & 0x1ff) << 1 | (s1 & 0x400) << 20 | (s2 & 0x400) << 10 |
229  (s3 & 0x400);
230  if (somevalid)
231  dat |= 0x80000000;
232  // should we set dv from daq_samples ??
233  if (do_capid)
234  dat = (dat & 0xcff3fcff) | capid << 28 | capid << 18 | capid << 8;
235  ptr[daq_words_total++] = dat >> 16;
236  ptr[daq_words_total++] = dat & 0xffff;
237  }
238  }
239 
240  m_ownData[5] = (tp_words_total << 8) | 0x1;
241  unsigned short totalLen = headerLen + 12 + daq_words_total + trailerLen;
242 
243  m_rawLength = totalLen;
244  m_ownData[totalLen - 2] = totalLen / 2; // 32-bit words
245  m_ownData[totalLen - 3] = totalLen;
246  m_ownData[totalLen - 4] = daq_words_total;
247 }

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

Referenced by CastorCtdcPacker::pack().

◆ packHeaderTrailer()

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

250  {
251  m_ownData[0] = L1Anumber & 0xFF;
252  m_ownData[1] = (L1Anumber & 0xFFFF00) >> 8;
253 
254  m_ownData[2] = 0x8000; // Version is valid, no error bits - status bits need definition
255  m_ownData[3] = ((orbitn & 0x1F) << 11) | (submodule & 0x7FF);
256  m_ownData[4] = ((m_formatVersion & 0xF) << 12) | (bcn & 0xFFF);
257  m_ownData[5] |= ((nps & 0xF) << 4) | 0x1;
258  m_ownData[6] = ((firmwareRev & 0x70000) >> 3) | (firmwareRev & 0x1FFF);
259  m_ownData[7] = (pipeline & 0xFF) | ((ndd & 0x1F) << 8);
260  m_ownData[m_rawLength - 4] &= 0x7FF;
261  m_ownData[m_rawLength - 4] |= (ndd & 0x1F) << 11;
262 
263  m_ownData[m_rawLength - 2] = m_rawLength / 2; // 32-bit words
264  m_ownData[m_rawLength - 1] = (L1Anumber & 0xFF) << 8;
265 }

References m_formatVersion, m_ownData, and m_rawLength.

Referenced by CastorCtdcPacker::pack().

◆ readoutVMECrateId()

unsigned int CastorCORData::readoutVMECrateId ( ) const

HcalElectronicsId-style VME crate number.

Definition at line 277 of file CastorCORData.cc.

277  {
278  const unsigned int smid = getSubmodule();
279  return ((smid >> 6) & 0x1F);
280 }

References getSubmodule().

◆ unpack()

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 data

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

105  {
106  if (daq_lengths != nullptr)
107  memset(daq_lengths, 0, CHANNELS_PER_SPIGOT);
108  if (tp_lengths != nullptr)
109  memset(tp_lengths, 0, 1);
110 
111  int tp_words_total = 0;
112  int daq_words_total = 0;
113  int headerLen = 0;
114  int trailerLen = 0;
115  int triggerLen = 0;
116  determineSectionLengths(tp_words_total, daq_words_total, headerLen, trailerLen, triggerLen);
117 
118  int wordPtr;
119  const unsigned short* tpBase = m_rawConst + headerLen;
120  // process the trigger primitive words
121  if (tp_lengths != nullptr) {
122  for (wordPtr = 0; wordPtr < tp_words_total; wordPtr++) {
123  tp_samples[tp_lengths[0]] = tpBase[wordPtr];
124  tp_lengths[0]++;
125  }
126  }
127 
128  const unsigned short* daqBase = m_rawConst + headerLen + triggerLen;
129  unsigned long dat;
130  // process the DAQ words
131  int lastCapid = 0;
132  int ts, dv;
133  int tsamples = daq_words_total / 24;
134  if (daq_lengths != nullptr) {
135  for (ts = 0; ts < tsamples; ts++) {
136  for (int j = 0; j < 12; j++) {
137  dat = daqBase[(ts * 12 + j) * 2] << 16 | daqBase[(ts * 12 + j) * 2 + 1];
138  dv = (dat & 0x80000000) >> 31;
139  daq_samples[(j * 3) * MAXIMUM_SAMPLES_PER_CHANNEL + ts] =
140  ((dat & 0x40000000) >> 20) | ((dat & 0x3fe00000) >> 21) | (dv << 9);
141  daq_samples[(j * 3 + 1) * MAXIMUM_SAMPLES_PER_CHANNEL + ts] =
142  ((dat & 0x00100000) >> 10) | ((dat & 0x000ff800) >> 11) | (dv << 9);
143  daq_samples[(j * 3 + 2) * MAXIMUM_SAMPLES_PER_CHANNEL + ts] =
144  ((dat & 0x00000400)) | ((dat & 0x000003fe) >> 1) | (dv << 9);
145  }
146  }
147  // now loop over channels - set daq_lengths with error bits
148  int ichan;
149  for (ichan = 0; ichan < CHANNELS_PER_SPIGOT; ichan++) {
150  daq_lengths[ichan] = tsamples;
151  for (ts = 0; ts < tsamples; ts++) {
152  int erdv = (daq_samples[ichan * MAXIMUM_SAMPLES_PER_CHANNEL + ts] & 0x600) >> 9;
153  int capid = (daq_samples[ichan * MAXIMUM_SAMPLES_PER_CHANNEL + ts] & 0x180) >> 7;
154  if (erdv != 1 || (ts != 0 && (capid != ((lastCapid + 1) % 4)))) {
155  daq_lengths[ichan] |= 0x80;
156  }
157  lastCapid = capid;
158  }
159  }
160  }
161 }

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

Referenced by CastorCtdcUnpacker::unpack().

◆ unpackHistogram()

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

327  {
328  // check for histogram mode
329  if (!isHistogramEvent())
330  return false;
331 
332  int fiber1, fiber2;
333  getHistogramFibers(fiber1, fiber2);
334  if (fiber1 != myfiber && fiber2 != myfiber)
335  return false;
336 
337  if (m_formatVersion == -1) {
338  int offset = 6 + mysc * 4 * 32 + capid * 32;
339  if (myfiber == fiber2)
340  offset += 3 * 4 * 32; // skip to the second half...
341  for (int i = 0; i < 32; i++)
342  histogram[i] = m_rawConst[offset + i];
343  return true;
344  } else {
345  int offset = 8 + mysc * 4 * 32 + capid * 32;
346  if (myfiber == fiber2)
347  offset += 3 * 4 * 32; // skip to the second half...
348  for (int i = 0; i < 32; i++)
349  histogram[i] = m_rawConst[offset + i];
350  return true;
351  }
352 }

References getHistogramFibers(), mps_fire::i, isHistogramEvent(), m_formatVersion, m_rawConst, and hltrates_dqm_sourceclient-live_cfg::offset.

◆ wasMarkAndPassZS()

bool CastorCORData::wasMarkAndPassZS ( int  fiber,
int  fiberchan 
) const

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

Definition at line 283 of file CastorCORData.cc.

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

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

Member Data Documentation

◆ CHANNELS_PER_SPIGOT

const int CastorCORData::CHANNELS_PER_SPIGOT = 36
static

Definition at line 16 of file CastorCORData.h.

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

◆ m_formatVersion

int CastorCORData::m_formatVersion
protected

◆ m_ownData

unsigned short* CastorCORData::m_ownData
protected

◆ m_rawConst

const unsigned short* CastorCORData::m_rawConst
protected

◆ m_rawLength

int CastorCORData::m_rawLength
protected

◆ m_unpackedData

unsigned short* CastorCORData::m_unpackedData
protected

Definition at line 212 of file CastorCORData.h.

◆ MAXIMUM_SAMPLES_PER_CHANNEL

const int CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL = 20
static

Definition at line 17 of file CastorCORData.h.

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

mps_fire.i
i
Definition: mps_fire.py:355
CastorCORData::adoptData
void adoptData(const unsigned short *data, int length)
Definition: CastorCORData.cc:51
min
T min(T a, T b)
Definition: MathUtil.h:58
CastorCORData::isHistogramEvent
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: CastorCORData.cc:294
indexGen.s2
s2
Definition: indexGen.py:107
CastorCORData::m_ownData
unsigned short * m_ownData
Definition: CastorCORData.h:211
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
CastorCORData::getHistogramFibers
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!)
Definition: CastorCORData.cc:315
b
double b
Definition: hdecay.h:118
CastorCORData::m_rawConst
const unsigned short * m_rawConst
Definition: CastorCORData.h:210
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
CastorCORData::allocate
void allocate(int version_to_create=0)
Definition: CastorCORData.cc:32
CastorCORData::determineSectionLengths
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!)
Definition: CastorCORData.cc:82
a
double a
Definition: hdecay.h:119
CastorCORData::m_formatVersion
int m_formatVersion
Definition: CastorCORData.h:208
CastorCORData::CHANNELS_PER_SPIGOT
static const int CHANNELS_PER_SPIGOT
Definition: CastorCORData.h:16
CastorCORData::m_rawLength
int m_rawLength
Definition: CastorCORData.h:209
heppy_batch.val
val
Definition: heppy_batch.py:351
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:17
CastorCORData::determineStaticLengths
void determineStaticLengths(int &headerWords, int &trailerWords, int &triggerWords) const
Definition: CastorCORData.cc:96
CastorCORData::getSubmodule
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: CastorCORData.cc:268
CastorCORData::isUnsuppressed
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: CastorCORData.cc:282
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
trigger
Definition: HLTPrescaleTableCond.h:8
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78