Skip to content

Fixes the connection between primary and secondary particles#150

Open
jdkio wants to merge 12 commits into
mainfrom
jdkio/particles_fix
Open

Fixes the connection between primary and secondary particles#150
jdkio wants to merge 12 commits into
mainfrom
jdkio/particles_fix

Conversation

@jdkio

@jdkio jdkio commented Jun 2, 2026

Copy link
Copy Markdown

Properly connects secondary particles to the parent particles in the caf, see issue #116. Also adds validation script.

# Before fix
=== validation summary ===
file: default/example-CAF.root
entries checked: 13
secondaries checked: 10426
ancestor refs resolved: 0
ancestor chain matches where CAF chain is complete: 0
errors: 10426
warnings: 0
FAIL

# After fix:
python scripts/validate_caf_truth.py fixed_secondaries/example-CAF.root 
=== validation summary ===
file: fixed_secondaries/example-CAF.root
entries checked: 13
secondaries checked: 10426
ancestor refs resolved: 10426
ancestor chain matches where CAF chain is complete: 10426
errors: 0
warnings: 0
PASS

The file sizes are not that different

3.5M    default/example-CAF.root
3.5M    fixed_secondaries/example-CAF.root

Run times are not either (note these were measured on two different days):

Original: 3m31s
Fixed: 3m29s

Note about intermediate secondaries

Secondaries are only saved if a reconstructed track warrants it. This makes sense so we're not save too much info. But this meant that some intermediate particles weren't saved. Like if a secondary neutron creates a proton track, which we reconstruct, then there was no parent to the proton in the caf. Below is the result of the validation if we don't save the interemediate particles. The fix was to save the intermediate particles. It's a more general and stable solution than trying to link the secondary to the primary. Currently the unreco'd particles are not individually flagged but we could add that if need be.

python scripts/validate_caf_truth.py particle_fix/example-CAF.root 
=== validation summary ===
file: particle_fix/example-CAF.root
entries checked: 13
secondaries checked: 7680
ancestor refs resolved: 7680
ancestor chain matches where CAF chain is complete: 5279
ancestor refs not independently checkable because CAF parent is missing: 2401
trace_missing-parent: 2401
errors: 0
warnings: 0
PASS

Files touched

src/truth/FillTruth.cxx
.gitignore

Files added

scripts/validate_caf_truth.py

@chenel chenel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great implementation, and I'm especially happy to see the validation script---that'll be a big win in the future if/when we have to check whether future changes break anything. I'm happy to approve.

There are a few nits recorded below, with one possible edge-case bug that I'd like your further opinion on.

Comment thread src/truth/FillTruth.cxx Outdated
Comment thread src/truth/FillTruth.cxx Outdated
Comment thread src/truth/FillTruth.cxx Outdated
Comment thread src/truth/FillTruth.cxx Outdated
@chenel

chenel commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Okay---sounds good. In that case, if you have the check already instrumented, it might even be worth contemplating whether we should make it an abort, so we know to go figure out what happened?

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.

2 participants