CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
CSCEventData Class Reference

#include <CSCEventData.h>

Public Member Functions

void add (const CSCStripDigi &, int layer)
 routines to add digis to the data More...
 
void add (const CSCWireDigi &, int layer)
 
void add (const CSCComparatorDigi &, int layer)
 
void add (const CSCComparatorDigi &, const CSCDetId &)
 
void add (const std::vector< CSCALCTDigi > &)
 these go in as vectors, so they get sorted right away More...
 
void add (const std::vector< CSCCLCTDigi > &)
 
void add (const std::vector< CSCCorrelatedLCTDigi > &)
 
void addALCTStructures ()
 adds an empty ALCTHeader, trailer, and anode data More...
 
CSCAnodeDataalctData () const
 user must check if nalct > 0 More...
 
CSCALCTHeaderalctHeader () const
 user must check if nalct > 0 More...
 
CSCALCTTraileralctTrailer () const
 user must check if nalct > 0 More...
 
unsigned int calcALCTcrc (std::vector< std::pair< unsigned int, unsigned short * > > &vec)
 
const CSCCFEBDatacfebData (unsigned icfeb) const
 unpacked in long mode: has overflow and error bits decoded More...
 
int chamberType () const
 might not be set in real data More...
 
CSCCLCTDataclctData () const
 user must check if nclct > 0 More...
 
 CSCEventData (int chamberType, uint16_t format_version=2005)
 
 CSCEventData (const uint16_t *buf, uint16_t format_version=2005)
 should make const input soon More...
 
 CSCEventData ()
 
 CSCEventData (const CSCEventData &data)
 
const CSCDMBHeaderdmbHeader () const
 the DAQ motherboard header. A good place for event and chamber info More...
 
CSCDMBHeaderdmbHeader ()
 
const CSCDMBTrailerdmbTrailer () const
 DMB trailer. More...
 
uint16_t getFormatVersion () const
 
bool isALCT (const uint16_t *buf)
 if dealing with ALCT data More...
 
bool isTMB (const uint16_t *buf)
 if dealing with TMB data More...
 
int nalct () const
 the flag for existence of ALCT data More...
 
int nclct () const
 the number of CLCTs More...
 
CSCEventData operator= (const CSCEventData &data)
 
boost::dynamic_bitset pack ()
 returns the packed event data. More...
 
void setEventInformation (int bxnum, int lvl1num)
 
unsigned short size () const
 size of the data buffer used, in bytes More...
 
std::vector< CSCStripDigistripDigis (const CSCDetId &idlayer) const
 returns all the strip digis in the chamber, with the comparator information. More...
 
std::vector< CSCStripDigistripDigis (unsigned idlayer, unsigned icfeb) const
 returns all the strip digis in the chamber's cfeb More...
 
std::vector< std::vector< CSCStripDigi > > stripDigis () const
 deprecated. Use the above methods instead More...
 
CSCTMBDatatmbData () const
 user must check in nclct > 0 More...
 
CSCTMBHeadertmbHeader () const
 user must check if nclct > 0 More...
 
std::vector< CSCWireDigiwireDigis (unsigned ilayer) const
 
std::vector< std::vector< CSCWireDigi > > wireDigis () const
 deprecated. Use the above method instead. More...
 
 ~CSCEventData ()
 

Static Public Member Functions

static void selfTest ()
 
static void setDebug (const bool value)
 

Static Public Attributes

static std::atomic< bool > debug {false}
 

Private Member Functions

void addComparatorInformation (std::vector< CSCStripDigi > &, int layer) const
 adds the comparators to the strip digis More...
 
void checkALCTClasses ()
 makes new ALCT classes, if needed More...
 
void checkTMBClasses ()
 makes new TMB classes, if needed More...
 
void copy (const CSCEventData &)
 
void destroy ()
 
void init ()
 
void unpack_data (const uint16_t *buf)
 

Private Attributes

unsigned short * alctZSErecovered
 Auxiliary bufer to recove the ALCT raw payload from zero suppression. More...
 
int size_
 
CSCALCTHeadertheALCTHeader
 
CSCALCTTrailertheALCTTrailer
 
CSCAnodeDatatheAnodeData
 
CSCCFEBDatatheCFEBData [7]
 for up to MAX_CFEB CFEB boards More...
 
int theChamberType
 
CSCDMBHeader theDMBHeader
 
CSCDMBTrailer theDMBTrailer
 
uint16_t theFormatVersion
 Output Format Version (2005, 2013) More...
 
CSCTMBDatatheTMBData
 
int zseEnable
 

Detailed Description

Definition at line 28 of file CSCEventData.h.

Constructor & Destructor Documentation

CSCEventData::CSCEventData ( int  chamberType,
uint16_t  format_version = 2005 
)
explicit

Definition at line 17 of file CSCEventData.cc.

References mps_fire::i, MAX_CFEB, and theCFEBData.

18  : theDMBHeader(format_version),
19  theALCTHeader(nullptr),
20  theAnodeData(nullptr),
21  theALCTTrailer(nullptr),
22  theTMBData(nullptr),
23  theDMBTrailer(format_version),
25  alctZSErecovered(nullptr),
26  zseEnable(0),
27  theFormatVersion(format_version) {
28  for (unsigned i = 0; i < MAX_CFEB; ++i) {
29  theCFEBData[i] = nullptr;
30  }
31 }
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:170
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:162
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
int chamberType() const
might not be set in real data
Definition: CSCEventData.h:119
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
CSCEventData::CSCEventData ( const uint16_t *  buf,
uint16_t  format_version = 2005 
)

should make const input soon

Definition at line 33 of file CSCEventData.cc.

References theFormatVersion, and unpack_data().

33  : theFormatVersion(format_version) {
34  theFormatVersion = format_version;
35  unpack_data(buf);
36 }
void unpack_data(const uint16_t *buf)
Definition: CSCEventData.cc:38
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
CSCEventData::CSCEventData ( )
inline

Definition at line 33 of file CSCEventData.h.

References data, operator=(), and ~CSCEventData().

33 {}
CSCEventData::~CSCEventData ( )

since we need deep copies, need the Big Three (destructor, copy ctor, op=)

Definition at line 259 of file CSCEventData.cc.

References destroy().

Referenced by CSCEventData().

259 { destroy(); }
CSCEventData::CSCEventData ( const CSCEventData data)

Definition at line 257 of file CSCEventData.cc.

References copy().

257 { copy(data); }
void copy(const CSCEventData &)

Member Function Documentation

void CSCEventData::add ( const CSCStripDigi digi,
int  layer 
)

routines to add digis to the data

Definition at line 467 of file CSCEventData.cc.

References CSCCFEBData::add(), CSCDMBHeader::addCFEB(), CSCDMBHeader::format_version(), CSCStripDigi::getADCCounts(), CSCStripDigi::getStrip(), theCFEBData, theDMBHeader, and theFormatVersion.

Referenced by CSCDigiToRaw::add(), dmbTrailer(), counter.Counter::register(), SequenceTypes.Task::remove(), SequenceTypes.Task::replace(), and selfTest().

467  {
468  //@@ need special logic here for ME11
469  unsigned cfeb = (digi.getStrip() - 1) / 16;
470  bool sixteenSamples = false;
471  if (digi.getADCCounts().size() == 16)
472  sixteenSamples = true;
473  if (theCFEBData[cfeb] == nullptr) {
474  bool isDCFEB = false;
475  if (theDMBHeader.format_version() == 2)
476  isDCFEB = true;
477  theCFEBData[cfeb] = new CSCCFEBData(cfeb, sixteenSamples, theFormatVersion, isDCFEB);
478  theDMBHeader.addCFEB(cfeb);
479  }
480  theCFEBData[cfeb]->add(digi, layer);
481 }
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
std::vector< int > const & getADCCounts() const
Get ADC readings.
Definition: CSCStripDigi.h:44
void add(const CSCStripDigi &, int layer)
Definition: CSCCFEBData.cc:82
int getStrip() const
Definition: CSCStripDigi.h:41
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
void addCFEB(int icfeb)
Definition: CSCDMBHeader.h:23
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
unsigned format_version() const
Definition: CSCDMBHeader.h:49
void CSCEventData::add ( const CSCWireDigi digi,
int  layer 
)

Definition at line 483 of file CSCEventData.cc.

References CSCAnodeData::add(), checkALCTClasses(), CSCWireDigi::getWireGroup(), CSCWireDigi::getWireGroupBX(), CSCALCTHeader::setBXNCount(), CSCALCTHeader::setDAVForChannel(), theALCTHeader, and theAnodeData.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

483  {
485  theAnodeData->add(digi, layer);
488 }
void checkALCTClasses()
makes new ALCT classes, if needed
void setBXNCount(unsigned int bxn)
Definition: CSCALCTHeader.h:78
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
void add(const CSCWireDigi &wireDigi, int layer)
Definition: CSCAnodeData.h:25
int getWireGroup() const
default
Definition: CSCWireDigi.h:22
int getWireGroupBX() const
return BX assigned for the wire group (16 upper bits from the wire group number)
Definition: CSCWireDigi.h:24
void setDAVForChannel(int wireGroup)
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
void CSCEventData::add ( const CSCComparatorDigi digi,
int  layer 
)

Definition at line 490 of file CSCEventData.cc.

References CSCCLCTData::add(), checkTMBClasses(), CSCTMBData::clctData(), and theTMBData.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

490  {
491  checkTMBClasses();
492  theTMBData->clctData()->add(digi, layer);
493 }
CSCCLCTData * clctData()
Definition: CSCTMBData.h:40
void checkTMBClasses()
makes new TMB classes, if needed
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn&#39;t do flipping yet.
Definition: CSCCLCTData.cc:191
void CSCEventData::add ( const CSCComparatorDigi digi,
const CSCDetId cid 
)

Definition at line 495 of file CSCEventData.cc.

References CSCCLCTData::add(), checkTMBClasses(), CSCTMBData::clctData(), and theTMBData.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

495  {
496  checkTMBClasses();
497  theTMBData->clctData()->add(digi, cid);
498 }
CSCCLCTData * clctData()
Definition: CSCTMBData.h:40
void checkTMBClasses()
makes new TMB classes, if needed
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn&#39;t do flipping yet.
Definition: CSCCLCTData.cc:191
void CSCEventData::add ( const std::vector< CSCALCTDigi > &  digis)

these go in as vectors, so they get sorted right away

Definition at line 500 of file CSCEventData.cc.

References CSCALCTHeader::add(), checkALCTClasses(), and theALCTHeader.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

500  {
502  theALCTHeader->add(digis);
503 }
void checkALCTClasses()
makes new ALCT classes, if needed
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
void add(const std::vector< CSCALCTDigi > &digis)
void CSCEventData::add ( const std::vector< CSCCLCTDigi > &  digis)

Definition at line 505 of file CSCEventData.cc.

References CSCTMBHeader::add(), checkTMBClasses(), theTMBData, and CSCTMBData::tmbHeader().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

505  {
506  checkTMBClasses();
507  theTMBData->tmbHeader()->add(digis);
508 }
void checkTMBClasses()
makes new TMB classes, if needed
void add(const std::vector< CSCCLCTDigi > &digis)
these methods need more brains to figure which one goes first
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:39
void CSCEventData::add ( const std::vector< CSCCorrelatedLCTDigi > &  digis)

Definition at line 510 of file CSCEventData.cc.

References CSCTMBHeader::add(), checkTMBClasses(), theTMBData, and CSCTMBData::tmbHeader().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

510  {
511  checkTMBClasses();
512  theTMBData->tmbHeader()->add(digis);
513 }
void checkTMBClasses()
makes new TMB classes, if needed
void add(const std::vector< CSCCLCTDigi > &digis)
these methods need more brains to figure which one goes first
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:39
void CSCEventData::addALCTStructures ( )

adds an empty ALCTHeader, trailer, and anode data

Referenced by dmbTrailer().

void CSCEventData::addComparatorInformation ( std::vector< CSCStripDigi > &  ,
int  layer 
) const
private

adds the comparators to the strip digis

CSCAnodeData * CSCEventData::alctData ( ) const

user must check if nalct > 0

Definition at line 381 of file CSCEventData.cc.

References Exception, nalct(), and theAnodeData.

Referenced by dmbHeader(), and cscdqm::EventProcessor::processCSC().

381  {
382  if (nalct() == 0)
383  throw cms::Exception("No ALCT for this chamber");
384  return theAnodeData;
385 }
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:69
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
CSCALCTHeader * CSCEventData::alctHeader ( ) const

user must check if nalct > 0

Definition at line 369 of file CSCEventData.cc.

References Exception, nalct(), and theALCTHeader.

Referenced by dmbHeader(), pack(), and cscdqm::EventProcessor::processCSC().

369  {
370  if (nalct() == 0)
371  throw cms::Exception("No ALCT for this chamber");
372  return theALCTHeader;
373 }
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:69
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
CSCALCTTrailer * CSCEventData::alctTrailer ( ) const

user must check if nalct > 0

Definition at line 375 of file CSCEventData.cc.

References Exception, nalct(), and theALCTTrailer.

Referenced by dmbHeader(), pack(), and cscdqm::EventProcessor::processCSC().

375  {
376  if (nalct() == 0)
377  throw cms::Exception("No ALCT for this chamber");
378  return theALCTTrailer;
379 }
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:69
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
unsigned int CSCEventData::calcALCTcrc ( std::vector< std::pair< unsigned int, unsigned short * > > &  vec)

Definition at line 569 of file CSCEventData.cc.

References RawDataTask_cfi::CRC, mps_fire::i, dqmiolumiharvest::j, dqmiodumpmetadata::n, edm::second(), OrderedSet::t, and w.

Referenced by getFormatVersion(), and pack().

569  {
570  int CRC = 0;
571  // int size=0;
572 
573  for (unsigned int n = 0; n < vec.size(); n++) {
574  // size += vec[n].first;
575  for (uint16_t j = 0, w = 0; j < vec[n].first; j++) {
576  if (vec[n].second != nullptr) {
577  w = vec[n].second[j] & 0xffff;
578  for (uint32_t i = 15, t = 0, ncrc = 0; i < 16; i--) {
579  t = ((w >> i) & 1) ^ ((CRC >> 21) & 1);
580  ncrc = (CRC << 1) & 0x3ffffc;
581  ncrc |= (t ^ (CRC & 1)) << 1;
582  ncrc |= t;
583  CRC = ncrc;
584  }
585  }
586  }
587  }
588 
589  // std::cout << "ALCT CRC vector size: " << size << ", crc: 0x" << std::hex << CRC<< std::endl;
590  return CRC;
591 }
const double w
Definition: UKUtility.cc:23
U second(std::pair< T, U > const &p)
const CSCCFEBData * CSCEventData::cfebData ( unsigned  icfeb) const

unpacked in long mode: has overflow and error bits decoded

Definition at line 367 of file CSCEventData.cc.

References theCFEBData.

Referenced by pack(), cscdqm::EventProcessor::processCSC(), and setDebug().

367 { return theCFEBData[icfeb]; }
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
int CSCEventData::chamberType ( ) const
inline

might not be set in real data

Definition at line 119 of file CSCEventData.h.

References theChamberType.

119 { return theChamberType; }
void CSCEventData::checkALCTClasses ( )
private

makes new ALCT classes, if needed

Definition at line 436 of file CSCEventData.cc.

References CSCDMBHeader::addNALCT(), CSCALCTHeader::alctFirmwareVersion(), CSCALCTHeader::setEventInformation(), size(), CSCAnodeData::sizeInWords(), CSCALCTTrailer::sizeInWords(), CSCALCTHeader::sizeInWords(), theALCTHeader, theALCTTrailer, theAnodeData, theChamberType, and theDMBHeader.

Referenced by add().

436  {
437  if (theAnodeData == nullptr) {
438  assert(theChamberType > 0);
444  // set data available flag
446  }
447 }
unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData.h:19
void setEventInformation(const CSCDMBHeader &)
static int sizeInWords()
in 16-bit frames
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
int sizeInWords()
in 16-bit words
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
unsigned short int alctFirmwareVersion() const
unsigned short size() const
size of the data buffer used, in bytes
Definition: CSCEventData.h:41
void addNALCT()
Definition: CSCDMBHeader.h:26
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
void CSCEventData::checkTMBClasses ( )
private

makes new TMB classes, if needed

Definition at line 449 of file CSCEventData.cc.

References CSCDMBHeader::addNCLCT(), CSCTMBHeader::setEventInformation(), CSCTMBHeader::setNCFEBs(), theChamberType, theDMBHeader, theFormatVersion, theTMBData, and CSCTMBData::tmbHeader().

Referenced by add().

449  {
450  int nCFEBs = 5;
451  if ((theFormatVersion == 2013) && ((theChamberType == 1) || (theChamberType == 2))) {
452  nCFEBs = 7;
453  }
454  if (theTMBData == nullptr) {
455  if (theFormatVersion == 2013) { // Set to TMB format for Post-LS1 data
456  theTMBData = new CSCTMBData(2013, 0x7a76, nCFEBs);
457  } else {
458  theTMBData = new CSCTMBData(2007, 0x50c3);
459  }
462  }
463  theTMBData->tmbHeader()->setNCFEBs(nCFEBs);
464  // std::cout << "nCFEBs: " << theTMBData->tmbHeader()->NCFEBs() << std::endl;
465 }
void setEventInformation(const CSCDMBHeader &dmbHeader)
fills fields like bxn and l1a
Definition: CSCTMBHeader.h:32
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
void addNCLCT()
Definition: CSCDMBHeader.h:24
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:64
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:39
CSCCLCTData * CSCEventData::clctData ( ) const

user must check if nclct > 0

Definition at line 399 of file CSCEventData.cc.

References CSCTMBData::clctData(), Exception, nclct(), and tmbData().

Referenced by dmbHeader(), and cscdqm::EventProcessor::processCSC().

399  {
400  if ((nclct() == 0) || (tmbData() == nullptr))
401  throw cms::Exception("No CLCT data for this chamber");
402  return tmbData()->clctData();
403 }
CSCCLCTData * clctData()
Definition: CSCTMBData.h:40
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:72
CSCTMBData * tmbData() const
user must check in nclct > 0
void CSCEventData::copy ( const CSCEventData data)
private

Definition at line 282 of file CSCEventData.cc.

References init(), MAX_CFEB, size_, theALCTHeader, theALCTTrailer, theAnodeData, theCFEBData, theChamberType, theDMBHeader, theDMBTrailer, theFormatVersion, and theTMBData.

Referenced by CSCEventData(), and operator=().

282  {
283  init();
285  theDMBHeader = data.theDMBHeader;
287  if (data.theALCTHeader != nullptr)
289  if (data.theAnodeData != nullptr)
290  theAnodeData = new CSCAnodeData(*(data.theAnodeData));
291  if (data.theALCTTrailer != nullptr)
293  if (data.theTMBData != nullptr)
294  theTMBData = new CSCTMBData(*(data.theTMBData));
295  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb) {
296  theCFEBData[icfeb] = nullptr;
297  if (data.theCFEBData[icfeb] != nullptr)
298  theCFEBData[icfeb] = new CSCCFEBData(*(data.theCFEBData[icfeb]));
299  }
300  size_ = data.size_;
302 }
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:162
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
void CSCEventData::destroy ( )
private

Definition at line 304 of file CSCEventData.cc.

References alctZSErecovered, MAX_CFEB, theALCTHeader, theALCTTrailer, theAnodeData, theCFEBData, theTMBData, and zseEnable.

Referenced by operator=(), and ~CSCEventData().

304  {
305  if (zseEnable) {
306  delete[] alctZSErecovered;
307  }
308  delete theALCTHeader;
309  delete theAnodeData;
310  delete theALCTTrailer;
311  delete theTMBData;
312  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb) {
313  delete theCFEBData[icfeb];
314  }
315  /*
316  std::cout << "Before delete alctZSErecovered " << std::endl;
317  delete [] alctZSErecovered;
318  std::cout << "After delete alctZSErecovered " << std::endl;
319  */
320 }
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:170
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
const CSCDMBHeader* CSCEventData::dmbHeader ( ) const
inline

the DAQ motherboard header. A good place for event and chamber info

Definition at line 75 of file CSCEventData.h.

References theDMBHeader.

Referenced by CSCDDUEventData::add(), CSCDigiToRaw::findEventData(), and cscdqm::EventProcessor::processCSC().

75 { return &theDMBHeader; }
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
CSCDMBHeader* CSCEventData::dmbHeader ( )
inline

Definition at line 76 of file CSCEventData.h.

References alctData(), alctHeader(), alctTrailer(), clctData(), theDMBHeader, tmbData(), and tmbHeader().

76 { return &theDMBHeader; }
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
const CSCDMBTrailer* CSCEventData::dmbTrailer ( ) const
inline

DMB trailer.

Definition at line 97 of file CSCEventData.h.

References add(), addALCTStructures(), pack(), setEventInformation(), and theDMBTrailer.

Referenced by pack(), and cscdqm::EventProcessor::processCSC().

97 { return &theDMBTrailer; }
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:162
uint16_t CSCEventData::getFormatVersion ( ) const
inline

Definition at line 121 of file CSCEventData.h.

References calcALCTcrc(), debug, and theFormatVersion.

Referenced by cscdqm::EventProcessor::processCSC().

121 { return theFormatVersion; }
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
void CSCEventData::init ( void  )
private

helpers for ctors, dtor, and op= zeroes all pointers

Definition at line 269 of file CSCEventData.cc.

References alctZSErecovered, MAX_CFEB, theALCTHeader, theALCTTrailer, theAnodeData, theCFEBData, theTMBData, and zseEnable.

Referenced by copy(), and unpack_data().

269  {
270  //dataPresent = 0;
271  theALCTHeader = nullptr;
272  theAnodeData = nullptr;
273  theALCTTrailer = nullptr;
274  theTMBData = nullptr;
275  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb) {
276  theCFEBData[icfeb] = nullptr;
277  }
278  alctZSErecovered = nullptr;
279  zseEnable = 0;
280 }
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:170
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
bool CSCEventData::isALCT ( const uint16_t *  buf)

if dealing with ALCT data

Definition at line 251 of file CSCEventData.cc.

Referenced by setDebug(), and unpack_data().

251  {
252  return (((buf[0] & 0xFFFF) == 0xDB0A) || (((buf[0] & 0xF800) == 0x6000) && ((buf[1] & 0xF800) == 0)));
253 }
bool CSCEventData::isTMB ( const uint16_t *  buf)

if dealing with TMB data

Definition at line 255 of file CSCEventData.cc.

Referenced by setDebug(), and unpack_data().

255 { return ((buf[0] & 0xFFF) == 0xB0C); }
int CSCEventData::nalct ( ) const
inline

the flag for existence of ALCT data

Definition at line 69 of file CSCEventData.h.

References CSCDMBHeader::nalct(), and theDMBHeader.

Referenced by alctData(), alctHeader(), alctTrailer(), cscdqm::EventProcessor::processCSC(), and unpack_data().

69 { return theDMBHeader.nalct(); }
unsigned nalct() const
Definition: CSCDMBHeader.h:42
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
int CSCEventData::nclct ( ) const
inline

the number of CLCTs

Definition at line 72 of file CSCEventData.h.

References CSCDMBHeader::nclct(), and theDMBHeader.

Referenced by clctData(), cscdqm::EventProcessor::processCSC(), tmbData(), tmbHeader(), and unpack_data().

72 { return theDMBHeader.nclct(); }
unsigned nclct() const
Definition: CSCDMBHeader.h:43
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
CSCEventData CSCEventData::operator= ( const CSCEventData data)

Definition at line 261 of file CSCEventData.cc.

References copy(), and destroy().

Referenced by CSCEventData().

261  {
262  // check for self-assignment before destructing
263  if (&data != this)
264  destroy();
265  copy(data);
266  return *this;
267 }
void copy(const CSCEventData &)
boost::dynamic_bitset CSCEventData::pack ( )

returns the packed event data.

Definition at line 526 of file CSCEventData.cc.

References alctHeader(), alctTrailer(), bitset_utilities::append(), calcALCTcrc(), cfebData(), CSCAnodeData::data(), CSCDMBHeader::data(), CSCDMBTrailer::data(), CSCALCTTrailer::data(), data, CSCALCTHeader::data(), dmbTrailer(), MAX_CFEB, CSCTMBData::pack(), CSCALCTHeader::pack(), mps_fire::result, CSCALCTTrailer::setCRC(), CSCAnodeData::sizeInWords(), CSCDMBHeader::sizeInWords(), CSCDMBTrailer::sizeInWords(), CSCALCTTrailer::sizeInWords(), CSCALCTHeader::sizeInWords(), theALCTHeader, theALCTTrailer, theAnodeData, theCFEBData, theDMBHeader, theDMBTrailer, theTMBData, and bitset_utilities::ushortToBitset().

Referenced by dmbTrailer().

526  {
527  boost::dynamic_bitset<> result =
529 
530  // Container for CRC calculations
531  std::vector<std::pair<unsigned int, unsigned short*> > crcvec;
532 
533  if (theALCTHeader != nullptr) {
534  boost::dynamic_bitset<> alctHeader = theALCTHeader->pack();
535  result = bitset_utilities::append(result, alctHeader);
536  crcvec.push_back(std::make_pair(theALCTHeader->sizeInWords(), theALCTHeader->data()));
537  }
538  if (theAnodeData != nullptr) {
539  boost::dynamic_bitset<> anodeData =
541  result = bitset_utilities::append(result, anodeData);
542  crcvec.push_back(std::make_pair(theAnodeData->sizeInWords(), theAnodeData->data()));
543  }
544  if (theALCTTrailer != nullptr) {
545  unsigned int crc = calcALCTcrc(crcvec);
546  theALCTTrailer->setCRC(crc);
547  boost::dynamic_bitset<> alctTrailer =
549  result = bitset_utilities::append(result, alctTrailer);
550  }
551  if (theTMBData != nullptr) {
552  result = bitset_utilities::append(result, theTMBData->pack());
553  }
554 
555  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb) {
556  if (theCFEBData[icfeb] != nullptr) {
557  boost::dynamic_bitset<> cfebData =
558  bitset_utilities::ushortToBitset(theCFEBData[icfeb]->sizeInWords() * 16, theCFEBData[icfeb]->data());
559  result = bitset_utilities::append(result, cfebData);
560  }
561  }
562 
563  boost::dynamic_bitset<> dmbTrailer =
565  result = bitset_utilities::append(result, dmbTrailer);
566  return result;
567 }
unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData.h:19
unsigned int calcALCTcrc(std::vector< std::pair< unsigned int, unsigned short * > > &vec)
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
boost::dynamic_bitset pack()
not const because it sets size int TMBTrailer
Definition: CSCTMBData.cc:394
const CSCDMBTrailer * dmbTrailer() const
DMB trailer.
Definition: CSCEventData.h:97
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
unsigned sizeInWords() const
Definition: CSCDMBTrailer.h:61
CSCALCTHeader * alctHeader() const
user must check if nalct > 0
static int sizeInWords()
in 16-bit frames
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
unsigned short * data()
Definition: CSCDMBTrailer.h:58
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTTrailer * alctTrailer() const
user must check if nalct > 0
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
unsigned sizeInWords() const
Definition: CSCDMBHeader.h:48
boost::dynamic_bitset pack()
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:162
unsigned short * data()
int sizeInWords()
in 16-bit words
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
unsigned short * data()
Definition: CSCDMBHeader.h:53
const CSCCFEBData * cfebData(unsigned icfeb) const
unpacked in long mode: has overflow and error bits decoded
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
boost::dynamic_bitset ushortToBitset(const unsigned int numberOfBits, unsigned short *buf)
this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj...
unsigned short * data()
Definition: CSCAnodeData.h:17
void setCRC(unsigned int crc)
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
unsigned short int * data()
void CSCEventData::selfTest ( )
static

Definition at line 593 of file CSCEventData.cc.

References add(), CSCTMBHeader::CLCTDigis(), CSCTMBHeader::CorrelatedLCTDigis(), cscPackAndUnpack(), cscPackerCompare(), CSCDetId::layer(), goodZToMuMu_cfi::overlap, EcalCondDBWriter_cfi::pedestal, DetId::rawId(), stripDigis(), and tmbHeader().

593  {
594  CSCEventData chamberData(5);
595  CSCDetId detId(1, 3, 2, 1, 3);
596  std::vector<CSCCLCTDigi> clctDigis;
597  // Both CLCTs are read-out at the same (pre-trigger) bx, so the last-but-one
598  // arguments in both digis must be the same.
599  clctDigis.push_back(CSCCLCTDigi(1, 1, 4, 1, 0, 30, 3, 2, 1)); // valid for 2007
600  clctDigis.push_back(CSCCLCTDigi(1, 1, 2, 1, 1, 31, 1, 2, 2));
601 
602  // BX of LCT (8th argument) is 1-bit word (the least-significant bit
603  // of ALCT's bx).
604  std::vector<CSCCorrelatedLCTDigi> corrDigis;
605  corrDigis.push_back(CSCCorrelatedLCTDigi(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0));
606  corrDigis.push_back(CSCCorrelatedLCTDigi(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0));
607 
608  chamberData.add(clctDigis);
609  chamberData.add(corrDigis);
610 
611  CSCWireDigi wireDigi(10, 6);
612  CSCComparatorDigi comparatorDigi(30, 1, 6);
613  chamberData.add(wireDigi, 3);
614  chamberData.add(comparatorDigi, 3);
615 
616  CSCEventData newData = cscPackAndUnpack(chamberData);
617 
618  std::vector<CSCCLCTDigi> clcts = newData.tmbHeader()->CLCTDigis(detId.rawId());
619  assert(cscPackerCompare(clcts[0], clctDigis[0]));
620  assert(cscPackerCompare(clcts[1], clctDigis[1]));
621 
622  std::vector<CSCCorrelatedLCTDigi> lcts = newData.tmbHeader()->CorrelatedLCTDigis(detId.rawId());
623  assert(cscPackerCompare(lcts[0], corrDigis[0]));
624  assert(cscPackerCompare(lcts[1], corrDigis[1]));
625 
626  // test strip digis
627  CSCDetId me1adet1(1, 1, 1, 4, 1);
628  CSCDetId me1bdet1(1, 1, 4, 4, 6);
629  CSCDetId me1adet2(2, 1, 1, 4, 2);
630  CSCDetId me1bdet2(2, 1, 4, 4, 5);
631 
632  std::vector<int> sca(16, 600);
633  std::vector<unsigned short> overflow(16, 0), overlap(16, 0), errorfl(16, 0);
634  CSCStripDigi me1a(5, sca, overflow, overlap, errorfl);
635  CSCStripDigi me1b(8, sca, overflow, overlap, errorfl);
636 
637  CSCEventData forward(1);
638  CSCEventData backward(1);
639 
640  forward.add(me1a, me1adet1.layer());
641  forward.add(me1b, me1bdet1.layer());
642  backward.add(me1a, me1adet2.layer());
643  backward.add(me1b, me1adet2.layer());
644  std::vector<CSCStripDigi> me1afs = forward.stripDigis(me1adet1);
645  std::vector<CSCStripDigi> me1bfs = forward.stripDigis(me1bdet1);
646  std::vector<CSCStripDigi> me1abs = backward.stripDigis(me1adet2);
647  std::vector<CSCStripDigi> me1bbs = backward.stripDigis(me1bdet2);
648  //FIXME The current code works under the assumption that ME11 and ME1A
649  // go into separate EventData. They need to be combined.
650  assert(me1afs.size() == 16);
651  assert(me1bfs.size() == 16);
652  assert(me1abs.size() == 16);
653  assert(me1bbs.size() == 16);
654 
655  assert(me1afs[4].getStrip() == 5);
656  assert(me1bfs[7].getStrip() == 8);
657  assert(me1abs[4].getStrip() == 5);
658  assert(me1bbs[7].getStrip() == 8);
659  assert(me1afs[4].pedestal() == 600);
660  assert(me1bfs[7].pedestal() == 600);
661  assert(me1abs[4].pedestal() == 600);
662  assert(me1bbs[7].pedestal() == 600);
663 }
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const
returns CorrelatedLCT digis
Definition: CSCTMBHeader.h:70
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer)
returns CLCT digis
Definition: CSCTMBHeader.h:67
bool cscPackerCompare(const T &t1, const T &t2)
CSCTMBHeader * tmbHeader() const
user must check if nclct > 0
T cscPackAndUnpack(T &t)
static void CSCEventData::setDebug ( const bool  value)
inlinestatic

turns on/off debug flag for this class

Definition at line 44 of file CSCEventData.h.

References cfebData(), debug, isALCT(), isTMB(), stripDigis(), relativeConstraints::value, and wireDigis().

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

44 { debug = value; }
static std::atomic< bool > debug
Definition: CSCEventData.h:128
void CSCEventData::setEventInformation ( int  bxnum,
int  lvl1num 
)

this will fill the DMB header, and change all related fields in the DMBTrailer, ALCTHeader, and TMBHeader

Definition at line 405 of file CSCEventData.cc.

References CSCDMBHeader::setBXN(), CSCTMBHeader::setEventInformation(), CSCALCTHeader::setEventInformation(), CSCDMBHeader::setL1A(), CSCCFEBData::setL1A(), CSCDMBHeader::setL1A24(), CSCTMBHeader::setNCFEBs(), theALCTHeader, theCFEBData, theChamberType, theDMBHeader, theFormatVersion, theTMBData, and CSCTMBData::tmbHeader().

Referenced by CSCDDUEventData::add(), and dmbTrailer().

405  {
406  theDMBHeader.setBXN(bxnum);
407  theDMBHeader.setL1A(lvl1num);
408  theDMBHeader.setL1A24(lvl1num);
409  if (theALCTHeader) {
411  }
412  if (theTMBData) {
414 
415  assert(theChamberType > 0);
416 
418 
419  // Set number of CFEBs to 7 for Post-LS1 ME11
420  if ((theFormatVersion == 2013) && ((theChamberType == 1) || (theChamberType == 2))) {
422  }
423  /*
424  // Set number of CFEBs to 4 for ME13 chambers
425  if (theChamberType == 4) {
426  theTMBData->tmbHeader()->setNCFEBs(4);
427  }
428 */
429  }
430  for (unsigned cfeb = 0; cfeb < 7; cfeb++) {
431  if (theCFEBData[cfeb])
432  theCFEBData[cfeb]->setL1A(lvl1num);
433  }
434 }
void setEventInformation(const CSCDMBHeader &dmbHeader)
fills fields like bxn and l1a
Definition: CSCTMBHeader.h:32
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
void setL1A(unsigned l1a)
Definition: CSCCFEBData.cc:159
void setL1A(int l1a)
Definition: CSCDMBHeader.h:28
void setEventInformation(const CSCDMBHeader &)
void setBXN(int bxn)
Definition: CSCDMBHeader.h:27
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:64
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
void setL1A24(int l1a)
Definition: CSCDMBHeader.h:29
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:39
unsigned short CSCEventData::size ( void  ) const
inline

size of the data buffer used, in bytes

Definition at line 41 of file CSCEventData.h.

References size_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and checkALCTClasses().

41 { return size_; }
std::vector< CSCStripDigi > CSCEventData::stripDigis ( const CSCDetId idlayer) const

returns all the strip digis in the chamber, with the comparator information.

Definition at line 322 of file CSCEventData.cc.

References MAX_CFEB, mps_fire::result, and stripDigis().

Referenced by operator<<(), and selfTest().

322  {
323  std::vector<CSCStripDigi> result;
324  for (unsigned icfeb = 0; icfeb < MAX_CFEB; ++icfeb) {
325  std::vector<CSCStripDigi> newDigis = stripDigis(idlayer, icfeb);
326  result.insert(result.end(), newDigis.begin(), newDigis.end());
327  }
328  return result;
329 }
std::vector< std::vector< CSCStripDigi > > stripDigis() const
deprecated. Use the above methods instead
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
std::vector< CSCStripDigi > CSCEventData::stripDigis ( unsigned  idlayer,
unsigned  icfeb 
) const

returns all the strip digis in the chamber's cfeb

Definition at line 331 of file CSCEventData.cc.

References CSCCFEBData::digis(), mps_fire::result, and theCFEBData.

331  {
332  // assert(ilayer > 0 && ilayer <= 6); // off because now idlayer is raw cscdetid
333  std::vector<CSCStripDigi> result;
334  if (theCFEBData[icfeb] != nullptr) {
335  std::vector<CSCStripDigi> newDigis = theCFEBData[icfeb]->digis(idlayer);
336  result.insert(result.end(), newDigis.begin(), newDigis.end());
337  }
338 
339  return result;
340 }
void digis(uint32_t idlayer, std::vector< CSCStripDigi > &result) const
faster way to get to digis
Definition: CSCCFEBData.cc:202
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
std::vector< std::vector< CSCStripDigi > > CSCEventData::stripDigis ( ) const

deprecated. Use the above methods instead

Definition at line 350 of file CSCEventData.cc.

References mps_fire::result.

Referenced by operator<<(), setDebug(), and stripDigis().

350  {
351  std::vector<std::vector<CSCStripDigi> > result;
352  for (int layer = 1; layer <= 6; ++layer) {
353  std::vector<CSCStripDigi> digis = stripDigis(layer);
354  result.push_back(digis);
355  }
356  return result;
357 }
std::vector< std::vector< CSCStripDigi > > stripDigis() const
deprecated. Use the above methods instead
CSCTMBData * CSCEventData::tmbData ( ) const

user must check in nclct > 0

Definition at line 387 of file CSCEventData.cc.

References Exception, nclct(), and theTMBData.

Referenced by clctData(), dmbHeader(), cscdqm::EventProcessor::processCSC(), and tmbHeader().

387  {
388  if (nclct() == 0)
389  throw cms::Exception("No CLCT for this chamber");
390  return theTMBData;
391 }
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:72
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCTMBHeader * CSCEventData::tmbHeader ( ) const

user must check if nclct > 0

Definition at line 393 of file CSCEventData.cc.

References Exception, nclct(), tmbData(), and CSCTMBData::tmbHeader().

Referenced by dmbHeader(), and selfTest().

393  {
394  if ((nclct() == 0) || (tmbData() == nullptr))
395  throw cms::Exception("No CLCT header for this chamber");
396  return tmbData()->tmbHeader();
397 }
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:72
CSCTMBData * tmbData() const
user must check in nclct > 0
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:39
void CSCEventData::unpack_data ( const uint16_t *  buf)
private

The size of the ALCT payload is determined here

Check if Zero Suppression ALCT Enabled

Aauxilary variables neede to recover zero suppression Calculate the number of wire groups per layer

Calculate the number of words in the layer

unsigned short * posZSEtmpALCT = pos; This is just to dump the actual ALCT payload ** begin ** For debuggin purposes

to_rm (8 lines)

This is just to dump the actual ALCT payload ** end **

Actual word counting and recovering the original ALCT payload

Convert the recovered vector into the array

This is to check the content of the recovered ALCT payload to_rm (7 lines)

Definition at line 38 of file CSCEventData.cc.

References CSCALCTHeader::ALCTDigis(), alctZSErecovered, CSCDMBTrailer::cfeb_endtimeout(), CSCDMBTrailer::cfeb_starttimeout(), CSCDMBHeader::cfebAvailable(), CSCDMBHeader::check(), CSCALCTHeader::check(), CSCALCTHeader::data(), debug, CSCDMBHeader::format_version(), mps_fire::i, init(), createfilelist::int, isALCT(), isTMB(), dqmiolumiharvest::j, cmsLHEtoEOSManager::l, LogTrace, MAX_CFEB, nalct(), nclct(), CSCTMBData::size(), size_, CSCAnodeData::sizeInWords(), CSCCFEBData::sizeInWords(), CSCDMBHeader::sizeInWords(), CSCDMBTrailer::sizeInWords(), CSCALCTTrailer::sizeInWords(), CSCALCTHeader::sizeInWords(), theALCTHeader, theALCTTrailer, theAnodeData, theCFEBData, theDMBHeader, theDMBTrailer, theFormatVersion, theTMBData, and zseEnable.

Referenced by CSCEventData().

38  {
39  // zero everything
40  init();
41  const uint16_t* pos = buf;
42  if (debug) {
43  LogTrace("CSCEventData|CSCRawToDigi") << "The event data ";
44  for (int i = 0; i < 16; ++i) {
45  LogTrace("CSCEventData|CSCRawToDigi") << std::hex << pos[i] << " ";
46  }
47  }
48 
50  if (!(theDMBHeader.check())) {
51  LogTrace("CSCEventData|CSCRawToDigi") << "Bad DMB Header??? "
52  << " first four words: ";
53  for (int i = 0; i < 4; ++i) {
54  LogTrace("CSCEventData|CSCRawToDigi") << std::hex << pos[i] << " ";
55  }
56  }
57 
58  if (debug) {
59  LogTrace("CSCEventData|CSCRawToDigi") << "nalct = " << nalct();
60  LogTrace("CSCEventData|CSCRawToDigi") << "nclct = " << nclct();
61  }
62 
63  if (debug) {
64  LogTrace("CSCEventData|CSCRawToDigi") << "size in words of DMBHeader" << theDMBHeader.sizeInWords();
65  LogTrace("CSCEventData|CSCRawToDigi") << "sizeof(DMBHeader)" << sizeof(theDMBHeader);
66  }
67 
68  pos += theDMBHeader.sizeInWords();
69 
70  if (nalct() == 1) {
71  if (isALCT(pos)) //checking for ALCTData
72  {
73  theALCTHeader = new CSCALCTHeader(pos);
74  if (!theALCTHeader->check()) {
75  LogTrace("CSCEventData|CSCRawToDigi") << "+++WARNING: Corrupt ALCT data - won't attempt to decode";
76  } else {
77  //dataPresent|=0x40;
78  pos += theALCTHeader->sizeInWords(); //size of the header
79  //fill ALCT Digis
81 
82  //theAnodeData = new CSCAnodeData(*theALCTHeader, pos);
83 
85  /*
86  std::cout << " ****The ALCT information from CSCEventData.cc (begin)**** " << std::endl; ///to_rm
87  std::cout << " alctHeader2007().size: " << theALCTHeader->alctHeader2007().sizeInWords() << std::endl; ///to_rm
88  std::cout << " ALCT Header Content: " << std::endl; ///to_rm
90  for(int k=0; k<theALCTHeader->sizeInWords(); k+=4){
91  std::cout << std::hex << theALCTHeader->data()[k+3]
92  << " " << theALCTHeader->data()[k+2]
93  << " " << theALCTHeader->data()[k+1]
94  << " " << theALCTHeader->data()[k] << std::dec << std::endl;
95  }
96  */
97  //std::cout << " ALCT Size: " << theAnodeData->sizeInWords() << std::endl;
99  // int zseEnable = 0;
100  zseEnable = (theALCTHeader->data()[5] & 0x1000) >> 12;
101  //std::cout << " ZSE Bit: " << zseEnable << std::endl; /// to_rm
102  int sizeInWord_ZSE = 0;
103 
104  //alctZSErecovered = new unsigned short [theAnodeData->sizeInWords()];
105 
106  if (zseEnable) {
109  int nWGs_per_layer = ((theALCTHeader->data()[6] & 0x0007) + 1) * 16;
111  int nWG_round_up = int(nWGs_per_layer / 12) + (nWGs_per_layer % 3 ? 1 : 0);
112  //std::cout << " Words per layer: " << nWG_round_up << std::endl; ///to_rm
113  const uint16_t* posZSE = pos;
114  std::vector<unsigned short> alctZSErecoveredVector;
115  alctZSErecoveredVector.clear();
116 
117  //alctZSErecovered = new unsigned short [theAnodeData->sizeInWords()];
118  //delete [] alctZSErecovered;
119  //std::cout << " ALCT Buffer with ZSE: " << std::endl; ///to_rm
123  //unsigned short * posZSEdebug = pos; ///to_rm
124 
126  /*
127  while (*posZSEdebug != 0xDE0D){
128  unsigned short d = *posZSEdebug;
129  unsigned short c = *(posZSEdebug+1);
130  unsigned short b = *(posZSEdebug+2);
131  unsigned short a = *(posZSEdebug+3);
132  posZSEdebug+=4;
133  std::cout << std::hex << a << " " << b << " " << c << " " << d << std::dec << std::endl;
134  }
135  */
137 
139  int alctZSErecoveredPos = 0;
140  while (*posZSE != 0xDE0D) {
141  if ((*posZSE == 0x1000) && (*posZSE != 0x3000)) {
142  for (int j = 0; j < nWG_round_up; j++) {
143  alctZSErecoveredVector.push_back(0x0000);
144  }
145  alctZSErecoveredPos += nWG_round_up;
146  } else {
147  alctZSErecoveredVector.push_back(*posZSE);
148  ++alctZSErecoveredPos;
149  }
150  posZSE++;
151  sizeInWord_ZSE++;
152  }
153 
154  alctZSErecovered = new unsigned short[alctZSErecoveredVector.size()];
155 
157  for (int l = 0; l < (int)alctZSErecoveredVector.size(); l++) {
158  alctZSErecovered[l] = alctZSErecoveredVector[l];
159  }
160 
161  unsigned short* posRecovered = alctZSErecovered;
162  theAnodeData = new CSCAnodeData(*theALCTHeader, posRecovered);
163 
166  /*
167  std::cout << " The ALCT payload recovered: " << std::endl;
168  for(int k=0; k<theAnodeData->sizeInWords(); k+=4){
169  std::cout << std::hex << alctZSErecovered[k+3] << " "
170  << alctZSErecovered[k+2] << " "
171  << alctZSErecovered[k+1] << " "
172  << alctZSErecovered[k] << std::dec << std::endl;
173  }
174  */
175  //delete [] alctZSErecovered;
176  //std::cout << " ALCT SizeZSE : " << sizeInWord_ZSE << std::endl; ///to_rm
177  //std::cout << " ALCT SizeZSE Recovered: " << alctZSErecoveredPos << std::endl; ///to_rm
178  //std::cout << " ALCT Size Expected: " << theAnodeData->sizeInWords() << std::endl; ///to_rm
179  pos += sizeInWord_ZSE;
180  } else {
181  //pos +=sizeInWord_ZSE;
183  pos += theAnodeData->sizeInWords(); // size of the data is determined during unpacking
184  }
185  //std::cout << " ****The ALCT information from CSCEventData.cc (end)**** " << std::endl; ///to_rm
186  theALCTTrailer = new CSCALCTTrailer(pos);
187  pos += theALCTTrailer->sizeInWords();
188  }
189  } else {
190  LogTrace("CSCEventData|CSCRawToDigi") << "Error:nalct reported but no ALCT data found!!!";
191  }
192  }
193 
194  if (nclct() == 1) {
195  if (isTMB(pos)) {
196  //dataPresent|=0x20;
197  theTMBData = new CSCTMBData(pos); //fill all TMB data
198  pos += theTMBData->size();
199  } else {
200  LogTrace("CSCEventData|CSCRawToDigi") << "Error:nclct reported but no TMB data found!!!";
201  }
202  }
203 
204  //now let's try to find and unpack the DMBTrailer
205  bool dmbTrailerReached = false;
206  for (int i = 0; i < 12000; ++i) //8000 max for cfeb + 1980ALCT + 287 TMB
207  {
208  dmbTrailerReached = (*(i + pos) & 0xF000) == 0xF000 && (*(i + pos + 1) & 0xF000) == 0xF000 &&
209  (*(i + pos + 2) & 0xF000) == 0xF000 && (*(i + pos + 3) & 0xF000) == 0xF000 &&
210  (*(i + pos + 4) & 0xF000) == 0xE000 && (*(i + pos + 5) & 0xF000) == 0xE000 &&
211  (*(i + pos + 6) & 0xF000) == 0xE000 && (*(i + pos + 7) & 0xF000) == 0xE000;
212  if (dmbTrailerReached) {
213  // theDMBTrailer = *( (CSCDMBTrailer *) (pos+i) );
215  break;
216  }
217  }
218  if (dmbTrailerReached) {
219  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb) {
220  theCFEBData[icfeb] = nullptr;
221  int cfeb_available = theDMBHeader.cfebAvailable(icfeb);
222  unsigned int cfebTimeout = theDMBTrailer.cfeb_starttimeout() | theDMBTrailer.cfeb_endtimeout();
223  //cfeb_available cannot be trusted - need additional verification!
224  if (cfeb_available == 1) {
225  if ((cfebTimeout >> icfeb) & 1) {
226  if (debug)
227  LogTrace("CSCEventData|CSCRawToDigi") << "CFEB Timed out! ";
228  } else {
229  //dataPresent|=(0x1>>icfeb);
230  // Fill CFEB data and convert it into cathode digis
231 
232  // Check if we have here DCFEB using DMB format version field (new ME11 with DCFEBs - 0x2, other chamber types 0x1)
233  bool isDCFEB = false;
234  if (theDMBHeader.format_version() == 2)
235  isDCFEB = true;
236 
237  theCFEBData[icfeb] = new CSCCFEBData(icfeb, pos, theFormatVersion, isDCFEB);
238  pos += theCFEBData[icfeb]->sizeInWords();
239  }
240  }
241  }
242  pos += theDMBTrailer.sizeInWords();
243  size_ = pos - buf;
244  } else {
245  LogTrace("CSCEventData|CSCRawToDigi") << "Critical Error: DMB Trailer was not found!!! ";
246  }
247 
248  // std::cout << "CSC format: " << theFormatVersion << " " << getFormatVersion() << std::endl;
249 }
bool check() const
Definition: CSCDMBHeader.h:51
unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData.h:19
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:170
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:72
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:174
#define MAX_CFEB
Maximum available CFEBs per chamber (for old system 5, for new ME11 should be 7)
Definition: CSCEventData.h:26
unsigned cfeb_endtimeout() const
Definition: CSCDMBTrailer.h:33
const unsigned short size() const
Definition: CSCTMBData.h:37
unsigned sizeInWords() const
Definition: CSCDMBTrailer.h:61
bool check() const
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:69
static int sizeInWords()
in 16-bit frames
bool isALCT(const uint16_t *buf)
if dealing with ALCT data
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:149
CSCTMBData * theTMBData
Definition: CSCEventData.h:157
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:154
unsigned cfeb_starttimeout() const
Definition: CSCDMBTrailer.h:37
unsigned sizeInWords() const
Definition: CSCDMBHeader.h:48
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:162
#define LogTrace(id)
int sizeInWords()
in 16-bit words
std::vector< CSCALCTDigi > ALCTDigis() const
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:160
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:156
unsigned format_version() const
Definition: CSCDMBHeader.h:49
bool isTMB(const uint16_t *buf)
if dealing with TMB data
unsigned sizeInWords() const
Definition: CSCCFEBData.h:46
static std::atomic< bool > debug
Definition: CSCEventData.h:128
bool cfebAvailable(unsigned icfeb)
Definition: CSCDMBHeader.h:21
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
unsigned short int * data()
std::vector< CSCWireDigi > CSCEventData::wireDigis ( unsigned  ilayer) const

Definition at line 342 of file CSCEventData.cc.

References theAnodeData, and CSCAnodeData::wireDigis().

Referenced by operator<<().

342  {
343  if (theAnodeData == nullptr) {
344  return std::vector<CSCWireDigi>();
345  } else {
346  return theAnodeData->wireDigis(ilayer);
347  }
348 }
std::vector< CSCWireDigi > wireDigis(int layer) const
input layer is from 1 to 6
Definition: CSCAnodeData.h:22
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:155
std::vector< std::vector< CSCWireDigi > > CSCEventData::wireDigis ( ) const

deprecated. Use the above method instead.

Definition at line 359 of file CSCEventData.cc.

References mps_fire::result.

Referenced by operator<<(), and setDebug().

359  {
360  std::vector<std::vector<CSCWireDigi> > result;
361  for (int layer = 1; layer <= 6; ++layer) {
362  result.push_back(wireDigis(layer));
363  }
364  return result;
365 }
std::vector< std::vector< CSCWireDigi > > wireDigis() const
deprecated. Use the above method instead.

Member Data Documentation

unsigned short* CSCEventData::alctZSErecovered
private

Auxiliary bufer to recove the ALCT raw payload from zero suppression.

Definition at line 170 of file CSCEventData.h.

Referenced by destroy(), init(), and unpack_data().

std::atomic< bool > CSCEventData::debug {false}
static
int CSCEventData::size_
private

Definition at line 164 of file CSCEventData.h.

Referenced by copy(), size(), and unpack_data().

CSCALCTHeader* CSCEventData::theALCTHeader
private

these may or may not be present. I decided to make them dynamic because most CSC chambers don't have LCTs, therefore don't have data, except for DMB headers and trailers.

Definition at line 154 of file CSCEventData.h.

Referenced by add(), alctHeader(), checkALCTClasses(), copy(), destroy(), init(), pack(), setEventInformation(), and unpack_data().

CSCALCTTrailer* CSCEventData::theALCTTrailer
private

Definition at line 156 of file CSCEventData.h.

Referenced by alctTrailer(), checkALCTClasses(), copy(), destroy(), init(), pack(), and unpack_data().

CSCAnodeData* CSCEventData::theAnodeData
private
CSCCFEBData* CSCEventData::theCFEBData[7]
private

for up to MAX_CFEB CFEB boards

Definition at line 160 of file CSCEventData.h.

Referenced by add(), cfebData(), copy(), CSCEventData(), destroy(), init(), pack(), setEventInformation(), stripDigis(), and unpack_data().

int CSCEventData::theChamberType
private

this won't be filled when real data is read it. It's only used when packing simulated data, so we know how many wire and strip channels to make.

Definition at line 167 of file CSCEventData.h.

Referenced by chamberType(), checkALCTClasses(), checkTMBClasses(), copy(), and setEventInformation().

CSCDMBHeader CSCEventData::theDMBHeader
private
CSCDMBTrailer CSCEventData::theDMBTrailer
private

Definition at line 162 of file CSCEventData.h.

Referenced by copy(), dmbTrailer(), pack(), and unpack_data().

uint16_t CSCEventData::theFormatVersion
private

Output Format Version (2005, 2013)

Definition at line 174 of file CSCEventData.h.

Referenced by add(), checkTMBClasses(), copy(), CSCEventData(), getFormatVersion(), setEventInformation(), and unpack_data().

CSCTMBData* CSCEventData::theTMBData
private
int CSCEventData::zseEnable
private

Definition at line 171 of file CSCEventData.h.

Referenced by destroy(), init(), and unpack_data().