Fix integer truncation in cosmic livetime resampling scale factor - #1940
Conversation
resampledEvents_ / generatedEvents_ are both unsigned int, so the division truncates to floor before the float assignment. Any cosmic S2 resampling job with fewer resampled events than the mixin subrun's generated count (128,783/subrun for CosmicDSStopsCRYAll.MDC2025ab) stores CosmicLivetime = 0; otherwise the livetime is understated by up to 1/floor(ratio) (e.g. -23% for dts.mu2e.CosmicCRYAll.MDC2025ap, scaling 3.88 stored as 3). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
☀️ The build tests passed at 52ff4a0.
N.B. These results were obtained from a build of this Pull Request at 52ff4a0 after being merged into the base branch at 8ca6473. For more information, please check the job page here. |
rlcee
left a comment
There was a problem hiding this comment.
did you check for other instances of this issue in this module?
|
Yes — I swept the module. This is the only integer division in EventMixing: the only other I also checked the adjacent line: in For scale of the original problem: with |
Problem
Mu2eProductMixer::endSubRuncomputes the cosmic livetime scale factor with integer division:float scaling = resampledEvents_ / generatedEvents_;resampledEvents_andgeneratedEvents_are bothunsigned int, so the ratio is truncated to its floor before the float assignment. The resampledCosmicLivetimeproduct (instancemixed, the only livetime productS2Resampler.fclkeeps) is scaled by that floored value.Consequences, measured against
sim.mu2e.CosmicDSStopsCRYAll.MDC2025ab(GenEventCount = 128,783/subrun, S1 livetime 29.586 s/subrun):dts.mu2e.CosmicCRYAll.Run1Bandts.mu2e.CosmicCRYAll.MDC2025apAny S2 cosmic resampling with events/job below the mixin subrun's generated count stores exactly zero livetime; above it, livetime is understated by up to
1/floor(ratio). Present since c30db7e (2021).Fix
Cast before dividing:
One line; no interface change. Existing datasets can be corrected offline since the true scaling is recomputable from events/job and the S1 subrun GenEventCount.
🤖 Generated with Claude Code