Skip to content

Commit 288a580

Browse files
zhaozhiwenclaude
andcommitted
Normalize run data once, not once per run streamer
publish_run_data called normalize_run_data inside the per-streamer loop. normalize_run_data mutates the shared run_data_collaction in place (replacing each normalized observable with value/events_processed) and is not idempotent, so with two or more run-mode streamers the second streamer published value/N^2, the third value/N^3, and so on. Hoist the normalization out of the loop so it runs exactly once per run regardless of streamer count. Fixes #105 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 48f83e5 commit 288a580

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

gemc/actions/run/gRunAction.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,17 @@ void GRunAction::publish_run_data(const std::shared_ptr<GRunDataCollection> &run
256256
" no run streamer map available - run data will not be published.");
257257
}
258258

259+
// Normalize once, before publishing: normalize_run_data() mutates run_data_collaction
260+
// in place and is NOT idempotent, so running it per streamer would divide the run
261+
// observables by events_processed once for every configured run streamer.
262+
normalize_run_data(run_data_collaction);
263+
259264
for (const auto &[name, gstreamer]: *gstreamer_run_map) {
260265
if (gstreamer == nullptr) {
261266
log->error(ERR_STREAMERMAP_NOT_EXISTING, FUNCTION_NAME,
262267
" null gstreamer instance for run streamer ", name);
263268
}
264269

265-
266-
normalize_run_data(run_data_collaction);
267-
268270
gstreamer->publishRunData(run_data_collaction);
269271
}
270272
}

0 commit comments

Comments
 (0)