feat: ALERT pre- and post-KF AI PID inference - #1368
Conversation
skuditha
commented
Jul 30, 2026
- Replaces the existing ALERT pre-PID implementation with the new AHDC- and ATOF-based TorchScript models.
- Adds post-KF PID inference for every valid ALERT::ai:projections pair.
- Writes predicted particle IDs and class probabilities to the existing ALERT AI PID banks.
…ed the feature extraction for the postpid model
There was a problem hiding this comment.
The old translator did logits.softmax(1) before toFloatArray(). Both new translators (ModelPrePID.java:290, ModelPostPID.java:84) read the raw output tensor. argmax is unaffected, so pid/prepid are fine either way, but if the exported TorchScript modules end in a Linear rather than a Softmax, then p2212/prob_2212/... are logits, and downstream users of a bank field literally named prob_* will be misled. Can you confirm the export includes the softmax?
| "AHDC::mc", "AHDC::kftrack", | ||
| "ALERT::projections", "ALERT::ai:projections", "ALERT::prePID"); | ||
| "ALERT::projections", "ALERT::ai:projections", | ||
| "ALERT::ai:prePID", "ALERT::ai:postPID"); |
There was a problem hiding this comment.
Wrong banks name: look into etc/bankdefs/hipo4/alert.json
"name": "ALERT::ai:prepid", and name": "ALERT::ai:pid"
| } | ||
| } | ||
| } | ||
| rbc.appendPIDBank(event, pidResults); |
There was a problem hiding this comment.
appendPIDBank is outside the isFinite(startTime) guard, so a zero-row ALERT::ai:pid is appended to every qualifying event. Consider if (!pidResults.isEmpty()).
There was a problem hiding this comment.
(1) Confirmed. I inspected the TorchScript graphs for both pre-PID models and the post-KF model. All three exported modules apply softmax(..., -1) inside their forward() method before returning the output tensor. Therefore, the values read by the new translators are already normalized class probabilities, not logits. Applying another softmax in Java would double-transform the probabilities, so the current translators are correct as written.
(2) Thank you! I will fix it. But it does not affect the output for some reason.
(3) Will do. Again, a zero row ALERT::ai:pid did not appear in my tests. So, there seems to be no effect.