From 714cf05287db318c4a35f03dad0714b6ecbecdac Mon Sep 17 00:00:00 2001 From: Maximiliano Puccio Date: Tue, 10 Nov 2026 14:42:01 +0100 Subject: [PATCH 1/2] ITSMFT: fix MC labels for single pixel clusters in the labels --- Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx b/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx index 2168c4b8d3308..8f872361d35d8 100644 --- a/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx +++ b/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx @@ -315,7 +315,10 @@ void Clusterer::ClustererThread::finishChipSingleHitFast(uint32_t hit, ChipPixel if (labelsClusPtr) { // MC labels were requested int nlab = 0; - fetchMCLabels(curChipData->getStartID() + hit, labelsDigPtr, nlab); + // Squashing can remove earlier digits on the chip, so the surviving + // pixel's source index need not be contiguous with the chip's start. + const auto digitID = parent->mSquashingDepth ? curChipData->getOrderedPixId(hit) : curChipData->getStartID() + hit; + fetchMCLabels(digitID, labelsDigPtr, nlab); auto cnt = compClusPtr->size(); for (int i = 0; i < nlab; i++) { labelsClusPtr->addElement(cnt, labelsBuff[i]); From 642f10122a99b702d0863dea725d0e31909b3998 Mon Sep 17 00:00:00 2001 From: Maximiliano Puccio Date: Thu, 12 Nov 2026 22:43:17 +0100 Subject: [PATCH 2/2] ITSMFT/ITS3: centralize cluster digit IDs for squashing labels --- .../include/ITSMFTReconstruction/PixelData.h | 2 ++ .../common/reconstruction/src/Clusterer.cxx | 20 ++++++------------- .../ITS3/reconstruction/src/Clusterer.cxx | 17 ++++++---------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h b/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h index 9b2c13b3db4fb..caccd646c85bc 100644 --- a/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h +++ b/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h @@ -273,6 +273,8 @@ class ChipPixelData std::vector& getPixIds() { return mPixIds; } std::vector& getPixelsOrder() { return mPixelsOrder; } uint32_t getOrderedPixId(int pos) const { return mPixIds[mPixelsOrder[pos]]; } + // Squashing can remove or reorder digits; otherwise their indices are contiguous. + uint32_t getDigitID(int pos) const { return mPixIds.empty() ? mStartID + pos : getOrderedPixId(pos); } private: uint8_t mROFlags = 0; // readout flags from the chip trailer diff --git a/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx b/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx index 8f872361d35d8..23717e8b0a7f1 100644 --- a/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx +++ b/Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx @@ -235,11 +235,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus pixArrBuff.push_back(pix); // needed for cluster topology bbox.adjust(pix.getRowDirect(), pix.getCol()); if (labelsClusPtr) { - if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity - fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab); - } else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second - fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab); - } + fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab); } next = pixEntry.first; } @@ -256,11 +252,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus pixArrBuff.push_back(pix); // needed for cluster topology bbox.adjust(pix.getRowDirect(), pix.getCol()); if (labelsClusPtr) { - if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity - fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab); - } else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second - fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab); - } + fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab); } next = pixEntry.first; } @@ -315,10 +307,7 @@ void Clusterer::ClustererThread::finishChipSingleHitFast(uint32_t hit, ChipPixel if (labelsClusPtr) { // MC labels were requested int nlab = 0; - // Squashing can remove earlier digits on the chip, so the surviving - // pixel's source index need not be contiguous with the chip's start. - const auto digitID = parent->mSquashingDepth ? curChipData->getOrderedPixId(hit) : curChipData->getStartID() + hit; - fetchMCLabels(digitID, labelsDigPtr, nlab); + fetchMCLabels(curChipData->getDigitID(hit), labelsDigPtr, nlab); auto cnt = compClusPtr->size(); for (int i = 0; i < nlab; i++) { labelsClusPtr->addElement(cnt, labelsBuff[i]); @@ -440,6 +429,9 @@ void Clusterer::ClustererThread::updateChip(const ChipPixelData* curChipData, ui void Clusterer::ClustererThread::fetchMCLabels(int digID, const ConstMCTruth* labelsDig, int& nfilled) { // transfer MC labels to cluster + if (!labelsDig) { + return; + } auto sortBuffer = [this]() { std::sort(this->labelsBuff.begin(), this->labelsBuff.end(), [](Label const& a, Label const& b) { return a.getTrackID() < b.getTrackID(); }); }; for (const auto& l : labelsDig->getLabels(digID)) { bool skip = false; diff --git a/Detectors/Upgrades/ITS3/reconstruction/src/Clusterer.cxx b/Detectors/Upgrades/ITS3/reconstruction/src/Clusterer.cxx index 60fc1859e4145..0491213aac72f 100644 --- a/Detectors/Upgrades/ITS3/reconstruction/src/Clusterer.cxx +++ b/Detectors/Upgrades/ITS3/reconstruction/src/Clusterer.cxx @@ -234,11 +234,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus pixArrBuff.push_back(pix); // needed for cluster topology bbox.adjust(pix.getRowDirect(), pix.getCol()); if (labelsClusPtr) { - if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity - fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab); - } else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second - fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab); - } + fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab); } next = pixEntry.first; } @@ -255,11 +251,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus pixArrBuff.push_back(pix); // needed for cluster topology bbox.adjust(pix.getRowDirect(), pix.getCol()); if (labelsClusPtr) { - if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity - fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab); - } else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second - fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab); - } + fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab); } next = pixEntry.first; } @@ -316,7 +308,7 @@ void Clusterer::ClustererThread::finishChipSingleHitFast(uint32_t hit, ChipPixel if (labelsClusPtr) { // MC labels were requested int nlab = 0; - fetchMCLabels(curChipData->getStartID() + hit, labelsDigPtr, nlab); + fetchMCLabels(curChipData->getDigitID(hit), labelsDigPtr, nlab); auto cnt = compClusPtr->size(); for (int i = 0; i < nlab; i++) { labelsClusPtr->addElement(cnt, labelsBuff[i]); @@ -454,6 +446,9 @@ void Clusterer::ClustererThread::updateChip(const ChipPixelData* curChipData, ui void Clusterer::ClustererThread::fetchMCLabels(int digID, const ConstMCTruth* labelsDig, int& nfilled) { // transfer MC labels to cluster + if (!labelsDig) { + return; + } auto sortBuffer = [this]() { std::sort(this->labelsBuff.begin(), this->labelsBuff.end(), [](Label const& a, Label const& b) { return a.getTrackID() < b.getTrackID(); }); }; for (const auto& label : labelsDig->getLabels(digID)) { bool skip = false;