Hi Ben, You need to use something like: Thing *daugtherThing= (Thing*)ThingTriplet[nd]->CloneThing->At(i); MyThing = new((*CloneThing)[numThings]) Thing( *daugtherThing); numThings++; The TClonesArray has to be the one calling the memory allocation of its content (hence you can not put the result of Clone inside a TClonesArray). Cheers, Philippe. The code you currently have enabled those not 'append' the TClonesArray but keep track of only the last copy. (I.e. was you should see is that you always get only the last daughter's 'things') Also the branch 'numThings' is duplicating information already in the 'CloneThing' branch. -----Original Message----- From: Ben Kilminster [mailto:bjk@fnal.gov] Sent: Friday, April 09, 2004 1:43 PM To: Philippe Canal Cc: roottalk@pcroot.cern.ch; Rene Brun Subject: Re: [ROOT] TClonesArray gathering > I do not understand the logic in your test program. > Nowhere you fill the TClonesArray. > I had to make a few changes to compile your code. See attached tar > file. > The results correspond to what I expect from the code. > As I am now leaving for 2 weeks, I suggest you communicate directly > with Philippe to make progress. Hi, The basic logic is that I want to take several TClonesArrays and merge them together, and put them in a TTree. Here are the steps. 1) Several "Daughter" objects have TClonesArrays of "Thing" objects. 2) The Parent makes a tree of all of the "Thing" objects. Here is how I implemented it: 1) In the Parent code, I call Daughter::Want(int val) several times for each Daughter object. 2) Daughter::Want(int val) adds a Thing to its TClonesArray of Things : MyThing = new ((*CloneThing)[GotAThing]) Thing; 3) At the end of the Parent code, the Parent loops over all the Daughters, and adds all the Thing objects to a Tree. Here is the problem: 1) The parent is able to get the number of Things from each Daughter. (ie, I am able to pass an integer from the Daughter object to the Parent object). 2) The parent is unable to merge multiple TClonesArrays together. And it is unable to put them in a tree. I tried two ways: getting a pointer to each Thing in each of the Daughter's TClonesArrays, and getting a pointer to each TClonesArray of Things and combining these. I'll bet that I am just not referencing the TClonesArrays properly. Sorry if it wasn't clear before, I hope this is better. It was probably my geeky coding analogy of the Parent - Daughter relationship that made it tough to follow. Ben
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET