Skip to content

Commit 1db657f

Browse files
authored
Merge pull request #48812 from CMS-HGCAL/dev/unpacker_patch_rebase
Fix to unpacker / module locator for HGCAL
2 parents 6002914 + 0654bca commit 1db657f

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
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/plugins/HGCalRawToDigi.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ uint16_t HGCalRawToDigi::callUnpacker(unsigned fedId,
159159
void HGCalRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
160160
edm::ParameterSetDescription desc;
161161
desc.add<edm::InputTag>("src", edm::InputTag("rawDataCollector"));
162-
desc.add<std::vector<unsigned int> >("fedIds", {});
163162
desc.add<bool>("doSerial", true)->setComment("do not attempt to paralleize unpacking of different FEDs");
164163
desc.add<bool>("headersOnly", false)->setComment("unpack only headers");
165164
descriptions.add("hgcalDigis", desc);

EventFilter/HGCalRawToDigi/src/HGCalUnpacker.cc

Lines changed: 6 additions & 1 deletion
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

@@ -158,6 +158,11 @@ uint16_t HGCalUnpacker::parseFEDData(unsigned fedId,
158158
if (econd_pkt_status != backend::ECONDPacketStatus::InactiveECOND) {
159159
// always increment the global ECON-D index (unless inactive/unconnected)
160160
globalECONDIdx++;
161+
162+
//stop if we have all the ECON-Ds expected
163+
if (globalECONDIdx >= fedReadoutSequence.totalECONs_) {
164+
return (0x1 << hgcaldigi::FEDUnpackingFlags::GenericUnpackWarning);
165+
}
161166
}
162167
LogDebug("[HGCalUnpacker]") << "fedId = " << fedId << ", captureblockIdx = " << captureblockIdx
163168
<< ", econdIdx = " << econdIdx << ", globalECONDIdx = " << (int)globalECONDIdx

EventFilter/Utilities/src/DAQSourceModelsDTH.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ int DataModeDTH::eventCounterCallback(
512512
edm::LogError("EvFDaqDirector") << "Invalid DTH header encountered";
513513
return fileClose();
514514
}
515-
if (!oh->verifyMarker() || oh->version() != 1) {
515+
if (!oh->verifyMarker() || (oh->version() != 1 && oh->version() != 2)) {
516516
edm::LogError("EvFDaqDirector") << "Unexpected DTH header version " << oh->version();
517517
return fileClose();
518518
}

Geometry/HGCalMapping/test/HGCalMappingESSourceTester.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,13 @@ 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)
154+
continue;
152155
totalmods += nmods;
153-
printf("\t[FED %d] packs data from %ld ECON-Ds - readout types -> (offsets) :", frs.id, nmods);
156+
printf("\t[FED %d] packs data from %ld ECON-Ds - readout types -> (offsets)\n", frs.id, nmods);
157+
printf("\tTotal capture blocks: %ld Total ECON-Ds %ld\n", frs.totalCBs_, frs.totalECONs_);
154158
for (size_t i = 0; i < nmods; i++) {
155159
printf("\t%d -> (%d;%d;%d)", frs.readoutTypes_[i], frs.modOffsets_[i], frs.erxOffsets_[i], frs.chDataOffsets_[i]);
156160
}
@@ -247,7 +251,7 @@ void HGCalMappingESSourceTester::analyze(const edm::Event& iEvent, const edm::Ev
247251
printf("\tTime: %f seconds\n", elapsed.count());
248252

249253
HGCalElectronicsId eid(elecid);
250-
assert(eid.localFEDId() == fedid);
254+
assert(eid.localFEDId() == (fedid & HGCalElectronicsId::HGCalElectronicsIdMask::kLocalFEDIDMask));
251255
assert((uint32_t)eid.captureBlock() == captureblockidx);
252256
assert((uint32_t)eid.econdIdx() == econdidx);
253257
assert((uint32_t)eid.econdeRx() == (uint32_t)(2 * chip + half));
@@ -288,7 +292,8 @@ void HGCalMappingESSourceTester::analyze(const edm::Event& iEvent, const edm::Ev
288292
elapsed = stop - start;
289293
printf("\tTime: %f seconds\n", elapsed.count());
290294
eid = HGCalElectronicsId(elecid);
291-
assert(eid.localFEDId() == modules.view()[modidx].fedid());
295+
assert(eid.localFEDId() ==
296+
(modules.view()[modidx].fedid() & HGCalElectronicsId::HGCalElectronicsIdMask::kLocalFEDIDMask));
292297
assert((uint32_t)eid.captureBlock() == modules.view()[modidx].captureblockidx());
293298
assert((uint32_t)eid.econdIdx() == modules.view()[modidx].econdidx());
294299
assert((uint32_t)eid.halfrocChannel() == cells.view()[cellidx].seq());

0 commit comments

Comments
 (0)