Skip to content

End the fluctuating hit chain after 1000 times the expected number of hits, as the hit chain does - #208

Merged
jbeirer merged 1 commit into
mainfrom
fluct-chain-hit-limit
Nov 24, 2026
Merged

jbeirer merged 1 commit into
mainfrom
fluct-chain-hit-limit

Conversation

@jbeirer

@jbeirer jbeirer commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

TFCSLateralShapeParametrizationFluctChain::simulate simulates hits until the relative fluctuation of the deposited energy, error2 = sum(E_hit^2) / (sum E_hit)^2, is below sigma2. A hit that the cell mapping rejects keeps zero energy and is still a success (TFCSHitCellMapping sets E = 0 beyond its boundary cut). If every hit is rejected, for example for a shower centre outside the cells of the layer, sum E_hit stays 0, error2 is never updated and the loop never ends: the simulation of the event hangs. TFCSLateralShapeParametrizationHitChain aborts its loop after 1000 times the expected number of hits; the fluctuating chain has no such limit. The bug is inherited: the loop in Athena upstream/main (ISF_FastCaloSimEvent) has no limit either. Nothing to port from Athena.

Change

  • The loop ends after 1000 times the expected number of hits (|E_layer / E_avghit|, at least 1) and at least 1000 hits, as in TFCSLateralShapeParametrizationHitChain, with a warning giving the deposited and the expected energy. The limit is computed in double, so an average hit energy near 0 cannot overflow it.
  • TFCSLateralShapeParametrization::set_calosample is exported (FASTCALOSIM_EXPORT): the code creating parametrizations calls it from outside the library, and so does the new test.
  • New FluctChainTests: a fluctuating chain with TFCSLateralShapeParametrizationHitNumberFromE and a TFCSHitCellMapping on a geometry whose only cell is far from every hit ends with FCSSuccess and no cell energy (on main it does not end).

A chain that reaches its precision ends as before, since it needs about the expected number of hits.

Checks

Run on main (73c5cc7) with #205 to #213 together, against main:

  • GCC 15 (LCG_110, developer build): 0 warnings; ctest 138/138 passed (main: 128/128), incl. the unchanged AtlasTransportTests and AtlasSimTests references
  • AtlasBenchmark dump (BENCH_N=50): byte-identical to main
  • SliceCheck on the MC23 file TFCSparam_dev_Hybrid_Ha_v5_all_baryons_0_500.root (BENCH_N=20): byte-identical to main, max RSS 4.76 GB on both
  • clang-format 20.1.8
  • GCC 16 and Clang 22 with the CI flags: 0 warnings
  • Alma 10 ci-linux (clang-tidy 21, cppcheck): 0 warnings; its ctest 138/138 passed
  • Production files: TFCSparam_AF3_MC23_Sep23.root contains no TFCSLateralShapeParametrizationFluctChain (all parametrizations walked), so production simulation is unchanged

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d43fbf5-247a-4f57-9bdb-57d35de6cea6
Commits

Reviewing files that changed from the base of the PR and between 73c5cc7 and 4af33a1.

Files selected for processing: 3

  • include/FastCaloSim/Core/TFCSLateralShapeParametrization.h
  • source/Core/TFCSLateralShapeParametrizationFluctChain.cxx
  • test/source/FluctChainTests.cxx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions github-actions Bot added the tests Issues affecting the CI tests label Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
test/source/FluctChainTests.cxx 96.96% 1 Missing ⚠️
Files with missing lines Coverage Δ
...FastCaloSim/Core/TFCSLateralShapeParametrization.h 25.00% <ø> (ø)
...Core/TFCSLateralShapeParametrizationFluctChain.cxx 60.78% <100.00%> (+60.78%) ⬆️
test/source/FluctChainTests.cxx 96.96% <96.96%> (ø)

... and 4 files with indirect coverage changes

@jbeirer
jbeirer merged commit 45e8f21 into main Nov 24, 2026
19 checks passed
@jbeirer
jbeirer deleted the fluct-chain-hit-limit branch November 24, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Issues affecting the CI tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant