Skip to content

Commit 642f101

Browse files
committed
ITSMFT/ITS3: centralize cluster digit IDs for squashing labels
1 parent 714cf05 commit 642f101

3 files changed

Lines changed: 14 additions & 25 deletions

File tree

‎Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ class ChipPixelData
273273
std::vector<uint32_t>& getPixIds() { return mPixIds; }
274274
std::vector<int>& getPixelsOrder() { return mPixelsOrder; }
275275
uint32_t getOrderedPixId(int pos) const { return mPixIds[mPixelsOrder[pos]]; }
276+
// Squashing can remove or reorder digits; otherwise their indices are contiguous.
277+
uint32_t getDigitID(int pos) const { return mPixIds.empty() ? mStartID + pos : getOrderedPixId(pos); }
276278

277279
private:
278280
uint8_t mROFlags = 0; // readout flags from the chip trailer

‎Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus
235235
pixArrBuff.push_back(pix); // needed for cluster topology
236236
bbox.adjust(pix.getRowDirect(), pix.getCol());
237237
if (labelsClusPtr) {
238-
if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity
239-
fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab);
240-
} else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second
241-
fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab);
242-
}
238+
fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab);
243239
}
244240
next = pixEntry.first;
245241
}
@@ -256,11 +252,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus
256252
pixArrBuff.push_back(pix); // needed for cluster topology
257253
bbox.adjust(pix.getRowDirect(), pix.getCol());
258254
if (labelsClusPtr) {
259-
if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity
260-
fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab);
261-
} else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second
262-
fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab);
263-
}
255+
fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab);
264256
}
265257
next = pixEntry.first;
266258
}
@@ -315,10 +307,7 @@ void Clusterer::ClustererThread::finishChipSingleHitFast(uint32_t hit, ChipPixel
315307

316308
if (labelsClusPtr) { // MC labels were requested
317309
int nlab = 0;
318-
// Squashing can remove earlier digits on the chip, so the surviving
319-
// pixel's source index need not be contiguous with the chip's start.
320-
const auto digitID = parent->mSquashingDepth ? curChipData->getOrderedPixId(hit) : curChipData->getStartID() + hit;
321-
fetchMCLabels(digitID, labelsDigPtr, nlab);
310+
fetchMCLabels(curChipData->getDigitID(hit), labelsDigPtr, nlab);
322311
auto cnt = compClusPtr->size();
323312
for (int i = 0; i < nlab; i++) {
324313
labelsClusPtr->addElement(cnt, labelsBuff[i]);
@@ -440,6 +429,9 @@ void Clusterer::ClustererThread::updateChip(const ChipPixelData* curChipData, ui
440429
void Clusterer::ClustererThread::fetchMCLabels(int digID, const ConstMCTruth* labelsDig, int& nfilled)
441430
{
442431
// transfer MC labels to cluster
432+
if (!labelsDig) {
433+
return;
434+
}
443435
auto sortBuffer = [this]() { std::sort(this->labelsBuff.begin(), this->labelsBuff.end(), [](Label const& a, Label const& b) { return a.getTrackID() < b.getTrackID(); }); };
444436
for (const auto& l : labelsDig->getLabels(digID)) {
445437
bool skip = false;

‎Detectors/Upgrades/ITS3/reconstruction/src/Clusterer.cxx‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus
234234
pixArrBuff.push_back(pix); // needed for cluster topology
235235
bbox.adjust(pix.getRowDirect(), pix.getCol());
236236
if (labelsClusPtr) {
237-
if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity
238-
fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab);
239-
} else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second
240-
fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab);
241-
}
237+
fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab);
242238
}
243239
next = pixEntry.first;
244240
}
@@ -255,11 +251,7 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus
255251
pixArrBuff.push_back(pix); // needed for cluster topology
256252
bbox.adjust(pix.getRowDirect(), pix.getCol());
257253
if (labelsClusPtr) {
258-
if (parent->mSquashingDepth) { // the MCtruth for this pixel is stored in chip data: due to squashing we lose contiguity
259-
fetchMCLabels(curChipData->getOrderedPixId(pixEntry.second), labelsDigPtr, nlab);
260-
} else { // the MCtruth for this pixel is at curChipData->startID+pixEntry.second
261-
fetchMCLabels(pixEntry.second + curChipData->getStartID(), labelsDigPtr, nlab);
262-
}
254+
fetchMCLabels(curChipData->getDigitID(pixEntry.second), labelsDigPtr, nlab);
263255
}
264256
next = pixEntry.first;
265257
}
@@ -316,7 +308,7 @@ void Clusterer::ClustererThread::finishChipSingleHitFast(uint32_t hit, ChipPixel
316308

317309
if (labelsClusPtr) { // MC labels were requested
318310
int nlab = 0;
319-
fetchMCLabels(curChipData->getStartID() + hit, labelsDigPtr, nlab);
311+
fetchMCLabels(curChipData->getDigitID(hit), labelsDigPtr, nlab);
320312
auto cnt = compClusPtr->size();
321313
for (int i = 0; i < nlab; i++) {
322314
labelsClusPtr->addElement(cnt, labelsBuff[i]);
@@ -454,6 +446,9 @@ void Clusterer::ClustererThread::updateChip(const ChipPixelData* curChipData, ui
454446
void Clusterer::ClustererThread::fetchMCLabels(int digID, const ConstMCTruth* labelsDig, int& nfilled)
455447
{
456448
// transfer MC labels to cluster
449+
if (!labelsDig) {
450+
return;
451+
}
457452
auto sortBuffer = [this]() { std::sort(this->labelsBuff.begin(), this->labelsBuff.end(), [](Label const& a, Label const& b) { return a.getTrackID() < b.getTrackID(); }); };
458453
for (const auto& label : labelsDig->getLabels(digID)) {
459454
bool skip = false;

0 commit comments

Comments
 (0)