Skip to content

Commit a1bb2ad

Browse files
committed
add generic warning to HGCalFEDPacketInfoSoA, counters of capture block and econs, propagating to indexer
1 parent 2b0a5a0 commit a1bb2ad

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
struct HGCalFEDReadoutSequence {
2323
uint32_t id;
24+
//overall counters for total number of ECONs and Capture Blocks (useful to steer the unpacker behavior)
25+
size_t totalECONs_, totalCBs_;
2426
/// look-up table (capture block, econd idx) -> internal dense index
2527
std::vector<int> moduleLUT_;
2628
/// dense sequence of modules in the readout: the type is the one in use in the cell mapping

CondFormats/HGCalObjects/src/HGCalMappingModuleIndexer.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,22 @@ void HGCalMappingModuleIndexer::finalize() {
8282
std::vector<uint32_t> typeCounters(globalTypesCounter_.size(), 0);
8383
for (auto& fedit : fedReadoutSequences_) {
8484
//assign the final indexing in the look-up table depending on which ECON-D's are really present
85+
//count also the the number of capture blocks present
8586
size_t nconn(0);
8687
fedit.moduleLUT_.resize(fedit.readoutTypes_.size(), -1);
88+
std::set<uint32_t> uniqueCB;
8789
for (size_t i = 0; i < fedit.readoutTypes_.size(); i++) {
8890
if (fedit.readoutTypes_[i] == -1)
8991
continue; //unexisting
9092

9193
reassignTypecodeLocation(fedit.id, i, nconn);
9294
fedit.moduleLUT_[i] = nconn;
9395
nconn++;
96+
97+
uniqueCB.insert( modFedIndexer_.unpackDenseIndex(i)[0] );
9498
}
99+
fedit.totalECONs_ = nconn;
100+
fedit.totalCBs_ = uniqueCB.size();
95101

96102
//remove unexisting ECONs building a final compact readout sequence
97103
fedit.readoutTypes_.erase(

DataFormats/HGCalDigi/interface/HGCalFEDPacketInfoSoA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace hgcaldigi {
1414
constexpr uint8_t NormalUnpacking = 0, GenericUnpackError = 1, ErrorSLinkHeader = 2, ErrorPayload = 3,
1515
ErrorCaptureBlockHeader = 4, ActiveCaptureBlockFlags = 5, ErrorECONDHeader = 6,
1616
ECONDPayloadLengthOverflow = 7, ECONDPayloadLengthMismatch = 8, ErrorSLinkTrailer = 9,
17-
EarlySLinkEnd = 10;
17+
EarlySLinkEnd = 10, GenericUnpackWarning = 11;
1818
} // namespace FEDUnpackingFlags
1919

2020
inline constexpr bool isNotNormalFED(uint16_t fedUnpackingFlag) {

EventFilter/HGCalRawToDigi/src/HGCalUnpacker.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
102102

103103
// parse SLink body (capture blocks)
104104
bool hasActiveCBFlags(false);
105-
for (uint32_t captureblockIdx = 0; captureblockIdx < HGCalMappingModuleIndexer::maxCBperFED_ && ptr < trailer - 2;
105+
for (uint32_t captureblockIdx = 0; captureblockIdx < fedReadoutSequence.totalCBs_ && ptr < trailer - 2;
106106
captureblockIdx++) {
107107
// check capture block header (64b)
108108

@@ -159,10 +159,9 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
159159
// always increment the global ECON-D index (unless inactive/unconnected)
160160
globalECONDIdx++;
161161

162-
//if for some reason we get more than expected there is something funny with the data
163-
//for now raise a payload error
164-
if(globalECONDIdx >= fedReadoutSequence.readoutTypes_.size()) {
165-
return (0x1 << hgcaldigi::FEDUnpackingFlags::ErrorPayload);
162+
//stop if we have all the ECON-Ds expected
163+
if(globalECONDIdx >= fedReadoutSequence.totalECONs_) {
164+
return (0x1 << hgcaldigi::FEDUnpackingFlags::GenericUnpackWarning);
166165
}
167166

168167
}

Geometry/HGCalMapping/test/HGCalMappingESSourceTester.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,12 @@ void HGCalMappingESSourceTester::analyze(const edm::Event& iEvent, const edm::Ev
148148
frs.chDataOffsets_.end(),
149149
std::inserter(unique_chDataOffsets, unique_chDataOffsets.end()));
150150

151-
size_t nmods = frs.readoutTypes_.size();
151+
assert(frs.readoutTypes_.size() == frs.totalECONs_);
152+
size_t nmods = frs.totalECONs_;
153+
if(nmods==0) continue;
152154
totalmods += nmods;
153-
printf("\t[FED %d] packs data from %ld ECON-Ds - readout types -> (offsets) :", frs.id, nmods);
155+
printf("\t[FED %d] packs data from %ld ECON-Ds - readout types -> (offsets)\n", frs.id, nmods);
156+
printf("\tTotal capture blocks: %ld Total ECON-Ds %ld\n", frs.totalCBs_, frs.totalECONs_);
154157
for (size_t i = 0; i < nmods; i++) {
155158
printf("\t%d -> (%d;%d;%d)", frs.readoutTypes_[i], frs.modOffsets_[i], frs.erxOffsets_[i], frs.chDataOffsets_[i]);
156159
}
@@ -247,7 +250,7 @@ void HGCalMappingESSourceTester::analyze(const edm::Event& iEvent, const edm::Ev
247250
printf("\tTime: %f seconds\n", elapsed.count());
248251

249252
HGCalElectronicsId eid(elecid);
250-
assert(eid.localFEDId() == fedid);
253+
assert(eid.localFEDId() == (fedid & HGCalElectronicsId::HGCalElectronicsIdMask::kLocalFEDIDMask));
251254
assert((uint32_t)eid.captureBlock() == captureblockidx);
252255
assert((uint32_t)eid.econdIdx() == econdidx);
253256
assert((uint32_t)eid.econdeRx() == (uint32_t)(2 * chip + half));
@@ -288,7 +291,7 @@ void HGCalMappingESSourceTester::analyze(const edm::Event& iEvent, const edm::Ev
288291
elapsed = stop - start;
289292
printf("\tTime: %f seconds\n", elapsed.count());
290293
eid = HGCalElectronicsId(elecid);
291-
assert(eid.localFEDId() == modules.view()[modidx].fedid());
294+
assert(eid.localFEDId() == (modules.view()[modidx].fedid() & HGCalElectronicsId::HGCalElectronicsIdMask::kLocalFEDIDMask));
292295
assert((uint32_t)eid.captureBlock() == modules.view()[modidx].captureblockidx());
293296
assert((uint32_t)eid.econdIdx() == modules.view()[modidx].econdidx());
294297
assert((uint32_t)eid.halfrocChannel() == cells.view()[cellidx].seq());

0 commit comments

Comments
 (0)