1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "EventFilter/CSCRawToDigi/interface/CSCChamberDataItr.h"
#include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
CSCChamberDataItr::CSCChamberDataItr(const char *buf) : theDCCData(nullptr), theCurrentDDU(0) {
// first try if it's DCC data.
const CSCDCCHeader *dccHeader = reinterpret_cast<const CSCDCCHeader *>(buf);
if (dccHeader->check()) {
theDCCData = new CSCDCCEventData((const uint16_t *)buf);
theNumberOfDDUs = theDCCData->dduData().size();
theDDUItr = new CSCDDUDataItr(&(theDCCData->dduData()[theCurrentDDU]));
} else {
// it's DDU data, with only one DDU
theDDUItr = new CSCDDUDataItr(buf);
theNumberOfDDUs = 1;
}
}
CSCChamberDataItr::~CSCChamberDataItr() {
// safe, even if it's zero
delete theDCCData;
}
bool CSCChamberDataItr::next() {
bool result = true;
if (!theDDUItr->next()) {
if (++theCurrentDDU >= theNumberOfDDUs) {
result = false;
} else {
// the next DDU exists, so initialize an itr
assert(theDCCData != nullptr);
delete theDDUItr;
theDDUItr = new CSCDDUDataItr(&(theDCCData->dduData()[theCurrentDDU]));
}
}
return result;
}
const CSCEventData &CSCChamberDataItr::operator*() { return **theDDUItr; }
|