From 453303544ef14a08b76b144719b237c89a98f068 Mon Sep 17 00:00:00 2001 From: Iuri Oksuzian Date: Sat, 7 Nov 2026 07:49:04 -0600 Subject: [PATCH] Take SimInfo end values from the last simulation stage In staged MC, a particle that crosses a stage boundary is split into one SimParticle per stage. fillAllSimInfos fills each generation from the first-stage SimParticle (originParticle()), so stopCode, endpos and endmom described the end of the first stage, for example a muon stopped by the killer volume at TS3, rather than the point where it decayed. Keep the start values from the first stage. Take the end values from the stage that made the track hits (generation 0) or that produced the previous generation. Particles simulated in a single stage are unchanged. Co-Authored-By: Claude Opus 5.5 --- inc/InfoMCStructHelper.hh | 1 + src/InfoMCStructHelper.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/inc/InfoMCStructHelper.hh b/inc/InfoMCStructHelper.hh index 8c500f7..151cba5 100644 --- a/inc/InfoMCStructHelper.hh +++ b/inc/InfoMCStructHelper.hh @@ -84,6 +84,7 @@ namespace mu2e { void fillStepPointMCInfo(StepPointMCCollection const& mcsteps, MCStepInfos& mcstepinfos); void fillSimInfo(const art::Ptr& sp, SimInfo& siminfo); void fillSimInfo(const SimParticle& sp, SimInfo& siminfo); + void fillSimInfoEnd(const SimParticle& sp, SimInfo& siminfo); }; } diff --git a/src/InfoMCStructHelper.cc b/src/InfoMCStructHelper.cc index c70bbfd..ea53db8 100644 --- a/src/InfoMCStructHelper.cc +++ b/src/InfoMCStructHelper.cc @@ -203,6 +203,14 @@ namespace mu2e { SimInfo sim_info; fillSimInfo(current_sim_particle, sim_info); + // In staged MC a particle is split into one SimParticle per stage. + // current_sim_particle is the first stage, so the start values above + // describe where the particle was created. Take the end values from + // current_sim_particle_ptr instead: the stage that made the track hits + // (generation 0) or that produced the previous generation (e.g. the + // muon at the point where it decayed), not the first stage, which may + // end at a stage boundary such as a killer volume. + fillSimInfoEnd(*current_sim_particle_ptr, sim_info); sim_info.trkrel = MCRelationship(current_sim_particle_ptr, trkprimaryptr); sim_info.rank = imatch; @@ -292,6 +300,13 @@ namespace mu2e { siminfo.endmom = XYZVectorF(sp.endMomentum()); } + void InfoMCStructHelper::fillSimInfoEnd(const SimParticle& sp, SimInfo& siminfo) { + GeomHandle det; + siminfo.stopCode = sp.stoppingCode(); + siminfo.endpos = XYZVectorF(det->toDetector(sp.endPosition())); + siminfo.endmom = XYZVectorF(sp.endMomentum()); + } + void InfoMCStructHelper::fillVDInfo(const KalSeed& kseed, const KalSeedMC& kseedmc, std::vector>& all_vdinfos) { std::vector vdinfos; const auto& vdsteps = kseedmc._vdsteps;