Repository navigation
Add SimInfo endid and MCStepInfo originid for staged MC - #444
Merged
Merged
Conversation
A SimInfo entry for a particle that crossed a simulation stage boundary takes its start values from the first stage and its end values from a later stage, but id names only the first. Steps and calorimeter deposits carry the id of the stage piece that made them, so they could not always be linked to the entry. - SimInfo::endid: id of the SimParticle that stopCode, endpos and endmom come from. Equals id unless the particle crossed a stage boundary. - MCStepInfo::originid: id of the first-stage piece of the step's particle, so steps link to <trk>mcsim id for any number of stages. The walk back stops at a parent piece that was not kept. - fillSimInfo now takes its end values through fillSimInfoEnd. - Field comments say which piece each value comes from. - Validation histograms for both new fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oksuzian
marked this pull request as ready for review
November 8, 2026 15:28
ehrlich-uva
approved these changes
Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #443. For a particle split across simulation stages, a
<trk>mcsimentry now takes its start values from the first piece and its end values (stopCode,endpos,endmom) from a later piece, butidnames only the first piece. Steps and calorimeter deposits carry the ID of the piece that made them, so they cannot always be linked to the entry. James Mott raised this after #443.This PR adds two fields so every step can be linked:
SimInfo::endidstopCode,endpos,endmomcome from. Equalsidunless the particle crossed a stage boundary, so it also flags merged entries.MCStepInfo::originidstep.originid == mcsim.idlinks a step to its entry for any number of stages. Equalssimidfor single-stage particles. The walk back stops at a parent piece that was not kept, so it cannot throw.idkeeps its meaning (the first piece), sotrkrel,prirel, the duplicate check, RooUtil's calo matching andh_trkmcsim_idare unchanged. Primary,calomcsimandcalodigisimentries are filled from one piece, soendid == idfor them. The comments onid,endid,stopCode,endpos,endmom,simidandoriginidnow say which piece each value comes from. Validation getsh_trkmcsim_endidandh_mcsteps_virtualdetector_originid.Alternatives considered: making
idthe later piece silently changes an existing field and breaks linking for steps of the first piece. Listing each piece as its own entry breaks one-entry-per-generation, andMCRelationshipwould call the first piece a cousin (usibling) of the track particle.endidalone misses the middle pieces of particles with three or more pieces.Evidence
Built against AnalysisMDC2025 v02_03_01. Each ntuple was made with current
main(cc5a3af, which includes #443) and with this branch, from the same input. Old and new files were read in separate processes (see Merge Danger).Decay-in-flight sample (544 events, MuBeamCat Run1Bai resampled with the DS at 50% and a forced muon decay; 223
detracks from muon decay):mcsteps_virtualdetectorsteps, 878 havesimid == mcsim.idand 2127 (the steps after the stage boundary) match nomcsimentry.After:
originid == mcsim.idfor 3005/3005.endidequals thesimidof the 2127 later steps.endid != idfor exactly the 223 merged muon entries. Of all 13758 VD steps, 9563 haveoriginid == simid(single-piece particles).main.Conversion-electron sample (1000 events from
Production/Validation/ceSimReco.fcl, 359 kept,from_mcs-ceSimReco.fcl):main.endid != idfor 361 of 1892trkmcsimentries, all of them the electron's parent muon.validation/create_val_file_rooutil.Cruns on the conversion-electron ntuple, and both new histograms fill (1892 entries inh_trkmcsim_endid).For reference, what #443 changed in standard samples: in the same conversion-electron sample, the electron's parent muon (361 entries) went from
stopCodemu2eKillerVolume to muMinusCaptureAtRest, and itsendposmoved 1.27–2.08 m, from the stage boundary to the stop in the target. #443 described its reach as resampled beam particles. In practice that includes the parent muon in standard signal and background samples.Merge Danger
Door: two-way
The PR only adds fields. Existing values are unchanged.
Blast Radius: file layout
SimInfoandMCStepInfoeach gain anint. As with earlier additions to these structs (for exampleiditself), the class version stays 1. ROOT and RooUtil read old and new files. uproot reads each file on its own, but one uproot session that opens a file from before and a file from after this change fails on the nested branches (<trk>mcsim,<trk>mcvd), because both layouts are labelled version 1. The split branches (mcsteps_*,calomcsim,primary) just gain a column. Versioning these structs would be a separate, package-wide change.<trk>crv,<trk>crvxings,<trk>crvcandsand their truth) #441, which editsInfoMCStructHelper.cc.🤖 Generated with Claude Code