Hello ROOT Forum,
I’m having trouble handling backwards compatibility for some of my classes after a recent evolution in their inheritance. I used to have two classes, Event and OtherEvent, with an inheritance like this (class version numbers in brackets):
Base(1) < Event(4) < OtherEvent(3)
I have a lot of data written with these class versions. Now I want to change the structure using a new templated base class with the following inheritance:
Base(1) < BaseEvent(1) < ETempl<T>(1)
and the inheritance of the two previous classes becomes (with new class versions):
ETempl<Nuc> < Event(5)
ETempl<OtherNuc> < OtherEvent(4)
When I try to read some old data using the new classes, I expect to need to manually tweak the Streamers if the automatic schema evolution fails (which is the case with my real world problem for OtherEvent, although not for Event). However, this relies on being able to read the class versions in a file and act accordingly, and this is not happening. The data is stored as objects of the classes contained in an unsplit branch of a TTree. If I read an old object which was simply written to a TFile (not in a TTree), the custom streamers in my new classes recognize correctly the class versions:
auto event = f.Get<Event>("event");
Info in <Event::Streamer>: On-file version = 4
auto oevent = f.Get<OtherEvent>("other_event");
Info in <OtherEvent::Streamer>: On-file version = 3
But not when reading the objects from the TTree written in the same file:
auto tree = f.Get<TTree>("tree");
tree->SetBranchAddress("events",&event);
tree->SetBranchAddress("other_events",&oevent);
tree->GetEntry(0);
Info in <Event::Streamer>: On-file version = 1
Error in <TClass::RegisterStreamerInfo>: Register StreamerInfo for Event on non-empty slot (5).
Error in <TBufferFile::CheckByteCount>: object of class ETempl<Nuc> read too few bytes: 6 instead of 20
Info in <OtherEvent::Streamer>: On-file version = 4
Error in <TBufferFile::CheckByteCount>: object of class EBase read too few bytes: 6 instead of 20
I have attached the simplest possible example to demonstrate. Instructions are included.
I would be grateful for any help!
Cheers
Johnexample.tgz (1.8 KB)
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.23/01 (master)
Platform: Ubuntu 20.10
Compiler: g++10.2.0