Re: [ROOT] Persistency of custom container
Axel Naumann <Axel.Naumann <at> cern.ch>
2010-01-04 10:16:01 GMT
on your original layout: ROOT can stream
T* fArray; //[fSize]
even without a custom streamer.
You should avoid writing custom streamers; they will obviously disable
memberwise streaming, splitting, and (automatic and non-automatic) data
Your second approach looks good. But read the documentation of
which states that you'll need to use v.
I assume you want to store these things in a TTree - you might want to
test that directly; the behavior (of member access e.g. in the TBrowser)
is slightly different for objects stored in TTrees and those stored in a
Roel Aaij wrote on 01/03/2010 09:27 PM:
> Hi Axel,
> I've continued my exercise and have created a new container that is
> essentially a thin wrapper around an std::vector< TYPE* >. I've called
> my class DataStdVector and generated a reflex dictionary for it.
> DataStdVector inherits from DataObject. I also have a class Track, which
> inherits from DataObject. I want to store these in my DataStdVector and
> write the collection to a file.
> I would like to write my vector to the file using a pointer to
> DataObject, so is the following supposed to work?
> DataStdVector< Track >* v = new DataStdVector;
> Track* t = new Track( 1, 1000 );
> v->push_back( t );
> DataObject* d = v;
> TFile f( "test.root" )
> f.WriteObjectAny( d, "DataStdVector<Track>", "Tracks" );
> If I load and enable Cintex and open the file, I can read the object,
> but there are no tracks in the container. If I replace the last line by:
> f.WriteObjectAny( v, "DataStdVector<Track>", "Tracks" );
> It works.
> As a sidenote, DataObject contains a pointer to the container that
> contains it. I've declared this data member transient in my
> selection.xml file.
> Greetings, Roel