Hi Sebastien, John, You cannot mix in the same TRefArray references to objects that have uids set in different sessions. In your case, there is a very simple workaround: In your job creating your original collection of tracks, create a dummy TRef referencing all the tracks in the array. This will force all the tracks to be assigned a uid with the same process id. TRef dummy; for all tracks do { dummy = trak[i]; } Then build your TRefArray of jets referencing these tracks. Rene Brun On Wed, 29 Oct 2003, Sebastien Greder wrote: > > Hello , > > Her e is what I'd like to do : > > I have 50 tracks and 10 of them in a jet. > I have a jet class which has a TRefArray referencing > the tracks. > I run over my data and build a TTree with these objects. > > Now I read again this TTree in another ROOT session and > get my referenced tracks, well ! > > Now I'd like to create new jets and reference again > some of the previous tracks to this new one. > > Unfortenatly I'm getting troubles while assigning already > referenced tracks to a new TRefArray in another ROOT session > (everything behaves nicely in the same one since it is > under the same process id control) > > I put a small code in : > > /afs/in2p3.fr/home/g/greder/public/test.tar.gz > > which is a simple version of my problem. > > You'll find in MyClass.C/h 2 classes : > > MyClass (== tracks) and MyClassRef (==jets), the latter owning a > TRefArray. > > Threre is a file MakeTree.C which creates an "event" : > > it creates a TClonesArray of MuClass objects and referenced > some of them to MyClassRef and save these guys in a ROOT file. > > A second methods reads back the file and reference these tracks > to another MYClassRef object. > > To run the code just do in a Root session : .x Compile.C > > it will print out an output that looks correct to > me. > Now quit ROOT and comment the line MakeTree(); in > Compile.C and re-run Compile.C in a ROOT session. > > The final output has changed. > > Well, this is due to the fact that it is a new ROOT > session. > > But what I'd like to understand is why the objects > in myclassref2's TRefArray have been doubled ? > > And I'd like to know how could I give the objects MyClass to > a new object MyClassRef > > It sounds to me I misunderstood something about the TRefArray > doc, but cannot figure out how to solve my pb. > > thanks, > > sebastien. >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET