Skip to content

fix: prevent unphysical boost in UndoAfterBurner when only one beam found - #2891

Merged
wdconinc merged 1 commit into
acts-event-data-seed-deprecated-declarationsfrom
fix-head-on-frame-particle-gun
Aug 24, 2026
Merged

fix: prevent unphysical boost in UndoAfterBurner when only one beam found#2891
wdconinc merged 1 commit into
acts-event-data-seed-deprecated-declarationsfrom
fix-head-on-frame-particle-gun

Conversation

@wdconinc

@wdconinc wdconinc commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fix MCParticlesHeadOnFrameNoBeamFX overflow for particle gun events

Stacked on: #2887 (acts-event-data-seed-deprecated-declarations)

Problem

Single-electron gun events with secondary neutrons produce extreme momentum values (~10³⁰⁸ GeV) in MCParticlesHeadOnFrameNoBeamFX, causing CI failures in capybara histogram generation:

Root Cause

The fallback logic (lines 67-75) incorrectly treats secondary hadrons from particle gun events as beam particles:

  1. Electron gun event produces secondary neutron (E=0.94 GeV) from showering
  2. Fallback finds neutron → sets hasBeamHadron=true, leaves hasBeamLepton=false
  3. Old check if (!hasBeamHadron && !hasBeamLepton) only returns if BOTH are false
  4. Code proceeds with:
    • e_beam = (0,0,0,0) (uninitialized)
    • h_beam = (0.024, 0, 0.94, 0.94) (from secondary neutron)
  5. Boost calculation: β = (-0.024/0.94, 0, -0.94/0.94) = (-0.026, 0, -1.0)
  6. β² = 1.0006 > 1 → unphysical (faster than light) → extreme Lorentz factors → 10³⁰⁸ GeV

Solution

One-character fix: Change && to || on line 98.

// Old (buggy):
if (!hasBeamHadron && !hasBeamLepton) {  // Only returns if BOTH false
  return;
}

// New (correct):
if (!hasBeamHadron || !hasBeamLepton) {  // Returns if EITHER false
  return;
}

This is consistent with the check at line 62 and prevents unphysical boost calculations.

Effect

  • Particle gun events (with or without secondary hadrons): MCParticlesHeadOnFrameNoBeamFX will be empty (no valid collision frame)
  • DIS events (both beams present): Boost transformation applied correctly as before

Testing

Verified with rec_e_1GeV_20GeV_craterlake.edm4eic.root:

  • Before fix: Events 7, 11, 61, 95 have momentum ~10³⁰⁸ GeV or NaN
  • Input MCParticles: Normal momentum ~1.4 GeV
  • Expected after fix: No extreme values (empty output collection for gun events)

Copilot AI lite review requested due to automatic review settings August 24, 2026 02:45

Copilot AI left a comment

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.

Pull request overview

This PR updates eicrecon::UndoAfterBurner to avoid unphysical boosts/rotations when processing particle-gun MC inputs, which previously could generate extreme momentum values in MCParticlesHeadOnFrameNoBeamFX and break downstream CI validation (capybara histograms).

Changes:

  • Detect presence of incoming beam lepton/hadron and add an early “identity transform” path intended for particle-gun events.
  • Remove the prior “fake beam particle” fallback logic that attempted to synthesize beam four-vectors.
  • Keep the existing boost/rotation workflow for collision events where both beam particles are found.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/algorithms/reco/UndoAfterBurner.cc Outdated
The fallback logic at lines 67-75 can set hasBeamHadron=true by
finding secondary neutrons from particle gun events, but leave
hasBeamLepton=false when the neutron energy is not in [270,280] GeV.

The old check 'if (!hasBeamHadron && !hasBeamLepton)' only returns
when BOTH are false, allowing the code to proceed with:
- e_beam = (0,0,0,0) (uninitialized)
- h_beam = (small values from secondary neutron)

This produces beta^2 > 1 (faster than light), resulting in extreme
momentum values ~10^308 GeV after Lorentz transformation.

Fix: Change && to || so we return if EITHER beam is missing.
This is consistent with the line 62 check and prevents unphysical boosts.

Root cause analysis:
- Input MCParticles have normal momentum (~1.4 GeV)
- Fallback finds neutron with E=0.94 GeV, sets hasBeamHadron=true
- e_beam stays (0,0,0,0), h_beam = (0.024, 0, 0.94, 0.94)
- beta = (-0.024/0.94, 0, -0.94/0.94) = (-0.026, 0, -1.0)
- beta^2 = 1.0006 > 1 → unphysical boost → extreme values

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wdconinc
wdconinc force-pushed the fix-head-on-frame-particle-gun branch from d9c43cb to 3e26c16 Compare August 24, 2026 03:00
@wdconinc wdconinc changed the title fix: apply identity transform for particle gun events in MCParticlesHeadOnFrameNoBeamFX fix: prevent unphysical boost in UndoAfterBurner when only one beam found Aug 24, 2026
@wdconinc

Copy link
Copy Markdown
Contributor Author

Still failed, but now likely due to having used a ref artifact that has unphysicals... https://github.com/eic/EICrecon/actions/runs/32684922352/job/97312267237?pr=2891#step:16:160

@wdconinc
wdconinc requested review from a team and veprbl August 24, 2026 13:29
@wdconinc
wdconinc merged commit e1c4e52 into acts-event-data-seed-deprecated-declarations Aug 24, 2026
51 of 64 checks passed
@wdconinc
wdconinc deleted the fix-head-on-frame-particle-gun branch August 24, 2026 13:34
@veprbl

veprbl commented Aug 24, 2026

Copy link
Copy Markdown
Member

cc @ajentsch FYI

tom-bleher pushed a commit to tom-bleher/EICrecon that referenced this pull request Sep 5, 2026
… fix UndoAfterBurner (eic#2885)

### Briefly, what does this PR introduce? Please link to any relevant
presentations or discussions.
In eic/containers#387 we bumped Acts to v46.8.1,
but this deprecates the seeding data model (as is fixed in eic#2524, but
that's now not ready for merging). Because we build some jobs with
`-Werror` we have to allow the deprecated declarations to get CI to
complete. See e.g.
https://github.com/eic/EICrecon/actions/runs/32506264064/job/97200314068#step:7:571.

This PR also includes the following stacked PRs:
- eic#2889 
This pull request updates the workflow configuration in
.github/workflows/linux-eic-shell.yml to improve control over job error
handling in the eicrecon-dis job. The main changes introduce a
continue-on-error setting to the job matrix, allowing certain job runs
(2DStrip in particular) to proceed even if errors occur.
- eic#2891 
Single-electron gun events with secondary neutrons produce extreme
momentum values (~10³⁰⁸ GeV) in MCParticlesHeadOnFrameNoBeamFX, causing
CI failures in capybara histogram generation, because the fallback logic
incorrectly treats secondary hadrons from particle gun events as beam
particles.

### What is the urgency of this PR?
- [x] High (please describe reason below)
- [ ] Medium
- [ ] Low

CI is currently broken on `main`.

### What kind of change does this PR introduce?
- [x] Bug fix (issue:
https://github.com/eic/EICrecon/actions/runs/32506264064/job/97200314068#step:7:571)
- [ ] New feature (issue #__)
- [ ] Optimization (issue #__)
- [ ] Updated parameters, constants (issue #__)
- [ ] Updated documentation
- [ ] other: __

### Please check if any of the following apply
- [ ] This PR requires changes to geometry (epic PR: __)
- [ ] This PR requires changes to EDM4eic (EDM PR: __)
- [ ] This PR introduces breaking changes. Please describe changes users
need to make below.
- [ ] This PR changes default behavior. Please describe changes below.
- [ ] AI was used in preparing this PR. Please describe usage below.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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