Skip to content

fix: duplicate seed removal bug#4165

Merged
osbornjd merged 6 commits intosPHENIX-Collaboration:masterfrom
osbornjd:duplicate_removal_bug
Feb 6, 2026
Merged

fix: duplicate seed removal bug#4165
osbornjd merged 6 commits intosPHENIX-Collaboration:masterfrom
osbornjd:duplicate_removal_bug

Conversation

@osbornjd
Copy link
Copy Markdown
Contributor

@osbornjd osbornjd commented Feb 5, 2026

This fixes a subtle one line bug found by Yuko and Dennis where some exact duplicate seeds were not removed from the seed pool. It also adds a diagnostic function to check for this

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work for users)
  • Requiring change in macros repository (Please provide links to the macros pull request in the last section)
  • I am a member of GitHub organization of sPHENIX Collaboration, EIC, or ECCE (contact Chris Pinkenburg to join)

What kind of change does this PR introduce? (Bug fix, feature, ...)

TODOs (if applicable)

Links to other PRs in macros and calibration repositories (if applicable)

Pull Request Summary: Fix Duplicate Seed Removal Bug

Motivation & Context

A logic bug caused some exact duplicate silicon seed tracks to survive the seed-merging step, producing redundant seed candidates and potentially duplicate reconstructed tracks. This PR fixes the duplicate-detection/merging logic and adds a diagnostic to surface any remaining duplicates.

Key Changes

  • Bug fix: corrects seed-merging logic so the merged key set (keysToKeep) is stored for the surviving seed instead of inserting the wrong key set, ensuring exact duplicates are consistently detected and removed.
  • Diagnostic: adds printRemainingDuplicates() (declared private in PHSiliconSeedMerger) to scan seed pairs after merging and print any duplicate relationships remaining.
  • Verbosity/diagnostics cleanup: removes verbose per-seed identify() emissions in the inner loop and consolidates diagnostic printing to a single call to printRemainingDuplicates() at the end of process_event() when Verbosity() > 2.
  • Minor: small formatting/clang-format changes.

Potential Risk Areas

  • Reconstruction behavior: changed seed removal/merging may alter downstream track reconstruction for events that previously had duplicate seeds. Run validation with representative datasets.
  • I/O / formats: no node or I/O interface changes — internal-only C++ modifications.
  • Thread-safety: no new concurrency primitives introduced; no known threading issues.
  • Performance: minimal impact. Correct logic may increase pairwise checks in some cases; diagnostics only run at high verbosity.

Possible Future Improvements

  • Add unit/regression tests covering multiple identical/overlapping seeds to prevent regressions.
  • Allow diagnostic output to be written to a file or test log for offline analysis.
  • If needed for high-multiplicity events, optimize pairwise duplicate checks (e.g., hashed signatures or indexed lookup).

Note: this summary was prepared with AI assistance—AI can err; please verify the patch and behavior during review.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Consolidates per-seed verbose diagnostics into a new helper printRemainingDuplicates(), replaces inline insertion of MVTX key sets with merged keysToKeep, and calls the new diagnostic at the end of process_event() when verbosity is high.

Changes

Cohort / File(s) Summary
PHSiliconSeedMerger implementation
offline/packages/trackreco/PHSiliconSeedMerger.cc
Removed inline per-seed verbose diagnostics and immediate per-match insertions; use keysToKeep for matches. Added printRemainingDuplicates() implementation that iterates seed pairs, computes MVTX key intersections, and prints remaining duplicates when still present after merging. Replaced per-seed identify() prints with a single call to printRemainingDuplicates() at end of process_event() when Verbosity() > 2.
PHSiliconSeedMerger declaration
offline/packages/trackreco/PHSiliconSeedMerger.h
Added private member declaration void printRemainingDuplicates(); and minor formatting adjustments near m_clusterOverlap.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Comment on lines +217 to 237
for (const auto& [trackKey, mvtxKeys] : matches)
{
std::cout << "original track: " << std::endl;
track->identify();
}
auto* track = m_siliconTracks->get(trackKey);
if (Verbosity() > 2)
{
std::cout << "original track: " << std::endl;
track->identify();
}

for (const auto& key : mvtxKeys)
{
if (track->find_cluster_key(key) == track->end_cluster_keys())
for (const auto& key : mvtxKeys)
{
track->insert_cluster_key(key);
if (Verbosity() > 2)
if (track->find_cluster_key(key) == track->end_cluster_keys())
{
std::cout << "adding " << key << std::endl;
track->insert_cluster_key(key);
if (Verbosity() > 2)
{
std::cout << "adding " << key << std::endl;
}
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing null check on track can cause a crash.

m_siliconTracks->get(trackKey) can return nullptr (as evidenced by the null check at line 128 for track2). If track is null here, lines 223 and 228 will dereference it, causing undefined behavior.

Proposed fix: add null guard
     for (const auto& [trackKey, mvtxKeys] : matches)
     {
       auto* track = m_siliconTracks->get(trackKey);
+      if (!track)
+      {
+        continue;
+      }
       if (Verbosity() > 2)
       {
         std::cout << "original track: " << std::endl;
         track->identify();
       }

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit 77ed93afaafa2f84882b5811d78d4bb6f920ff5f:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit cb381d6853ee81bf7b8d9d25d55aa42596706d1b:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit 756f1ffafab76a35c4c7a7d2f5a4e0af89a2576d:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@osbornjd osbornjd merged commit 663a3b2 into sPHENIX-Collaboration:master Feb 6, 2026
22 checks passed
@osbornjd osbornjd deleted the duplicate_removal_bug branch February 6, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant