CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes

CSCEventData Class Reference

#include <CSCEventData.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static bool debug = false

Private Member Functions

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

Private Attributes

unsigned short * alctZSErecovered
 Auxiliary bufer to recove the ALCT raw payload from zero suppression.
int size_
CSCALCTHeadertheALCTHeader
CSCALCTTrailertheALCTTrailer
CSCAnodeDatatheAnodeData
CSCCFEBDatatheCFEBData [5]
 for up to 5 CFEB boards
int theChamberType
CSCDMBHeader theDMBHeader
CSCDMBTrailer theDMBTrailer
CSCTMBDatatheTMBData
int zseEnable

Detailed Description

Definition at line 36 of file CSCEventData.h.


Constructor & Destructor Documentation

CSCEventData::CSCEventData ( int  chamberType) [explicit]

Definition at line 14 of file CSCEventData.cc.

References i, and theCFEBData.

CSCEventData::CSCEventData ( unsigned short *  buf)

should make const input soon

Definition at line 32 of file CSCEventData.cc.

References unpack_data().

                                              {
  unpack_data(buf);
}
CSCEventData::CSCEventData ( ) [inline]

Definition at line 41 of file CSCEventData.h.

{}
CSCEventData::~CSCEventData ( )

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

Definition at line 261 of file CSCEventData.cc.

References destroy().

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

Definition at line 257 of file CSCEventData.cc.

References copy().

                                                    {
  copy(data);
}

Member Function Documentation

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

routines to add digis to the data

Definition at line 455 of file CSCEventData.cc.

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

Referenced by CSCDigiToRaw::add(), and selfTest().

                                                           {
  //@@ need special logic here for ME11
  unsigned cfeb = (digi.getStrip()-1)/16;
  bool sixteenSamples = false;
  if (digi.getADCCounts().size()==16) sixteenSamples = true;  
  if(theCFEBData[cfeb] == 0)    {
    theCFEBData[cfeb] = new CSCCFEBData(cfeb, sixteenSamples);
    theDMBHeader.addCFEB(cfeb);
  }
  theCFEBData[cfeb]->add(digi, layer);
}
void CSCEventData::add ( const CSCWireDigi digi,
int  layer 
)
void CSCEventData::add ( const CSCComparatorDigi digi,
int  layer 
)

Definition at line 474 of file CSCEventData.cc.

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

                                                                {
  checkTMBClasses();
  theTMBData->clctData()->add(digi, layer);
}
void CSCEventData::add ( const std::vector< CSCALCTDigi > &  digis)

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

Definition at line 481 of file CSCEventData.cc.

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

void CSCEventData::add ( const std::vector< CSCCLCTDigi > &  digis)
void CSCEventData::add ( const std::vector< CSCCorrelatedLCTDigi > &  digis)
void CSCEventData::addALCTStructures ( )

adds an empty ALCTHeader, trailer, and anode data

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

References Exception, nalct(), and theAnodeData.

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

                                            {
  if(nalct() == 0) throw cms::Exception("No ALCT for this chamber");
  return theAnodeData;
}
CSCALCTHeader * CSCEventData::alctHeader ( ) const

user must check if nalct > 0

Definition at line 385 of file CSCEventData.cc.

References Exception, nalct(), and theALCTHeader.

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

                                             {
  if(nalct() == 0) throw cms::Exception("No ALCT for this chamber");
  return theALCTHeader;
}
CSCALCTTrailer * CSCEventData::alctTrailer ( ) const

user must check if nalct > 0

Definition at line 390 of file CSCEventData.cc.

References Exception, nalct(), and theALCTTrailer.

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

                                                {
  if(nalct() == 0) throw cms::Exception("No ALCT for this chamber");
  return theALCTTrailer;
}
CSCCFEBData * CSCEventData::cfebData ( unsigned  icfeb) const

unpacked in long mode: has overflow and error bits decoded

Definition at line 380 of file CSCEventData.cc.

References theCFEBData.

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

                                                        {
  return theCFEBData[icfeb];
}
int CSCEventData::chamberType ( ) const [inline]

might not be set in real data

Definition at line 134 of file CSCEventData.h.

References theChamberType.

{return theChamberType;}
void CSCEventData::checkALCTClasses ( ) [private]
void CSCEventData::checkTMBClasses ( ) [private]
CSCCLCTData * CSCEventData::clctData ( ) const

user must check if nclct > 0

Definition at line 412 of file CSCEventData.cc.

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

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

                                           {
  if((nclct() == 0)||(tmbData()==NULL)) throw cms::Exception("No CLCT data for this chamber");
  return tmbData()->clctData();
}
void CSCEventData::copy ( const CSCEventData data) [private]

Definition at line 288 of file CSCEventData.cc.

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

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

                                                 {
  init();
  theDMBHeader  = data.theDMBHeader;
  theDMBTrailer = data.theDMBTrailer;
  if(data.theALCTHeader != NULL)
    theALCTHeader  = new CSCALCTHeader(*(data.theALCTHeader));
  if(data.theAnodeData != NULL) 
    theAnodeData   = new CSCAnodeData(*(data.theAnodeData));
  if(data.theALCTTrailer != NULL) 
    theALCTTrailer = new CSCALCTTrailer(*(data.theALCTTrailer));
  if(data.theTMBData != NULL) 
    theTMBData     = new CSCTMBData(*(data.theTMBData));
  for(int icfeb = 0; icfeb < 5; ++icfeb) {
    theCFEBData[icfeb] = 0;
    if(data.theCFEBData[icfeb] != NULL) 
      theCFEBData[icfeb] = new CSCCFEBData(*(data.theCFEBData[icfeb]));
  }   
  size_  = data.size_;
  theChamberType = data.theChamberType;
  
}
void CSCEventData::destroy ( ) [private]

Definition at line 311 of file CSCEventData.cc.

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

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

                           {
  if(zseEnable){
  delete [] alctZSErecovered;
  }
  delete theALCTHeader;
  delete theAnodeData;
  delete theALCTTrailer;
  delete theTMBData;
  for(int icfeb = 0; icfeb < 5; ++icfeb) {
    delete theCFEBData[icfeb];
  }
/*
  std::cout << "Before delete alctZSErecovered " << std::endl;
  delete [] alctZSErecovered;
  std::cout << "After delete alctZSErecovered " << std::endl;
*/  
}
const CSCDMBHeader* CSCEventData::dmbHeader ( ) const [inline]

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

Definition at line 90 of file CSCEventData.h.

References theDMBHeader.

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

{return &theDMBHeader;}
CSCDMBHeader* CSCEventData::dmbHeader ( ) [inline]

Definition at line 91 of file CSCEventData.h.

References theDMBHeader.

{return &theDMBHeader;}
const CSCDMBTrailer* CSCEventData::dmbTrailer ( ) const [inline]

DMB trailer.

Definition at line 112 of file CSCEventData.h.

References theDMBTrailer.

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

{return &theDMBTrailer;}
void CSCEventData::init ( void  ) [private]

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

Definition at line 274 of file CSCEventData.cc.

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

Referenced by copy().

                        {
  //dataPresent = 0;
  theALCTHeader = 0;
  theAnodeData = 0;
  theALCTTrailer = 0;
  theTMBData = 0;
  for(int icfeb = 0; icfeb < 5; ++icfeb) {
    theCFEBData[icfeb] = 0;
  }
  alctZSErecovered=0;
  zseEnable=0;
}
bool CSCEventData::isALCT ( const short unsigned int *  buf)

if dealing with ALCT data

Definition at line 247 of file CSCEventData.cc.

                                                        {
  return (((buf[0]&0xFFFF)==0xDB0A)||(((buf[0]&0xF800)==0x6000)&&((buf[1]&0xF800)==0)));
}
bool CSCEventData::isTMB ( const short unsigned int *  buf)

if dealing with TMB data

Definition at line 251 of file CSCEventData.cc.

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

the flag for existence of ALCT data

Definition at line 84 of file CSCEventData.h.

References CSCDMBHeader::nalct(), and theDMBHeader.

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

{return theDMBHeader.nalct();}
int CSCEventData::nclct ( ) const [inline]

the number of CLCTs

Definition at line 87 of file CSCEventData.h.

References CSCDMBHeader::nclct(), and theDMBHeader.

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

{return theDMBHeader.nclct();}
CSCEventData CSCEventData::operator= ( const CSCEventData data)

Definition at line 266 of file CSCEventData.cc.

References copy(), and destroy().

                                                              {
  // check for self-assignment before destructing
  if(&data != this) destroy();
  copy(data);
  return *this;
}
boost::dynamic_bitset CSCEventData::pack ( )

returns the packed event data.

Definition at line 511 of file CSCEventData.cc.

References alctHeader(), alctTrailer(), python::multivaluedict::append(), cfebData(), CSCALCTTrailer::data(), CSCDMBTrailer::data(), data, CSCDMBHeader::data(), CSCAnodeData::data(), dmbTrailer(), NULL, CSCTMBData::pack(), CSCALCTHeader::pack(), query::result, CSCDMBHeader::sizeInWords(), CSCAnodeData::sizeInWords(), CSCALCTTrailer::sizeInWords(), CSCDMBTrailer::sizeInWords(), theALCTHeader, theALCTTrailer, theAnodeData, theCFEBData, theDMBHeader, theDMBTrailer, theTMBData, and bitset_utilities::ushortToBitset().

                                         {
  boost::dynamic_bitset<> result = bitset_utilities::ushortToBitset( theDMBHeader.sizeInWords()*16, 
                                                                     theDMBHeader.data());

  if(theALCTHeader != NULL)     {
    boost::dynamic_bitset<> alctHeader = theALCTHeader->pack();
    result = bitset_utilities::append(result, alctHeader);
  }
  if(theAnodeData != NULL) {
    boost::dynamic_bitset<> anodeData = bitset_utilities::ushortToBitset (theAnodeData->sizeInWords()*16,
                                                                          theAnodeData->data());
    result = bitset_utilities::append(result, anodeData);
  }
  if(theALCTTrailer != NULL)  {
    boost::dynamic_bitset<> alctTrailer =bitset_utilities::ushortToBitset(theALCTTrailer->sizeInWords()*16,
                                                                          theALCTTrailer->data());
    result = bitset_utilities::append(result, alctTrailer);
  }
  if(theTMBData != NULL)  {
    result  = bitset_utilities::append(result, theTMBData->pack());
  }

  for(int icfeb = 0;  icfeb < 5;  ++icfeb)  {
    if(theCFEBData[icfeb] != NULL){
      boost::dynamic_bitset<> cfebData = bitset_utilities::ushortToBitset(theCFEBData[icfeb]->sizeInWords()*16,
                                                                          theCFEBData[icfeb]->data());
      result = bitset_utilities::append(result, cfebData);
    }
  }
  
  boost::dynamic_bitset<> dmbTrailer = bitset_utilities::ushortToBitset( theDMBTrailer.sizeInWords()*16,
                                                                         theDMBTrailer.data());
  result = bitset_utilities::append(result, dmbTrailer);
  return result;
}
void CSCEventData::selfTest ( ) [static]

Definition at line 548 of file CSCEventData.cc.

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

                            {
  CSCEventData chamberData(5);
  CSCDetId detId(1, 3, 2, 1, 3);
  std::vector<CSCCLCTDigi> clctDigis;
  // Both CLCTs are read-out at the same (pre-trigger) bx, so the last-but-one
  // arguments in both digis must be the same.
  clctDigis.push_back(CSCCLCTDigi(1, 1, 4, 1, 0, 30, 3, 2, 1)); // valid for 2007
  clctDigis.push_back(CSCCLCTDigi(1, 1, 2, 1, 1, 31, 1, 2, 2));
  
  // BX of LCT (8th argument) is 1-bit word (the least-significant bit
  // of ALCT's bx).
  std::vector<CSCCorrelatedLCTDigi> corrDigis;
  corrDigis.push_back(CSCCorrelatedLCTDigi(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0));
  corrDigis.push_back(CSCCorrelatedLCTDigi(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0));

  chamberData.add(clctDigis);
  chamberData.add(corrDigis);

  CSCWireDigi wireDigi(10, 6);
  CSCComparatorDigi comparatorDigi(30, 1, 6);
  chamberData.add(wireDigi, 3);
  chamberData.add(comparatorDigi, 3);

  CSCEventData newData = cscPackAndUnpack(chamberData);

  std::vector<CSCCLCTDigi> clcts = newData.tmbHeader()->CLCTDigis(detId.rawId());
  assert(cscPackerCompare(clcts[0],clctDigis[0]));
  assert(cscPackerCompare(clcts[1],clctDigis[1]));

  std::vector<CSCCorrelatedLCTDigi> lcts = newData.tmbHeader()->CorrelatedLCTDigis(detId.rawId());
  assert(cscPackerCompare(lcts[0], corrDigis[0]));
  assert(cscPackerCompare(lcts[1], corrDigis[1]));

  // test strip digis
  CSCDetId me1adet1(1, 1, 1, 4, 1);
  CSCDetId me1bdet1(1, 1, 4, 4, 6);
  CSCDetId me1adet2(2, 1, 1, 4, 2);
  CSCDetId me1bdet2(2, 1, 4, 4, 5);

  std::vector<int> sca(16, 600);
  std::vector<unsigned short> overflow(16, 0), overlap(16, 0), errorfl(16,0);
  CSCStripDigi me1a(5, sca, overflow, overlap, errorfl);
  CSCStripDigi me1b(8, sca, overflow, overlap, errorfl);

  CSCEventData forward(1);
  CSCEventData backward(1);
  
  forward.add(me1a, me1adet1.layer());
  forward.add(me1b, me1bdet1.layer());
  backward.add(me1a, me1adet2.layer());
  backward.add(me1b, me1adet2.layer());
  std::vector<CSCStripDigi> me1afs = forward.stripDigis(me1adet1);
  std::vector<CSCStripDigi> me1bfs = forward.stripDigis(me1bdet1);
  std::vector<CSCStripDigi> me1abs = backward.stripDigis(me1adet2);
  std::vector<CSCStripDigi> me1bbs = backward.stripDigis(me1bdet2);
  //FIXME The current code works under the assumption that ME11 and ME1A
  // go into separate EventData.  They need to be combined.
  assert(me1afs.size() == 16);
  assert(me1bfs.size() == 16);
  assert(me1abs.size() == 16);
  assert(me1bbs.size() == 16);

  assert(me1afs[4].getStrip() == 5);
  assert(me1bfs[7].getStrip() == 8);
  assert(me1abs[4].getStrip() == 5);
  assert(me1bbs[7].getStrip() == 8);
  assert(me1afs[4].pedestal() == 600);
  assert(me1bfs[7].pedestal() == 600);
  assert(me1abs[4].pedestal() == 600);
  assert(me1bbs[7].pedestal() == 600);


}
static void CSCEventData::setDebug ( const bool  value) [inline, static]

turns on/off debug flag for this class

Definition at line 52 of file CSCEventData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

{debug = value;}
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 418 of file CSCEventData.cc.

References CSCDMBHeader::setBXN(), CSCALCTHeader::setEventInformation(), CSCTMBHeader::setEventInformation(), CSCDMBHeader::setL1A(), theALCTHeader, theDMBHeader, theTMBData, and CSCTMBData::tmbHeader().

Referenced by CSCDDUEventData::add().

unsigned short CSCEventData::size ( void  ) const [inline]

size of the data buffer used, in bytes

Definition at line 49 of file CSCEventData.h.

References size_.

Referenced by checkALCTClasses().

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

deprecated. Use the above methods instead

Definition at line 362 of file CSCEventData.cc.

References query::result.

Referenced by stripDigis().

                                                                     {
  std::vector < std::vector<CSCStripDigi> > result;
  for (int layer = 1; layer <= 6; ++layer) {
    std::vector<CSCStripDigi> digis = stripDigis(layer);
    result.push_back(digis);
  }
  return result;
}
std::vector< CSCStripDigi > CSCEventData::stripDigis ( unsigned  idlayer,
unsigned  icfeb 
) const

returns all the strip digis in the chamber's cfeb

Definition at line 340 of file CSCEventData.cc.

References CSCCFEBData::digis(), NULL, query::result, and theCFEBData.

                                                                                       {
  //  assert(ilayer > 0 && ilayer <= 6); // off because now idlayer is raw cscdetid
  std::vector<CSCStripDigi> result;
  if(theCFEBData[icfeb] != NULL) {
    std::vector<CSCStripDigi> newDigis = theCFEBData[icfeb]->digis(idlayer);
    result.insert(result.end(), newDigis.begin(), newDigis.end());
  }
  
  return result;
}
std::vector< CSCStripDigi > CSCEventData::stripDigis ( const CSCDetId idlayer) const

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

Definition at line 330 of file CSCEventData.cc.

References query::result, and stripDigis().

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

                                                                               {
  std::vector<CSCStripDigi> result;
  for(unsigned icfeb = 0; icfeb < 5; ++icfeb){
    std::vector<CSCStripDigi> newDigis = stripDigis(idlayer, icfeb);
    result.insert(result.end(), newDigis.begin(), newDigis.end());
  }
  return result;
}
CSCTMBData * CSCEventData::tmbData ( ) const

user must check in nclct > 0

Definition at line 401 of file CSCEventData.cc.

References Exception, nclct(), and theTMBData.

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

                                         {
  if(nclct() == 0) throw cms::Exception("No CLCT for this chamber");
  return theTMBData;
}
CSCTMBHeader * CSCEventData::tmbHeader ( ) const

user must check if nclct > 0

Definition at line 407 of file CSCEventData.cc.

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

Referenced by selfTest().

                                             {
  if((nclct() == 0)||(tmbData()==NULL)) throw cms::Exception("No CLCT header for this chamber");
  return tmbData()->tmbHeader();
}
void CSCEventData::unpack_data ( unsigned short *  buf) [private]

To pack trailer 0

Pack Trailer 0 (to access TTS)

Definition at line 152 of file CSCDDUEventData.cc.

References CSCDDUTrailer::check(), gather_cfg::cout, CSCDCCExaminer::DDU_block(), CSCDCCExaminer::DDU_size(), CSCDDUEventData::debug, CSCDDUEventData::decodeStatus(), CSCDCCExaminer::DMB_block(), CSCDDUEventData::errMask, benchmark_cfg::errors, CSCDCCExaminer::errorsForChamber(), CSCDDUTrailer::errorstat(), CSCDDUEventData::errorstat, CSCDCCExaminer::getMask(), i, LogTrace, CSCDDUHeader::ncsc(), NULL, pos, CSCDDUEventData::size(), CSCDDUHeader::sizeInWords(), CSCDDUTrailer::sizeInWords(), CSCDDUHeader::source_id(), CSCDDUEventData::theData, CSCDDUEventData::theDDUHeader, CSCDDUEventData::theDDUTrailer, CSCDDUEventData::theDDUTrailer0, and CSCDDUEventData::theSizeInWords.

Referenced by CSCEventData().

{
  // just to calculate length
  uint16_t * inputBuf = buf;
  uint16_t * inputBuf0 = buf; 
  theData.clear();
  if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi") << "CSCDDUEventData::unpack_data() is called";
  if (debug) 
   for (int i=0;i<6;++i) 
    {
      LogTrace ("CSCDDUEventData|CSCRawToDigi") << i << std::hex << buf[4*i+3] << buf[4*i+2] 
                                                << buf[4*i+1] << buf[4*i];
     std::cout << i << " " << std::hex << buf[4*i+3] << " " << buf[4*i+2] << " " 
                                                << buf[4*i+1] << " " << buf[4*i] << std::endl;
    }
  //std::cout << "DDU Size: " << std::dec << theDDUHeader.sizeInWords() << std::endl;

  memcpy(&theDDUHeader, buf, theDDUHeader.sizeInWords()*2);
  
  if (debug) {
    LogTrace ("CSCDDUEventData|CSCRawToDigi") << "size of ddu header in words = " << theDDUHeader.sizeInWords();
    LogTrace ("CSCDDUEventData|CSCRawToDigi") << "sizeof(DDUHeader) = " << sizeof(theDDUHeader);
  }
  buf += theDDUHeader.sizeInWords();
  



  //std::cout << "sandrik dduID =" << theDDUHeader.source_id() << std::endl; 
  //int i=-1;

 
  // we really don't want to copy CSCEventData's while filling the vec
  theData.clear();
  theData.reserve(theDDUHeader.ncsc());

  if (examiner!= NULL) { // Use selective unpacking mode

    if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi") << "selective unpacking starting";

    // Find this DDU in examiner's DDUs list
    DDUIdType dduID = theDDUHeader.source_id(); 
        
    std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > ddus = examiner->DMB_block();
    std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> >::iterator ddu_itr = ddus.find(dduID);
    uint16_t* dduBlock = (uint16_t*)((examiner->DDU_block())[dduID]);
    uint32_t dduBufSize = (examiner->DDU_size())[dduID];
                
    if (ddu_itr != ddus.end() && dduBufSize!=0 && dduBlock==inputBuf) {
      std::map<CSCIdType,const uint16_t*> &cscs = ddu_itr->second;
      std::map<CSCIdType,const uint16_t*>::iterator csc_itr;

      for (csc_itr=cscs.begin(); csc_itr != cscs.end(); ++csc_itr) {
        short cscid = csc_itr->first;

        if(cscid != -1)
        {
          uint16_t* pos = (uint16_t*)csc_itr->second;
        
        
          ExaminerStatusType errors = examiner->errorsForChamber(cscid);
          if ((errors & examiner->getMask()) > 0 ) {    
                if (debug) 
                LogTrace ("CSCDDUEventData|CSCRawToDigi" )
                       << "skip unpacking of CSC " << cscid << " due format errors: 0x" << std::hex << errors << std::dec;
            continue;
          } 
        
          theData.push_back(CSCEventData(pos));
        }
      }

      if (debug)
        {
          LogTrace ("CSCDDUEventData|CSCRawToDigi") << "size of vector of cscData = " << theData.size();
        }
      // std::cout << std::dec << theDDUTrailer.sizeInWords() << std::endl;
      // decode ddu tail
      memcpy(&theDDUTrailer, inputBuf+dduBufSize, theDDUTrailer.sizeInWords()*2);
      // memcpy(&theDDUTrailer, dduBlock+(dduBufSize-theDDUTrailer.sizeInWords())*2, theDDUTrailer.sizeInWords()*2);
      if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi") << theDDUTrailer.check();
      errorstat=theDDUTrailer.errorstat();
      if ((errorstat&errMask) != 0)
        {
          if (theDDUTrailer.check())
            {
              if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi")
                << "+++ CSCDDUEventData warning: DDU Trailer errors = " << std::hex << errorstat << " +++ ";
              if (debug) decodeStatus(errorstat);
            }
          else
            {
              if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi" )
                << " Unpacking lost DDU trailer - check() failed and 8 8 ffff 8 was not found ";
            }
        }

      if (debug) {
        LogTrace ("CSCDDUEventData|CSCRawToDigi")  << " Final errorstat " << std::hex << errorstat << std::dec ;
      }
      // the trailer counts in 64-bit words

      // theSizeInWords = dduBufSize;
      // buf=inputBuf+dduBufSize;

    }
    theSizeInWords = dduBufSize+12;
    buf=inputBuf+dduBufSize;
        
  } else {


    while( (((buf[0]&0xf000) == 0x9000)||((buf[0]&0xf000) == 0xa000)) 
           && (buf[3] != 0x8000)) {
        // ++i;
        if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi") << "unpack csc data loop started";
        theData.push_back(CSCEventData(buf));
        buf += (theData.back()).size();
        if (debug) {
            LogTrace ("CSCDDUEventData|CSCRawToDigi") << "size of vector of cscData = " << theData.size();
        }
    }
 
    if (debug) {
        LogTrace ("CSCDDUEventData|CSCRawToDigi") << "unpacking ddu trailer ";
        LogTrace ("CSCDDUEventData|CSCRawToDigi") << std::hex << buf[3]<<" " << buf[2] 
                                         <<" " << buf[1]<<" " << buf[0];
    }

    // decode ddu tail
    memcpy(&theDDUTrailer, buf, theDDUTrailer.sizeInWords()*2);
    if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi") << theDDUTrailer.check();
    errorstat=theDDUTrailer.errorstat();
    if ((errorstat&errMask) != 0)  
      {
        if (theDDUTrailer.check())
          {
            if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi") 
              << "+++ CSCDDUEventData warning: DDU Trailer errors = " << std::hex << errorstat << " +++ ";
            if (debug) decodeStatus(errorstat);
          } 
        else 
          {
            if (debug) LogTrace ("CSCDDUEventData|CSCRawToDigi" ) 
              << " Unpacking lost DDU trailer - check() failed and 8 8 ffff 8 was not found ";
          }
      }
   
    if (debug) 
      LogTrace ("CSCDDUEventData|CSCRawToDigi")  << " Final errorstat " << std::hex << errorstat << std::dec ;
    // the trailer counts in 64-bit words
    buf += theDDUTrailer.sizeInWords();
  
    theSizeInWords = buf - inputBuf;
  }

//std::cout << "DDUevData Size: " << theSizeInWords << " BUFlast: " << std::hex << inputBuf0[theSizeInWords-4] << //std::endl;
theDDUTrailer0 = inputBuf0[theSizeInWords-4];
}
std::vector< CSCWireDigi > CSCEventData::wireDigis ( unsigned  ilayer) const

Definition at line 352 of file CSCEventData.cc.

References theAnodeData, and CSCAnodeData::wireDigis().

Referenced by operator<<().

                                                                    {
  if(theAnodeData == 0)    {
    return std::vector<CSCWireDigi>();
  } 
  else    {
    return theAnodeData->wireDigis(ilayer);
  }
}
std::vector< std::vector< CSCWireDigi > > CSCEventData::wireDigis ( ) const

deprecated. Use the above method instead.

Definition at line 371 of file CSCEventData.cc.

References query::result.

                                                                   {
  std::vector < std::vector<CSCWireDigi> > result;
  for (int layer = 1; layer <= 6; ++layer)     {
    result.push_back(wireDigis(layer));
  }
  return result;
}

Member Data Documentation

unsigned short* CSCEventData::alctZSErecovered [private]

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

Definition at line 178 of file CSCEventData.h.

Referenced by destroy(), and init().

bool CSCEventData::debug = false [static]

Definition at line 137 of file CSCEventData.h.

Referenced by setDebug().

int CSCEventData::size_ [private]

Definition at line 172 of file CSCEventData.h.

Referenced by copy(), and size().

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 162 of file CSCEventData.h.

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

Definition at line 164 of file CSCEventData.h.

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

Definition at line 163 of file CSCEventData.h.

Referenced by add(), alctData(), checkALCTClasses(), copy(), destroy(), init(), pack(), and wireDigis().

for up to 5 CFEB boards

Definition at line 168 of file CSCEventData.h.

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

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 175 of file CSCEventData.h.

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

Definition at line 170 of file CSCEventData.h.

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

Definition at line 165 of file CSCEventData.h.

Referenced by add(), checkTMBClasses(), copy(), destroy(), init(), pack(), setEventInformation(), and tmbData().

int CSCEventData::zseEnable [private]

Definition at line 179 of file CSCEventData.h.

Referenced by destroy(), and init().