@@ -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
440429void 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 ;
0 commit comments