Changing TH2F * to TH2 * in class with backwards compatiblit

Hi,

I apologize if this was answered somewhere else (I couldn’t find it…).

I have an object where I want to change one member from TH2F to TH2 to be more general (and support TH2S’s, for example). If I understand the automatic schema evolution documentation, than this should work (“Move a data member to a base class or vice-versa.”) but I get a crash when reading the old files (where the histogram is stored as a TH2F).

Is this supposed to work, or is something else wrong? I guess because TH2F has two base classes that may be a problem?

I can think of a way to work around it (having a different pointer for each type and figuring out which one is non-zero) if this isn’t supported.

-Cosmin

Hi,

[quote] (“Move a data member to a base class or vice-versa.”) [/quote]This refers to the ability to move the data member ('TH2F* fPtr) from its original place (your object) to one of the base class of your object. So if you have:class Top { }; class Object : public Top { TH2F *fPtr; };you can transform it to[code]class Top { TH2F *fPtr; }; class Object : public Top { };

You should not get a crash but instead should get:Warning in <TStreamerInfo::BuildOld>: Cannot convert Object::h from type:TH2F* to type:TH2, skip elementand indeed what you are trying to do is not yet explicitly supported. However you can write a simple schema customization rule that enable supports for it:#ifdef __MAKECINT__ #pragma read sourceClass="Object" targetClass="Object" version="[-5]" source="TH2F *fPtr" target="fPtr" code="{ fPtr = onfile.fPtr; }" #endif

Cheers,
Philippe.