Schema evolution for GenVector class

Hello all,

I have a class with a data member fMomenta of type std::vector<ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>> (with the default coordinate system template type ROOT::Math::DefaultCoordinateSystemTag), which I have written to ROOT trees.

Well, it turns out it was a mistake: since the 3D vectors in that container are represented in the global coordinate system, they should each have been of type ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>,ROOT::Math::GlobalCoordinateSystemTag>.
So I put the amenities to generate the dictionary for the “new” type.
The problem is that my attempt to read files with the old data type is frustrated by:

Cannot convert fMomenta from type: vector<ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>,ROOT::Math::DefaultCoordinateSystemTag> > to type: vector<ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>,ROOT::Math::GlobalCoordinateSystemTag> >, skip element

The checksum of the class seems to be the same as the old one (in fact, the representation on disk and memory has not really changed). I think the problem is that there is no constructor from ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>,ROOT::Math::DefaultCoordinateSystemTag> to ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>,ROOT::Math::GlobalCoordinateSystemTag>, (and maybe also the lack of constructors at std::vector level would be a problem?).
I don’t know how to write an I/O rule, which would be the natural “solution”, because the old and the new class have the same checksum.
Replacing std::vector<> with a special container and shove it in the throat of the users for years just to make schema evolution work is more than I am comfortable with.
Forcing a change in the checksum with some other trick may be interesting – I don’t know whether it would work, and what the trick might be.
Is there any real solution?

Hello Hamlet,

first of all, make sure that you have enabled the schema evolution for the class that contains the vector.
If you are using GenReflex, that is achieved adding ClassVersion="10" to its <class /> tag.
Then the change you refer to should be automatically detected, generating a new version of that class.
That will in turn allow you to specify whatever I/O rule you need there.

Thank you, it works!
You’re a smart one.

Well, not really… :roll_eyes:

(I apologise for this act… in short, I found out where my problem was)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.