Hi,
on your original layout: ROOT can stream
int fSize
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 model evolution.
Your second approach looks good. But read the documentation of <http://root.cern.ch/root/html/TDirectoryFile.html#TDirectoryFile:WriteObjectAny> 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 TKey.
Cheers, Axel.
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
>
Received on Mon Jan 04 2010 - 11:14:01 CET
This archive was generated by hypermail 2.2.0 : Mon Jan 04 2010 - 17:50:01 CET