Re: [ROOT] Problem to copy selected entries of tree friends (additional info)

From: cstrato (cstrato@aon.at)
Date: Wed Apr 28 2004 - 20:01:02 MEST


Dear Philippe

Thank you for your response.
It is good to know that the data object is deleted by the
TTree object. I was checking the source code but could not
find where it is deleted. Is this already documented somewhere?
If not, maybe it would help if this would be mentioned, e.g.
in the description of TTree::Branch()?

Best regards
Christian

Philippe Canal wrote:
> Hi Christian,
> 
> The TTree object should be deleting the data object.
> 
> 
>>ad a) I apologize, but I disagree with you completely. The nice
> 
> 
> Well I was too strong in my wording.  What I recommend is that
> unless you script is trivial, you should check the syntax and
> the proper working of your script by compiling it (and you
> are already doing so :) ).
> 
> 
>>ad b) When you check the valgrind website you will realize that
>>the Macintosh version is not yet ready, sorrowly.
> 
> 
> Yes indeed, I forgot that you are running on a MacOS machine :(
> 
> I wonder if there is a similar tool for MacOS X.
> 
> Cheers,
> Philippe.
> 
> -----Original Message-----
> From: cstrato [mailto:cstrato@aon.at]
> Sent: Tuesday, April 27, 2004 2:59 PM
> To: Philippe Canal
> Cc: roottalk@pcroot.cern.ch
> Subject: Re: [ROOT] Problem to copy selected entries of tree friends
> (additional info)
> 
> 
> Dear Philippe
> 
> Thank you, this solves my problem, and I understand the reason.
> However, I am not sure: Is "data" deleted when the tree is deleted
> or do I have to delete "data" later?
> (It is not quite clear to me how I should accomplish this?
> Should I create a "TList *fTrash", and add the "data" to fTrash
> and delete fTrash in the destructor?)
> 
> Regarding your recommendations:
> ad b) When you check the valgrind website you will realize that
> the Macintosh version is not yet ready, sorrowly.
> ad a) I apologize, but I disagree with you completely. The nice
> thing of CINT is that normally you do not need to compile your
> macros, and usually the user should be able to run his/her macros
> w/o the need to compile them.
> (I know that even such a nice achievement as CINT has certain
> limitations, and I am always testing my macros with ACLiC, too.)
> 
> Philippe Canal wrote:
> 
> 
>>Hi Christian,
>>
>>In addition you do:
>>      tmptree->Branch("DataBranch", "MyData", &data, 64000, split);
>>
>>      for (Int_t i=0; i<nentries; i++) {
>>         // Test: filter mask!!!!
>>         if (i%2) continue;
>>
>>         treej[j]->GetEntry(i);
>>         data->SetID(dataj[j]->GetID());
>>         data->SetX(dataj[j]->GetX());
>>//if (i<4) cout << "i= " << i <<  " j= " << j << "  data= " << data->GetX() << endl;
>>         tmptree->Fill();
>>      }//for_i
>>
>>      tmptree->Write();
>>
>>      if (j == 0) {
>>         newtree = tmptree;
>>      } else {
>>         newtree->AddFriend(tmptree, alias.Data());
>>      }//if
>>
>>	delete data;
>>
>>The last delete data is invalid since tmptree still relies on it!
>>
>>In general I would recommend that you
>>	a) always compile your macros
>>	b) run valgrind (http://valgrind.kde.org) on the macro each time you have
>>a problem.
>>
>>Cheers,
>>Philippe.
>>



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET