CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/EventFilter/CSCRawToDigi/src/CSCChamberDataItr.cc

Go to the documentation of this file.
00001 #include "EventFilter/CSCRawToDigi/interface/CSCChamberDataItr.h"
00002 #include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
00003 
00004 CSCChamberDataItr::CSCChamberDataItr(const char * buf) :
00005   theDCCData(0),
00006   theCurrentDDU(0)
00007 {
00008   // first try if it's DCC data.
00009   const CSCDCCHeader * dccHeader 
00010     = reinterpret_cast<const CSCDCCHeader *>(buf);
00011   if(dccHeader->check())
00012     {
00013       theDCCData = new CSCDCCEventData((unsigned short *)buf);
00014       theNumberOfDDUs = theDCCData->dduData().size();
00015       theDDUItr = new CSCDDUDataItr( &(theDCCData->dduData()[theCurrentDDU]) );
00016     }
00017   else 
00018     {
00019       // it's DDU data, with only one DDU
00020       theDDUItr = new CSCDDUDataItr(buf);
00021       theNumberOfDDUs = 1;
00022     }
00023 }
00024   
00025 
00026 CSCChamberDataItr::~CSCChamberDataItr() 
00027 {
00028    // safe, even if it's zero
00029    delete theDCCData;
00030 }
00031 
00032 
00033 bool CSCChamberDataItr::next() 
00034 {
00035   bool result = true;
00036   if(!theDDUItr->next()) 
00037     {
00038       if(++theCurrentDDU >= theNumberOfDDUs)
00039         {
00040           result = false;
00041         }
00042       else
00043         {
00044           // the next DDU exists, so initialize an itr
00045           assert(theDCCData != 0);
00046           delete theDDUItr;
00047           theDDUItr = new CSCDDUDataItr( &(theDCCData->dduData()[theCurrentDDU]) );
00048         }
00049     }
00050   return result;
00051 }
00052 
00053 
00054 const CSCEventData &  CSCChamberDataItr::operator*() 
00055 {
00056   return **theDDUItr;
00057 }
00058 
00059