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..824d9fb 100644 --- a/src/InfoMCStructHelper.cc +++ b/src/InfoMCStructHelper.cc @@ -487,6 +487,12 @@ namespace mu2e { SimInfo siminfo; fillSimInfo(edep.sim(), siminfo); siminfo.index = csis.size(); + // Walk the Geant4 parent chain and store all ancestor SimParticle IDs + auto currentPtr = edep.sim(); + while (currentPtr->hasParent()) { + currentPtr = currentPtr->parent(); + siminfo.ancestorSimIds.push_back(currentPtr->id().asInt()); + } csis.push_back(siminfo); } }