Skip to content

Add SimInfo endid and MCStepInfo originid for staged MC - #444

Merged
sophiemiddleton merged 1 commit into
Mu2e:mainfrom
oksuzian:siminfo-endid-originid
Nov 9, 2026
Merged

sophiemiddleton merged 1 commit into
Mu2e:mainfrom
oksuzian:siminfo-endid-originid

Conversation

@oksuzian

@oksuzian oksuzian commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #443. For a particle split across simulation stages, a <trk>mcsim entry now takes its start values from the first piece and its end values (stopCode, endpos, endmom) from a later piece, but id names 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:

field meaning
SimInfo::endid ID of the piece that stopCode, endpos, endmom come from. Equals id unless the particle crossed a stage boundary, so it also flags merged entries.
MCStepInfo::originid ID of the first-stage piece of the step's particle. step.originid == mcsim.id links a step to its entry for any number of stages. Equals simid for single-stage particles. The walk back stops at a parent piece that was not kept, so it cannot throw.
 fillSimInfo(sp, siminfo)                 # id, pdg, start values
-  stopCode, endpos, endmom from sp
+  fillSimInfoEnd(sp, siminfo)            # stopCode, endpos, endmom, endid = sp.id()
 fillAllSimInfos
   fillSimInfo(first piece)
   fillSimInfoEnd(producing piece)        # from #443; now also sets endid
 fillStepPointMCInfo / fillExtraMCStepInfos
   simid    = step's piece id
+  originid = originId(step's piece)      # first piece, stops at a missing parent

id keeps its meaning (the first piece), so trkrel, prirel, the duplicate check, RooUtil's calo matching and h_trkmcsim_id are unchanged. Primary, calomcsim and calodigisim entries are filled from one piece, so endid == id for them. The comments on id, endid, stopCode, endpos, endmom, simid and originid now say which piece each value comes from. Validation gets h_trkmcsim_endid and h_mcsteps_virtualdetector_originid.

Alternatives considered: making id the 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, and MCRelationship would call the first piece a cousin (usibling) of the track particle. endid alone 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 de tracks from muon decay):

  • Before: of the parent muons' 3005 mcsteps_virtualdetector steps, 878 have simid == mcsim.id and 2127 (the steps after the stage boundary) match no mcsim entry.
    After: originid == mcsim.id for 3005/3005. endid equals the simid of the 2127 later steps. endid != id for exactly the 223 merged muon entries. Of all 13758 VD steps, 9563 have originid == simid (single-piece particles).
  • All 754 existing leaves are identical to main.

Conversion-electron sample (1000 events from Production/Validation/ceSimReco.fcl, 359 kept, from_mcs-ceSimReco.fcl):

  • All 371 existing leaves are identical to main. endid != id for 361 of 1892 trkmcsim entries, all of them the electron's parent muon.

validation/create_val_file_rooutil.C runs on the conversion-electron ntuple, and both new histograms fill (1892 entries in h_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 stopCode mu2eKillerVolume to muMinusCaptureAtRest, and its endpos moved 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

  • SimInfo and MCStepInfo each gain an int. As with earlier additions to these structs (for example id itself), 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.
  • Not covered: an ancestor that emitted the child mid-flight (for example a delta ray) in an early stage and continued into a later one still shows the end of the early piece.
  • May conflict with draft Track-CRV association branches (<trk>crv, <trk>crvxings, <trk>crvcands and their truth) #441, which edits InfoMCStructHelper.cc.

🤖 Generated with Claude Code

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
oksuzian marked this pull request as ready for review November 8, 2026 15:28
@sophiemiddleton
sophiemiddleton merged commit 2251849 into Mu2e:main Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants