Re: Strange behavior of TBranch::Fill

From: Antonio Bulgheroni <antonio.bulgheroni_at_gmail.com>
Date: Thu, 19 Jul 2007 14:22:54 +0200


Dear Philippe,

   thanks for your reply.

The problem is that in my case I really don't need to have all branches filled with the same number of entries. The example I sent around was oversimplified: in my real life case I have several branches, none of them is empty of course, but they for sure have different number of entries, at least this is what I would like to have!

I will try to find another solution....

thanks again!

Cheers,
Antonio

-- 
Antonio Bulgheroni, PhD

Computers have a lot in common with air conditioners:
Once you open WINDOWS, they stop working properly.

On 7/19/07, Philippe Canal <pcanal_at_fnal.gov> wrote:

>
> Hi Antonio,
>
> This is the expected behavior of your code. In you branch->Fill case, the
> tree is never informed that it has any entries ... and hence the tools
> (TBrowser, etc..) thinks the tree is empty. For most of the tools, it is
> important that each branch to be filled with the
> same amount of entries (because they match entries by their sequential
> order
> in the branch).
>
> You can 'fix' a TTree after being filled by your branch->Fill method by
> calling 'tree->SetEntries()' but it will complain if one of the branch has
> less entries than the other.
>
> You can also use SetBranchStatus(brname,0) and tree->Fill to prevent the
> filling of individual branches.
>
> > I don't need (and don't want) to fill all branches,but I would like to
> indivually fill only branches I'm interested in.
>
> Why? What do you want to represent with the 'empty' branch? Wouldn't it
> be
> better to __not__ add the branch to the TTree.
>
> You may want to consider replacing the
> TBranch * branch2 = tree->Branch("calib2.", &calib2, 8000, 1);
> by
> vector<Calib> *vec;
> TBranch * branch2 = tree->Branch("calib2.", &vec, 8000, 1);
> where the vector would be filled or not.
>
> You may also want to replace both branch with a single vector with one of
> more object in it,
> depending on the semantic.
>
> Cheers,
> Philippe.
>
> ________________________________
>
> From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
> On Behalf Of Antonio Bulgheroni
> Sent: Thursday, July 19, 2007 1:55 AM
> To: ROOT Talk
> Subject: [ROOT] Strange behavior of TBranch::Fill
>
>
> Dear ROOTers,
>
> I would like to report you the strange behavior of the TBranch::Fill
> compared to the TTree::Fill. In my real life case I have a TTree with
> several branches; I don't need (and don't want) to fill all branches,but I
> would like to indivually fill only branches I'm interested in. For this
> reason, I'm getting from the TTree the branch I need, I'm setting the
> address of the TBranch to a local variable and finally I call
> TBranch::Fill(). Everything is working fine but the tree browser, indeed
> if
> I browse the TTree and double click on a leaf instead of drawing the leaf
> content on a canvas, nothing is happening.
>
> I discovered that if I replace the TBranch::Fill call with a TTree::Fill,
> the tree broswer is working again, but every time I have
> all branches filled. Here attached a simplified example, calib.h and
> calib.cxx contain the class defining the branch content, and test.C a
> simple
> macro to fill in a tree using in one case TBranch::Fill and in the other
> TTree::Fill.
>
> Is this the correct behavior? If so, is there any workaround to have
> branches browsable and individually fillable? I played a bit with the
> branch status, but unsuccessfully.
>
> Thanks in advance.
>
> Cheers,
> Antonio
>
> Tested on the following configurations:
>
> ROOT 5.15/08 + Linux (Fedora 7) + g++ 4.1.2
> ROOT 5.13/04 + SLC 4 + g++ 3.4.6
> ROOT 5.10/00e + SLC 3
> --
> Antonio Bulgheroni, PhD
>
> Computers have a lot in common with air conditioners:
> Once you open WINDOWS, they stop working properly.
>
>
Received on Thu Jul 19 2007 - 14:23:04 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 19 2007 - 17:50:02 CEST