Skip to content

Warning if unsupported legacy detector signal branches are used#566

Open
cmargalejo wants to merge 5 commits into
cris_fix_event_branch_memory_leakfrom
cris_legacy_detector_signal_branch
Open

Warning if unsupported legacy detector signal branches are used#566
cmargalejo wants to merge 5 commits into
cris_fix_event_branch_memory_leakfrom
cris_legacy_detector_signal_branch

Conversation

@cmargalejo

@cmargalejo cmargalejo commented May 4, 2026

Copy link
Copy Markdown
Member

cmargalejo Large: 608 Powered by Pull Request Badge

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 TRestDetectorSignalEvent branches where TRestDetectorSignal::fSignalTime and fSignalCharge were written as vector<float>. Current detectorlib expects these members as vector<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, plain root): 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).
  • The warning now prints these two commands.

Depends on #564 (base branch).

@cmargalejo cmargalejo requested a review from nkx111 as a code owner May 4, 2026 08:17
@cmargalejo cmargalejo requested a review from AlvaroEzq May 4, 2026 08:20
cmargalejo and others added 3 commits June 12, 2026 11:41
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>
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.

1 participant