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 18 of file CSCEventData.cc.

References mps_fire::i, MAX_CFEB, and theCFEBData.

18  :
19  theDMBHeader(format_version),
20  theALCTHeader(nullptr),
21  theAnodeData(nullptr),
22  theALCTTrailer(nullptr),
23  theTMBData(nullptr),
24  theDMBTrailer(format_version),
26  alctZSErecovered(nullptr),
27  zseEnable(0),
28  theFormatVersion(format_version)
29 {
30 
31  for (unsigned i = 0; i < MAX_CFEB; ++i)
32  {
33  theCFEBData[i] = nullptr;
34  }
35 }
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:179
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:183
#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:158
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:171
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
int chamberType() const
might not be set in real data
Definition: CSCEventData.h:127
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
CSCEventData::CSCEventData ( const uint16_t *  buf,
uint16_t  format_version = 2005 
)

should make const input soon

Definition at line 38 of file CSCEventData.cc.

References theFormatVersion, and unpack_data().

38  : theFormatVersion(format_version)
39 {
40  theFormatVersion = format_version;
41  unpack_data(buf);
42 }
void unpack_data(const uint16_t *buf)
Definition: CSCEventData.cc:45
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:183
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 310 of file CSCEventData.cc.

References destroy().

Referenced by CSCEventData().

311 {
312  destroy();
313 }
CSCEventData::CSCEventData ( const CSCEventData data)

Definition at line 305 of file CSCEventData.cc.

References copy().

306 {
307  copy(data);
308 }
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 569 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().

570 {
571  //@@ need special logic here for ME11
572  unsigned cfeb = (digi.getStrip()-1)/16;
573  bool sixteenSamples = false;
574  if (digi.getADCCounts().size()==16) sixteenSamples = true;
575  if (theCFEBData[cfeb] == nullptr)
576  {
577  bool isDCFEB = false;
578  if (theDMBHeader.format_version() == 2) isDCFEB = true;
579  theCFEBData[cfeb] = new CSCCFEBData(cfeb, sixteenSamples, theFormatVersion, isDCFEB);
580  theDMBHeader.addCFEB(cfeb);
581  }
582  theCFEBData[cfeb]->add(digi, layer);
583 
584 
585 }
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:183
std::vector< int > const & getADCCounts() const
Get ADC readings.
Definition: CSCStripDigi.h:44
void add(const CSCStripDigi &, int layer)
Definition: CSCCFEBData.cc:85
int getStrip() const
Definition: CSCStripDigi.h:41
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
void addCFEB(int icfeb)
Definition: CSCDMBHeader.h:28
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
unsigned format_version() const
Definition: CSCDMBHeader.h:54
void CSCEventData::add ( const CSCWireDigi digi,
int  layer 
)

Definition at line 588 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().

589 {
591  theAnodeData->add(digi, layer);
594 
595 }
void checkALCTClasses()
makes new ALCT classes, if needed
void setBXNCount(unsigned int bxn)
Definition: CSCALCTHeader.h:78
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
void add(const CSCWireDigi &wireDigi, int layer)
Definition: CSCAnodeData.h:27
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:164
void CSCEventData::add ( const CSCComparatorDigi digi,
int  layer 
)

Definition at line 597 of file CSCEventData.cc.

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

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

598 {
599  checkTMBClasses();
600  theTMBData->clctData()->add(digi, layer);
601 
602 }
CSCCLCTData * clctData()
Definition: CSCTMBData.h:43
void checkTMBClasses()
makes new TMB classes, if needed
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn&#39;t do flipping yet.
Definition: CSCCLCTData.cc:222
void CSCEventData::add ( const CSCComparatorDigi digi,
const CSCDetId cid 
)

Definition at line 604 of file CSCEventData.cc.

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

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

605 {
606  checkTMBClasses();
607  theTMBData->clctData()->add(digi, cid);
608 
609 }
CSCCLCTData * clctData()
Definition: CSCTMBData.h:43
void checkTMBClasses()
makes new TMB classes, if needed
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn&#39;t do flipping yet.
Definition: CSCCLCTData.cc:222
void CSCEventData::add ( const std::vector< CSCALCTDigi > &  digis)

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

Definition at line 613 of file CSCEventData.cc.

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

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

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

Definition at line 620 of file CSCEventData.cc.

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

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

621 {
622  checkTMBClasses();
623  theTMBData->tmbHeader()->add(digis);
624 }
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:166
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:42
void CSCEventData::add ( const std::vector< CSCCorrelatedLCTDigi > &  digis)

Definition at line 626 of file CSCEventData.cc.

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

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

627 {
628  checkTMBClasses();
629  theTMBData->tmbHeader()->add(digis);
630 }
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:166
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:42
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 470 of file CSCEventData.cc.

References Exception, nalct(), and theAnodeData.

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

471 {
472  if (nalct() == 0) throw cms::Exception("No ALCT for this chamber");
473  return theAnodeData;
474 }
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:76
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
CSCALCTHeader * CSCEventData::alctHeader ( ) const

user must check if nalct > 0

Definition at line 457 of file CSCEventData.cc.

References Exception, nalct(), and theALCTHeader.

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

458 {
459  if (nalct() == 0) throw cms::Exception("No ALCT for this chamber");
460  return theALCTHeader;
461 }
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:76
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
CSCALCTTrailer * CSCEventData::alctTrailer ( ) const

user must check if nalct > 0

Definition at line 463 of file CSCEventData.cc.

References Exception, nalct(), and theALCTTrailer.

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

464 {
465  if (nalct() == 0) throw cms::Exception("No ALCT for this chamber");
466  return theALCTTrailer;
467 }
int nalct() const
the flag for existence of ALCT data
Definition: CSCEventData.h:76
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
unsigned int CSCEventData::calcALCTcrc ( std::vector< std::pair< unsigned int, unsigned short * > > &  vec)

Definition at line 700 of file CSCEventData.cc.

References mps_fire::i, gen::n, edm::second(), protons_cff::t, and w.

Referenced by getFormatVersion(), and pack().

701 {
702  int CRC=0;
703 // int size=0;
704 
705  for (unsigned int n = 0; n < vec.size(); n++)
706  {
707 // size += vec[n].first;
708  for (uint16_t j=0, w=0; j<vec[n].first; j++ )
709  {
710 
711  if (vec[n].second != nullptr) {
712  w = vec[n].second[j] & 0xffff;
713  for (uint32_t i=15, t=0, ncrc=0; i<16; i--)
714  {
715  t = ((w >> i) & 1) ^ ((CRC >> 21) & 1);
716  ncrc = (CRC << 1) & 0x3ffffc;
717  ncrc |= (t ^ (CRC & 1)) << 1;
718  ncrc |= t;
719  CRC = ncrc;
720  }
721 
722  }
723 
724  }
725  }
726 
727  // std::cout << "ALCT CRC vector size: " << size << ", crc: 0x" << std::hex << CRC<< std::endl;
728  return CRC;
729 }
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 451 of file CSCEventData.cc.

References theCFEBData.

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

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

might not be set in real data

Definition at line 127 of file CSCEventData.h.

References theChamberType.

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

makes new ALCT classes, if needed

Definition at line 532 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().

533 {
534  if (theAnodeData == nullptr)
535  {
536  assert(theChamberType>0);
542  // set data available flag
544  }
545 }
unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData.h:21
void setEventInformation(const CSCDMBHeader &)
static int sizeInWords()
in 16-bit frames
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
int sizeInWords()
in 16-bit words
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
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:31
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
void CSCEventData::checkTMBClasses ( )
private

makes new TMB classes, if needed

Definition at line 548 of file CSCEventData.cc.

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

Referenced by add().

549 {
550  int nCFEBs = 5;
551  if ((theFormatVersion == 2013) && ((theChamberType == 1) || (theChamberType == 2)) ) {
552  nCFEBs = 7;
553  }
554  if (theTMBData == nullptr)
555  {
556  if (theFormatVersion == 2013) { // Set to TMB format for Post-LS1 data
557  theTMBData = new CSCTMBData(2013, 0x7a76, nCFEBs);
558  } else {
559  theTMBData = new CSCTMBData(2007, 0x50c3);
560  }
563  }
564  theTMBData->tmbHeader()->setNCFEBs(nCFEBs);
565  // std::cout << "nCFEBs: " << theTMBData->tmbHeader()->NCFEBs() << std::endl;
566 }
void setEventInformation(const CSCDMBHeader &dmbHeader)
fills fields like bxn and l1a
Definition: CSCTMBHeader.h:33
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:183
void addNCLCT()
Definition: CSCDMBHeader.h:29
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:92
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:42
CSCCLCTData * CSCEventData::clctData ( ) const

user must check if nclct > 0

Definition at line 489 of file CSCEventData.cc.

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

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

490 {
491  if ((nclct() == 0)||(tmbData()==nullptr)) throw cms::Exception("No CLCT data for this chamber");
492  return tmbData()->clctData();
493 }
CSCCLCTData * clctData()
Definition: CSCTMBData.h:43
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:79
CSCTMBData * tmbData() const
user must check in nclct > 0
void CSCEventData::copy ( const CSCEventData data)
private

Definition at line 341 of file CSCEventData.cc.

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

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

342 {
343  init();
345  theDMBHeader = data.theDMBHeader;
347  if (data.theALCTHeader != nullptr)
349  if (data.theAnodeData != nullptr)
350  theAnodeData = new CSCAnodeData(*(data.theAnodeData));
351  if (data.theALCTTrailer != nullptr)
353  if (data.theTMBData != nullptr)
354  theTMBData = new CSCTMBData(*(data.theTMBData));
355  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb)
356  {
357  theCFEBData[icfeb] = nullptr;
358  if (data.theCFEBData[icfeb] != nullptr)
359  theCFEBData[icfeb] = new CSCCFEBData(*(data.theCFEBData[icfeb]));
360  }
361  size_ = data.size_;
363 
364 
365 }
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:183
#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:158
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:171
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
void CSCEventData::destroy ( )
private

Definition at line 368 of file CSCEventData.cc.

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

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

369 {
370  if (zseEnable)
371  {
372  delete [] alctZSErecovered;
373  }
374  delete theALCTHeader;
375  delete theAnodeData;
376  delete theALCTTrailer;
377  delete theTMBData;
378  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb)
379  {
380  delete theCFEBData[icfeb];
381  }
382  /*
383  std::cout << "Before delete alctZSErecovered " << std::endl;
384  delete [] alctZSErecovered;
385  std::cout << "After delete alctZSErecovered " << std::endl;
386  */
387 }
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:179
#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:166
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
const CSCDMBHeader* CSCEventData::dmbHeader ( ) const
inline

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

Definition at line 82 of file CSCEventData.h.

References theDMBHeader.

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

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

Definition at line 83 of file CSCEventData.h.

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

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

DMB trailer.

Definition at line 104 of file CSCEventData.h.

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

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

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

Definition at line 129 of file CSCEventData.h.

References calcALCTcrc(), debug, and theFormatVersion.

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

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

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

Definition at line 325 of file CSCEventData.cc.

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

Referenced by copy(), and unpack_data().

326 {
327  //dataPresent = 0;
328  theALCTHeader = nullptr;
329  theAnodeData = nullptr;
330  theALCTTrailer = nullptr;
331  theTMBData = nullptr;
332  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb)
333  {
334  theCFEBData[icfeb] = nullptr;
335  }
336  alctZSErecovered=nullptr;
337  zseEnable=0;
338 }
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
Definition: CSCEventData.h:179
#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:166
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
bool CSCEventData::isALCT ( const uint16_t *  buf)

if dealing with ALCT data

Definition at line 293 of file CSCEventData.cc.

Referenced by setDebug(), and unpack_data().

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

if dealing with TMB data

Definition at line 298 of file CSCEventData.cc.

Referenced by setDebug(), and unpack_data().

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

the flag for existence of ALCT data

Definition at line 76 of file CSCEventData.h.

References CSCDMBHeader::nalct(), and theDMBHeader.

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

76 {return theDMBHeader.nalct();}
unsigned nalct() const
Definition: CSCDMBHeader.h:47
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
int CSCEventData::nclct ( ) const
inline

the number of CLCTs

Definition at line 79 of file CSCEventData.h.

References CSCDMBHeader::nclct(), and theDMBHeader.

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

79 {return theDMBHeader.nclct();}
unsigned nclct() const
Definition: CSCDMBHeader.h:48
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
CSCEventData CSCEventData::operator= ( const CSCEventData data)

Definition at line 316 of file CSCEventData.cc.

References copy(), and destroy().

Referenced by CSCEventData().

317 {
318  // check for self-assignment before destructing
319  if (&data != this) destroy();
320  copy(data);
321  return *this;
322 }
void copy(const CSCEventData &)
boost::dynamic_bitset CSCEventData::pack ( )

returns the packed event data.

Definition at line 648 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(), and pyrootRender.interactiveRender::draw().

649 {
650  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset( theDMBHeader.sizeInWords()*16,
651  theDMBHeader.data());
652 
653  // Container for CRC calculations
654  std::vector<std::pair<unsigned int, unsigned short*> > crcvec;
655 
656  if (theALCTHeader != nullptr)
657  {
658  boost::dynamic_bitset<> alctHeader = theALCTHeader->pack();
659  result = bitset_utilities::append(result, alctHeader);
660  crcvec.push_back(std::make_pair(theALCTHeader->sizeInWords(), theALCTHeader->data()));
661  }
662  if (theAnodeData != nullptr)
663  {
664  boost::dynamic_bitset<> anodeData = bitset_utilities::ushortToBitset (theAnodeData->sizeInWords()*16,
665  theAnodeData->data());
666  result = bitset_utilities::append(result, anodeData);
667  crcvec.push_back(std::make_pair(theAnodeData->sizeInWords(), theAnodeData->data()));
668 
669  }
670  if (theALCTTrailer != nullptr)
671  {
672  unsigned int crc = calcALCTcrc(crcvec);
673  theALCTTrailer->setCRC(crc);
675  theALCTTrailer->data());
676  result = bitset_utilities::append(result, alctTrailer);
677 
678  }
679  if (theTMBData != nullptr)
680  {
681  result = bitset_utilities::append(result, theTMBData->pack());
682  }
683 
684  for (int icfeb = 0; icfeb < MAX_CFEB; ++icfeb)
685  {
686  if (theCFEBData[icfeb] != nullptr)
687  {
688  boost::dynamic_bitset<> cfebData = bitset_utilities::ushortToBitset(theCFEBData[icfeb]->sizeInWords()*16,
689  theCFEBData[icfeb]->data());
690  result = bitset_utilities::append(result, cfebData);
691  }
692  }
693 
695  theDMBTrailer.data());
696  result = bitset_utilities::append(result, dmbTrailer);
697  return result;
698 }
unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData.h:21
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:428
const CSCDMBTrailer * dmbTrailer() const
DMB trailer.
Definition: CSCEventData.h:104
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:64
CSCALCTHeader * alctHeader() const
user must check if nalct > 0
static int sizeInWords()
in 16-bit frames
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
unsigned short * data()
Definition: CSCDMBTrailer.h:61
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
CSCALCTTrailer * alctTrailer() const
user must check if nalct > 0
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
unsigned sizeInWords() const
Definition: CSCDMBHeader.h:53
boost::dynamic_bitset pack()
CSCDMBTrailer theDMBTrailer
Definition: CSCEventData.h:171
unsigned short * data()
int sizeInWords()
in 16-bit words
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
CSCALCTTrailer * theALCTTrailer
Definition: CSCEventData.h:165
unsigned short * data()
Definition: CSCDMBHeader.h:58
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:82
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:19
void setCRC(unsigned int crc)
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
unsigned short int * data()
void CSCEventData::selfTest ( )
static

Definition at line 733 of file CSCEventData.cc.

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

734 {
735  CSCEventData chamberData(5);
736  CSCDetId detId(1, 3, 2, 1, 3);
737  std::vector<CSCCLCTDigi> clctDigis;
738  // Both CLCTs are read-out at the same (pre-trigger) bx, so the last-but-one
739  // arguments in both digis must be the same.
740  clctDigis.push_back(CSCCLCTDigi(1, 1, 4, 1, 0, 30, 3, 2, 1)); // valid for 2007
741  clctDigis.push_back(CSCCLCTDigi(1, 1, 2, 1, 1, 31, 1, 2, 2));
742 
743  // BX of LCT (8th argument) is 1-bit word (the least-significant bit
744  // of ALCT's bx).
745  std::vector<CSCCorrelatedLCTDigi> corrDigis;
746  corrDigis.push_back(CSCCorrelatedLCTDigi(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0));
747  corrDigis.push_back(CSCCorrelatedLCTDigi(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0));
748 
749  chamberData.add(clctDigis);
750  chamberData.add(corrDigis);
751 
752  CSCWireDigi wireDigi(10, 6);
753  CSCComparatorDigi comparatorDigi(30, 1, 6);
754  chamberData.add(wireDigi, 3);
755  chamberData.add(comparatorDigi, 3);
756 
757  CSCEventData newData = cscPackAndUnpack(chamberData);
758 
759  std::vector<CSCCLCTDigi> clcts = newData.tmbHeader()->CLCTDigis(detId.rawId());
760  assert(cscPackerCompare(clcts[0],clctDigis[0]));
761  assert(cscPackerCompare(clcts[1],clctDigis[1]));
762 
763  std::vector<CSCCorrelatedLCTDigi> lcts = newData.tmbHeader()->CorrelatedLCTDigis(detId.rawId());
764  assert(cscPackerCompare(lcts[0], corrDigis[0]));
765  assert(cscPackerCompare(lcts[1], corrDigis[1]));
766 
767  // test strip digis
768  CSCDetId me1adet1(1, 1, 1, 4, 1);
769  CSCDetId me1bdet1(1, 1, 4, 4, 6);
770  CSCDetId me1adet2(2, 1, 1, 4, 2);
771  CSCDetId me1bdet2(2, 1, 4, 4, 5);
772 
773  std::vector<int> sca(16, 600);
774  std::vector<unsigned short> overflow(16, 0), overlap(16, 0), errorfl(16,0);
775  CSCStripDigi me1a(5, sca, overflow, overlap, errorfl);
776  CSCStripDigi me1b(8, sca, overflow, overlap, errorfl);
777 
778  CSCEventData forward(1);
779  CSCEventData backward(1);
780 
781  forward.add(me1a, me1adet1.layer());
782  forward.add(me1b, me1bdet1.layer());
783  backward.add(me1a, me1adet2.layer());
784  backward.add(me1b, me1adet2.layer());
785  std::vector<CSCStripDigi> me1afs = forward.stripDigis(me1adet1);
786  std::vector<CSCStripDigi> me1bfs = forward.stripDigis(me1bdet1);
787  std::vector<CSCStripDigi> me1abs = backward.stripDigis(me1adet2);
788  std::vector<CSCStripDigi> me1bbs = backward.stripDigis(me1bdet2);
789  //FIXME The current code works under the assumption that ME11 and ME1A
790  // go into separate EventData. They need to be combined.
791  assert(me1afs.size() == 16);
792  assert(me1bfs.size() == 16);
793  assert(me1abs.size() == 16);
794  assert(me1bbs.size() == 16);
795 
796  assert(me1afs[4].getStrip() == 5);
797  assert(me1bfs[7].getStrip() == 8);
798  assert(me1abs[4].getStrip() == 5);
799  assert(me1bbs[7].getStrip() == 8);
800  assert(me1afs[4].pedestal() == 600);
801  assert(me1bfs[7].pedestal() == 600);
802  assert(me1abs[4].pedestal() == 600);
803  assert(me1bbs[7].pedestal() == 600);
804 
805 
806 }
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const
returns CorrelatedLCT digis
Definition: CSCTMBHeader.h:104
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer)
returns CLCT digis
Definition: CSCTMBHeader.h:98
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:137
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 496 of file CSCEventData.cc.

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

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

497 {
498  theDMBHeader.setBXN(bxnum);
499  theDMBHeader.setL1A(lvl1num);
500  theDMBHeader.setL1A24(lvl1num);
501  if (theALCTHeader)
502  {
504  }
505  if (theTMBData)
506  {
508 
509  assert(theChamberType>0);
510 
512 
513  // Set number of CFEBs to 7 for Post-LS1 ME11
514  if ((theFormatVersion == 2013) && ((theChamberType == 1) || (theChamberType == 2)) ) {
516  }
517 /*
518  // Set number of CFEBs to 4 for ME13 chambers
519  if (theChamberType == 4) {
520  theTMBData->tmbHeader()->setNCFEBs(4);
521  }
522 */
523 
524  }
525  for (unsigned cfeb=0; cfeb< 7; cfeb++)
526  {
527  if (theCFEBData[cfeb]) theCFEBData[cfeb]->setL1A(lvl1num);
528  }
529 }
void setEventInformation(const CSCDMBHeader &dmbHeader)
fills fields like bxn and l1a
Definition: CSCTMBHeader.h:33
uint16_t theFormatVersion
Output Format Version (2005, 2013)
Definition: CSCEventData.h:183
void setL1A(unsigned l1a)
Definition: CSCCFEBData.cc:168
void setL1A(int l1a)
Definition: CSCDMBHeader.h:33
void setEventInformation(const CSCDMBHeader &)
void setBXN(int bxn)
Definition: CSCDMBHeader.h:32
CSCDMBHeader theDMBHeader
Definition: CSCEventData.h:158
void setNCFEBs(uint16_t ncfebs)
Definition: CSCTMBHeader.h:92
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
CSCALCTHeader * theALCTHeader
Definition: CSCEventData.h:163
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
void setL1A24(int l1a)
Definition: CSCDMBHeader.h:34
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:42
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 390 of file CSCEventData.cc.

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

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

391 {
392  std::vector<CSCStripDigi> result;
393  for (unsigned icfeb = 0; icfeb < MAX_CFEB; ++icfeb)
394  {
395  std::vector<CSCStripDigi> newDigis = stripDigis(idlayer, icfeb);
396  result.insert(result.end(), newDigis.begin(), newDigis.end());
397  }
398  return result;
399 }
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 402 of file CSCEventData.cc.

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

403 {
404  // assert(ilayer > 0 && ilayer <= 6); // off because now idlayer is raw cscdetid
405  std::vector<CSCStripDigi> result;
406  if (theCFEBData[icfeb] != nullptr)
407  {
408  std::vector<CSCStripDigi> newDigis = theCFEBData[icfeb]->digis(idlayer);
409  result.insert(result.end(), newDigis.begin(), newDigis.end());
410  }
411 
412  return result;
413 }
void digis(uint32_t idlayer, std::vector< CSCStripDigi > &result) const
faster way to get to digis
Definition: CSCCFEBData.cc:221
CSCCFEBData * theCFEBData[7]
for up to MAX_CFEB CFEB boards
Definition: CSCEventData.h:169
std::vector< std::vector< CSCStripDigi > > CSCEventData::stripDigis ( ) const

deprecated. Use the above methods instead

Definition at line 429 of file CSCEventData.cc.

References mps_fire::result.

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

430 {
431  std::vector < std::vector<CSCStripDigi> > result;
432  for (int layer = 1; layer <= 6; ++layer)
433  {
434  std::vector<CSCStripDigi> digis = stripDigis(layer);
435  result.push_back(digis);
436  }
437  return result;
438 }
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 476 of file CSCEventData.cc.

References Exception, nclct(), and theTMBData.

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

477 {
478  if (nclct() == 0) throw cms::Exception("No CLCT for this chamber");
479  return theTMBData;
480 }
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:79
CSCTMBData * theTMBData
Definition: CSCEventData.h:166
CSCTMBHeader * CSCEventData::tmbHeader ( ) const

user must check if nclct > 0

Definition at line 483 of file CSCEventData.cc.

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

Referenced by dmbHeader(), and selfTest().

484 {
485  if ((nclct() == 0)||(tmbData()==nullptr)) throw cms::Exception("No CLCT header for this chamber");
486  return tmbData()->tmbHeader();
487 }
int nclct() const
the number of CLCTs
Definition: CSCEventData.h:79
CSCTMBData * tmbData() const
user must check in nclct > 0
CSCTMBHeader * tmbHeader()
Definition: CSCTMBData.h:42
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 45 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(), checklumidiff::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().

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

Definition at line 416 of file CSCEventData.cc.

References theAnodeData, and CSCAnodeData::wireDigis().

Referenced by operator<<().

417 {
418  if (theAnodeData == nullptr)
419  {
420  return std::vector<CSCWireDigi>();
421  }
422  else
423  {
424  return theAnodeData->wireDigis(ilayer);
425  }
426 }
std::vector< CSCWireDigi > wireDigis(int layer) const
input layer is from 1 to 6
Definition: CSCAnodeData.h:24
CSCAnodeData * theAnodeData
Definition: CSCEventData.h:164
std::vector< std::vector< CSCWireDigi > > CSCEventData::wireDigis ( ) const

deprecated. Use the above method instead.

Definition at line 440 of file CSCEventData.cc.

References mps_fire::result.

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

441 {
442  std::vector < std::vector<CSCWireDigi> > result;
443  for (int layer = 1; layer <= 6; ++layer)
444  {
445  result.push_back(wireDigis(layer));
446  }
447  return result;
448 }
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 179 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 173 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 163 of file CSCEventData.h.

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

CSCALCTTrailer* CSCEventData::theALCTTrailer
private

Definition at line 165 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 169 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 176 of file CSCEventData.h.

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

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

Definition at line 171 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 183 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 180 of file CSCEventData.h.

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