@@ -25,8 +25,9 @@ using namespace o2::trk;
2525
2626// Data formats for ACTS interface
2727struct Cell2D {
28- Cell2D (int rowv, int colv) : row(rowv), col(colv) {}
28+ Cell2D (int rowv, int colv, uint32_t digIdx = 0 ) : row(rowv), col(colv), digitIdx(digIdx ) {}
2929 int row, col;
30+ uint32_t digitIdx; // /< Index of the original digit (for MC label retrieval)
3031 Acts::Ccl::Label label{Acts::Ccl::NO_LABEL};
3132};
3233
@@ -222,7 +223,7 @@ void ClustererACTS::process(gsl::span<const Digit> digits,
222223 cells.reserve (chipN);
223224 for (int i = chipFirst; i < chipFirst + chipN; ++i) {
224225 const auto & digit = digits[mSortIdx [i]];
225- cells.emplace_back (digit.getRow (), digit.getColumn ());
226+ cells.emplace_back (digit.getRow (), digit.getColumn (), mSortIdx [i] );
226227 }
227228
228229 LOG (debug) << " Clustering with ACTS on chip " << chipID << " " << cells.size () << " digits" ;
@@ -303,6 +304,23 @@ void ClustererACTS::process(gsl::span<const Digit> digits,
303304 const int nBytes = (tileRowSpan * tileColSpan + 7 ) / 8 ;
304305 patterns.insert (patterns.end (), patt.begin (), patt.begin () + nBytes);
305306
307+ // Handle MC labels for this tile
308+ if (clusterLabels && digitLabels) {
309+ const auto clsIdx = static_cast <uint32_t >(clusters.size ());
310+ for (const auto & cell : actsCluster.cells ) {
311+ uint16_t r = static_cast <uint16_t >(cell.row );
312+ uint16_t c = static_cast <uint16_t >(cell.col );
313+ if (r >= tileRowMin && r <= tileRowMax && c >= tileColMin && c <= tileColMax) {
314+ if (cell.digitIdx < digitLabels->getIndexedSize ()) {
315+ const auto & lbls = digitLabels->getLabels (cell.digitIdx );
316+ for (const auto & lbl : lbls) {
317+ clusterLabels->addElement (clsIdx, lbl);
318+ }
319+ }
320+ }
321+ }
322+ }
323+
306324 // Create O2 cluster for this tile
307325 o2::trk::Cluster cluster;
308326 cluster.chipID = chipID;
@@ -331,6 +349,19 @@ void ClustererACTS::process(gsl::span<const Digit> digits,
331349 const int nBytes = (rowSpan * colSpan + 7 ) / 8 ;
332350 patterns.insert (patterns.end (), patt.begin (), patt.begin () + nBytes);
333351
352+ // Handle MC labels
353+ if (clusterLabels && digitLabels) {
354+ const auto clsIdx = static_cast <uint32_t >(clusters.size ());
355+ for (const auto & cell : actsCluster.cells ) {
356+ if (cell.digitIdx < digitLabels->getIndexedSize ()) {
357+ const auto & lbls = digitLabels->getLabels (cell.digitIdx );
358+ for (const auto & lbl : lbls) {
359+ clusterLabels->addElement (clsIdx, lbl);
360+ }
361+ }
362+ }
363+ }
364+
334365 // Create O2 cluster
335366 o2::trk::Cluster cluster;
336367 cluster.chipID = chipID;
0 commit comments