Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:25

0001 #include "EventFilter/CSCRawToDigi/interface/CSCChamberDataItr.h"
0002 #include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
0003 
0004 CSCChamberDataItr::CSCChamberDataItr(const char *buf) : theDCCData(nullptr), theCurrentDDU(0) {
0005   // first try if it's DCC data.
0006   const CSCDCCHeader *dccHeader = reinterpret_cast<const CSCDCCHeader *>(buf);
0007   if (dccHeader->check()) {
0008     theDCCData = new CSCDCCEventData((const uint16_t *)buf);
0009     theNumberOfDDUs = theDCCData->dduData().size();
0010     theDDUItr = new CSCDDUDataItr(&(theDCCData->dduData()[theCurrentDDU]));
0011   } else {
0012     // it's DDU data, with only one DDU
0013     theDDUItr = new CSCDDUDataItr(buf);
0014     theNumberOfDDUs = 1;
0015   }
0016 }
0017 
0018 CSCChamberDataItr::~CSCChamberDataItr() {
0019   // safe, even if it's zero
0020   delete theDCCData;
0021 }
0022 
0023 bool CSCChamberDataItr::next() {
0024   bool result = true;
0025   if (!theDDUItr->next()) {
0026     if (++theCurrentDDU >= theNumberOfDDUs) {
0027       result = false;
0028     } else {
0029       // the next DDU exists, so initialize an itr
0030       assert(theDCCData != nullptr);
0031       delete theDDUItr;
0032       theDDUItr = new CSCDDUDataItr(&(theDCCData->dduData()[theCurrentDDU]));
0033     }
0034   }
0035   return result;
0036 }
0037 
0038 const CSCEventData &CSCChamberDataItr::operator*() { return **theDDUItr; }