Dear @pcanal
It seems we have had a similar discussion before: Read object from TBranch using new custom streamer
There, as here, the problem was objects written in TTrees with automatic streamers with missing version information. At the time (2016), this was declared a bug and promptly fixed (in 5.34)! It seems there has been a regression? (I have checked that I have exactly the same problem with the tip of the 5.34 branch as with the master).
Meanwhile, I found a very very small doc about I/O customization in the Users Guide chapter on I/O, and I’m trying to use it. The good news is that setting a “version=[-3]” flag works here, i.e. only for versions up to 3 does the rule print up a message (code={ std::cout << “coucou” << std::endl; }"), so I should be able to handle the backwards compatibility. However I can’t figure out how to do it.
I have objects on file like this:
class KVSimEvent : public KVEvent
{
ClassDef(KVSimEvent, 3)
};
class KVEvent : public TObject
{
TClonesArray* fParticles;//->
KVNameValueList fParameters;
ClassDef(KVEvent,4)
};
and I want to read them back into objects like this:
class KVSimEvent : public event<KVSimNucleus>
{
ClassDef(KVSimEvent, 4)
};
template <typename Nuc>
class event : public KVBaseEvent {};
class KVBaseEvent : public TObject
{
TClonesArray* fParticles;//->
KVNameValueList fParameters;
};
So basically the size and layout hasn’t changed and when I see a KVSimEvent on disk with version<4 I should stream the TClonesArray and KVNameValueList objects from the buffer into KVBaseEvent::fParticles and KVBaseEvent::fParameters inside my new KVSimEvent object.
I have tried to do it like this:
#pragma readraw \
sourceClass="KVSimEvent" \
source="" \
version="[-3]" \
targetClass="KVSimEvent" \
target="TClonesArray* KVBaseEvent::fParticles; KVNameValueList KVBaseEvent::fParameters" \
code="\
{\
KVBaseEvent::fParticles->Streamer(buffer);\
KVBaseEvent::fParameters.Streamer(buffer);\
}";
but I just get warnings from rootcint/cling that
WARNING: IO rule for class KVSimEvent data member: TClonesArray* KVBaseEvent::fParticles; KVNameValueList KVBaseEvent::fParameters was specified as a target in the rule but doesn't seem to appear in target class
and no code is generated in the dictionary.
Can anybody help?