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;