Hi Stefan, stefan kluth wrote: > > Hello, > > As far as I understand, the normal procedure for ROOT when reading objects > e.g. of type A in a TObjectBranch of a TTree is to delete the previous > object pointed to by the pointer contained in TObjectBranch::fAddress and > creating a new object using its default ctor A::A(). Then it is filled > using the Streamer member function of the object A::Streamer(...). This will work if users make sure to delete all objects and basic types allocated via new in the Streamer function itself. I cannot introduce this functionality by default, too many people will complain. However, I could introduce an option (at the branch or tree ? level) to tell Root that it should not delete the object before invoking Streamer. What about TTree:SetAutoDelete(Bool_t mode=kTRUE) ? Note that in case of split mode, this is already the case. The top level object is never deleted. > > Is it possible to arrange it so that ROOT does not delete the existing > object, and just calls the Streamer A::Streamer again to overwrite the > contents? > > This should work ok for objects with "constant memory footprint", i.e. > those which don't allocate memory from the heap themselves. > > One interesting application would be that one could have several > TObjectBranch'es holding the *same* type of objects, which in turn contain > non-static pointers to TClonesArrays holding identical types of objects. I am not sure I understand what you mean precisely without giving an example. > > Currently, one can only have one TObjectBranch containig objects with > a static pointer to one TClonesArray to reuse memory. If one would have > several branches, reading the next branch would overwrite the data from a > previously read branch in the one shared TClonesArray. > > For example, one could read several TObjectBranches of the Event > class containig different events. Of course, one would not do this with an > "event", but one could imagine storing and retrieving several objects of > the same type containg lists of e.g. tracks reconstructed in different > ways. \ You can already do this by either swapping pointers or calling tree->SetBranchAddress. Rene Brun
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET