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.
>
> -----Original Message-----
> From: Philippe Canal [mailto:pcanal@fnal.gov]
> Sent: Monday, April 26, 2004 5:36 PM
> To: cstrato; roottalk@pcroot.cern.ch
> Subject: RE: [ROOT] Problem to copy selected entries of tree friends
>
>
> Hi,
>
> In this macro you also define a class and try to store in a TTree.
> You should compile the macro in order to use it.
>
> Cheers,
> Philippe.
>
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of cstrato
> Sent: Sunday, April 25, 2004 4:28 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] Problem to copy selected entries of tree friends
>
>
> Dear Rooters
>
> Sorry to bother you again with a version of my macro, but since
> days I am trying to find an error in my program.
>
> This is my intention:
> Having a tree fTree with friend trees, I want to copy all trees
> to a new file, but only with a subset of tree entries. Variable
> fTree should now contain the new tree with friends.
>
> The enclosed macro "macroFriends1.C" should create a new tree
> containing as entries the mean value of the corresponding entries
> of the friend trees.
>
> Running the macro ".x macroFriends1.C(0)" uses all tree entries
> to calculate the mean. It works both with CINT and ACLiC.
>
> However, macro ".x macroFriends1.C(1)", using only every second
> tree entry, crashes at different points when using CINT or ACLiC.
>
> There must be a severe mistake in my macro, but I am unable to
> detect it. It would be great if someone could tell me what the
> error may be?
>
> Thank you in advance for your help.
>
> P.S.: To give you an idea how severe the crash of my program is,
> here is part of the output that I get after calling atree->GetTitle():
> nentries(atree)= 173
> atree_title= <Test@T_(W9
> Then the xterm produces only random characters.
>
> Best regards
> Christian
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> C.h.r.i.s.t.i.a.n. .S.t.r.a.t.o.w.a
> V.i.e.n.n.a. .A.u.s.t.r.i.a
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
>
>
>
>
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET