Warning if unsupported legacy detector signal branches are used#566
Open
cmargalejo wants to merge 5 commits into
Open
Warning if unsupported legacy detector signal branches are used#566cmargalejo wants to merge 5 commits into
cmargalejo wants to merge 5 commits into
Conversation
for more information, see https://pre-commit.ci
REST files written with TRestDetectorSignal ClassDef < 4 store fSignalTime/fSignalCharge as vector<Float_t>. Since restManager output files do not contain the event-class StreamerInfos, ROOT cannot apply schema evolution and misreads the float payload as doubles, making the detector signal branch unreadable (detectorlib#125). The data is intact on disk and fully recoverable: - macros/legacy/recoverLegacySignalData.C (stage 1, run with plain root): reads the signal branch using replica classes that match the legacy on-disk layout exactly and extracts the data to an intermediate file. Deliberately not named REST_*.C so restRoot's macro loading never interprets the replica class definitions. - macros/legacy/REST_RebuildLegacySignalFile.C (stage 2, run with restRoot): writes a new file with the signal branch rebuilt using the current classes, all other event branches and the AnalysisTree copied, metadata keys preserved, and the event-class StreamerInfos stored this time. Optional in-place overwrite keeps a .bak copy. The on-disk layout is detected via TBranchElement::GetClassVersion() on the fSignal sub-branches; files already at version 4 are skipped. Verified on R00236 (V2.4.0, 261 entries): 19750 signals and 447902 points recovered bit-exact; the rebuilt file reads back correctly via TRestRun with the current vector<Double_t> classes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
This was referenced Jun 12, 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.
This PR is built on top of #564 and should be reviewed/merged after #564 (I keep it separate because maybe we don't want to change TRestRun.cxx even more just to print a warning).
It mitigates rest-for-physics/detectorlib#125, but it's not a real fix. It just avoids crashing.
Some old files contain
TRestDetectorSignalEventbranches whereTRestDetectorSignal::fSignalTimeandfSignalChargewere written asvector<float>. Current detectorlib expects these members asvector<double>after detectorlib#109.This PR detects that unsupported branch, prints a warning, and disables only that signal event branch. Other events types remain readable.
Update
This PR now also includes the solution, not just the warning:
macros/legacy/recoverLegacySignalData.C(stage 1, plainroot): extracts the legacy float signal data using replica classes matching the old on-disk layout exactly.macros/legacy/REST_RebuildLegacySignalFile.C(stage 2,restRoot): writes a fixed file with the signal branch rebuilt using the current classes, all other branches/metadata copied, and StreamerInfos stored this time. Optional in-place overwrite (keeps a.bak).Depends on #564 (base branch).