Fix photon cluster matching by adding charge check in MatchClusters algorithm #2138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
MatchClustersalgorithm was not reconstructing photons even when clusters were present. The issue was in the cluster matching logic where photon clusters were incorrectly consumed by charged particle tracks during Step 1 (charged particle matching), preventing them from being reconstructed as neutral particles in Step 2.Root Cause
In
src/algorithms/reco/MatchClusters.cc(lines 67-73), the algorithm matched clusters to tracks purely bymcIDwithout checking if the associated MC particle was actually charged. This caused photon clusters to be incorrectly matched to charged particle tracks when they shared the samemcID, removing them from theclusterMapand preventing proper neutral particle reconstruction.Solution
Added a charge check before matching clusters to tracks. The algorithm now:
mcIDgetCharge() != 0.0F)clusterMapif the MC particle is actually chargedImpact
After this fix:
clusterMapduring Step 1 and are properly reconstructed as neutral particles in Step 2Testing
The change is minimal (13 lines added, 5 lines modified) and follows existing code patterns in the same file (line 99 uses the same
getCharge()check). The fix ensures that only truly charged particles consume clusters during track matching, allowing neutral particle clusters to pass through to the neutral reconstruction step.Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.