Saving TObjArrays of TObjArrays of

[Moved from Root Discussion]

I have written a class structure that seems to work as intended, but I am having trouble saving it to a file in a recoverable way.

The basic object is a TObjArray (TMatrixMapArray), containing TObectArrays (TMatrixMap), containig TObjArrays (TCell) containing TOjects (TCellLink)

All classes are defined in files TMatrixMapArray.C and TMatrixMapArray.hh with the following LinkDef

#ifdef CINT

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class TCellLink+;
#pragma link C++ class TCell+;
#pragma link C++ class TMatrixMap+;
#pragma link C++ class TMatrixMapArray+;


With a shared library built and loaded into ROOT, I can successfully run a test creating a destroying TMatrixMapArray objects. However, if I try to write to a file ( ie. pMatrixMapArray->Write()) all that is stored are the TCellLink objects, with none of the more complicated TMatrixMapArray, TMatrixMap, TCell structure, and I am unable to
read it back in a new session.

btw, I would probably do better to convert the TObjArrays to STL vectors, given I am not really using their functionality, but that is for another day.

Thanks for any suggestions.

TMatrixMapArray.tar.gz (5.02 KB)

You need to call

By default for the ROOT collections in general (and TObjArray) the call to ->Write, store in the indivual objects of the collection in the TDirectory and do not store the collection itself. To store the collection you need to use the kSingleKey (and which case the collection and all its contained objects are stored together).