Skip to content

Fix to the cluster key init#4171

Merged
osbornjd merged 1 commit intosPHENIX-Collaboration:masterfrom
antoniocosilva:TrackStateSmallFix
Feb 9, 2026
Merged

Fix to the cluster key init#4171
osbornjd merged 1 commit intosPHENIX-Collaboration:masterfrom
antoniocosilva:TrackStateSmallFix

Conversation

@antoniocosilva
Copy link
Copy Markdown
Contributor

@antoniocosilva antoniocosilva commented Feb 6, 2026

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, ...)

Fix the initialization of the cluster key. Previously it was being instantiated with {} (that would be 0), which made the state at the vertex be wrongly identified as a MVTX state. Now it is instantiated as std::numeric_limits<uint64_t>::max()

Fix to Cluster Key Initialization (PR #4171)

Motivation / Context

The cluster key (_ckey) member in SvtxTrackState_v3 was initialized with an empty initializer {}, which evaluates to 0. This caused a critical misidentification issue: uninitialized track states were incorrectly being flagged as associated with MVTX (Miniature Vertex Tracker) detector clusters, since 0 is a valid cluster key value. This fix introduces a sentinel value to distinguish genuinely uninitialized cluster keys from valid detector state assignments.

Key Changes

  • Modified private member initialization in SvtxTrackState_v3 class
  • Changed: TrkrDefs::cluskey _ckey{};
  • To: TrkrDefs::cluskey _ckey{std::numeric_limits<uint64_t>::max()};
  • File: offline/packages/trackbase_historic/SvtxTrackState_v3.h
  • Note: SvtxTrackState_v2.h retains the old initialization pattern for backward compatibility

Potential Risk Areas

  • Reconstruction behavior changes: Code checking for uninitialized cluster keys or comparing against 0 may behave differently. Review any logic that depends on the default cluster key value (e.g., state filtering, track fitting algorithms)
  • IO/Serialization changes: Default-constructed track state objects will now serialize with the maximum uint64_t value instead of 0, potentially affecting file format compatibility with older analyses. ROOT serialization (ClassDef) will encode the new sentinel value
  • Track state filtering: Any downstream code using get_cluskey() == 0 or similar checks to identify uninitialized states must be updated to use the new sentinel value
  • Performance: Negligible impact from the change itself, but dependent code checking cluster keys may see minor differences

Possible Future Improvements

  • Standardize sentinel value conventions across all track state versions (v1, v2, v3)
  • Add explicit documentation/comments explaining the sentinel value convention in TrkrDefs
  • Consider implementing helper functions (e.g., is_valid_ckey(), is_initialized_state()) to encapsulate these checks
  • Audit all track reconstruction and fitting modules for cluster key comparisons
  • Add unit tests verifying proper initialization behavior and state at vertex identification

Note: This summary includes AI-assisted analysis. Please verify the impact on downstream reconstruction algorithms and existing data files, particularly for physics analyses that may depend on vertex-state identification logic.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

The private member _ckey in SvtxTrackState_v3 is changed from an empty initializer to explicitly initialize to the maximum uint64_t value, establishing a sentinel default state for cluster keys on track objects.

Changes

Cohort / File(s) Summary
Cluster Key Initialization
offline/packages/trackbase_historic/SvtxTrackState_v3.h
Changed default initialization of private member _ckey from {} to {std::numeric_limits<uint64_t>::max()}, establishing a maximum value sentinel for unset cluster keys instead of zero/default state.
✨ 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.

@sphenix-jenkins-ci
Copy link
Copy Markdown

Build & test report

Report for commit f310306304826443ee4e2d8217fbd4c1efcd70f1:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@osbornjd
Copy link
Copy Markdown
Contributor

osbornjd commented Feb 8, 2026

Just to check, @pinkenburg this does not cause any problem with DST readback since there are no new objects (right)? It just means in old DSTs the old value will still be used in the initializer

@pinkenburg
Copy link
Copy Markdown
Contributor

yes - this won't change the readback. root does call the ctor when reading the data back, so the initial value will change from 0 (which is what {} does) to uint64_t (max). But then the dst content will overwrite this

@osbornjd osbornjd merged commit 3ff965f into sPHENIX-Collaboration:master Feb 9, 2026
22 checks passed
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.

3 participants