From 52ff4a0ddc81c60ab80ad17edc24871f0c6c235c Mon Sep 17 00:00:00 2001 From: Iuri Oksuzian Date: Mon, 24 Aug 2026 11:09:15 -0500 Subject: [PATCH] Fix integer truncation in cosmic livetime resampling scale factor 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 --- EventMixing/src/Mu2eProductMixer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventMixing/src/Mu2eProductMixer.cc b/EventMixing/src/Mu2eProductMixer.cc index 620f96f859..6edf1d18fc 100644 --- a/EventMixing/src/Mu2eProductMixer.cc +++ b/EventMixing/src/Mu2eProductMixer.cc @@ -236,7 +236,7 @@ namespace mu2e { } if (mixCosmicLivetimes_) { if(generatedEvents_ == 0)throw cet::exception("BADINPUT")<<"Mu2eProductMixer: generated event count =0; was the mixin file opened correctly?" << std::endl; - float scaling = resampledEvents_ / generatedEvents_; + float scaling = static_cast(resampledEvents_) / static_cast(generatedEvents_); auto livetime = std::make_unique(totalPrimaries_ * scaling, area_, lowE_, highE_, fluxConstant_, livetime_ * scaling); sr.put(std::move(livetime), subrunLivetimeInstanceName_, art::fullSubRun());