diff --git a/inc/SimInfo.hh b/inc/SimInfo.hh index 81af4f1..dd2b276 100644 --- a/inc/SimInfo.hh +++ b/inc/SimInfo.hh @@ -29,6 +29,7 @@ namespace mu2e XYZVectorF endpos = XYZVectorF(); // end position of the SimParticle [mm, in detector coords] MCRelationship prirel = MCRelationship(); // relationship to the event primary particles MCRelationship trkrel = MCRelationship(); // relationship to the particle that created hits in the track + std::vector ancestorSimIds; // full parent chain: [parentId, grandparentId, ..., rootId] void reset() { *this = SimInfo(); } }; } diff --git a/src/InfoMCStructHelper.cc b/src/InfoMCStructHelper.cc index 61fb2e5..5bae4c0 100644 --- a/src/InfoMCStructHelper.cc +++ b/src/InfoMCStructHelper.cc @@ -289,6 +289,15 @@ namespace mu2e { siminfo.pos = XYZVectorF(det->toDetector(sp.startPosition())); siminfo.endpos = XYZVectorF(det->toDetector(sp.endPosition())); siminfo.endmom = XYZVectorF(sp.endMomentum()); + // Walk the Geant4 parent chain and store every ancestor's SimParticle id + // (immediate parent first, root last). Populated here so every SimInfo + // collection (trkmcsim, calomcsim, primary list) exposes the same + // ancestorSimIds branch consistently. + auto p = sp.parent(); + while (p.isNonnull()) { + siminfo.ancestorSimIds.push_back(p->id().asInt()); + p = p->parent(); + } } void InfoMCStructHelper::fillVDInfo(const KalSeed& kseed, const KalSeedMC& kseedmc, std::vector>& all_vdinfos) {