Re: [ROOT] 2 TTree questions

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Jun 21 2003 - 07:39:43 MEST


Hi Pierre-Luc

On Fri, 20 Jun 2003, Pierre-Luc Drouin wrote:

> Hello,
> 
> I have 2 TTree questions:
> 
> -First, I would like to know how I can fill Tree branches separately (all
> the branches will have the same number of events at the end).

In principle, you can do this by calling TBranch::Fill for each branch.
However, the number of entries in the Tree will not be incremented
if you do this. A TTree::SetEntries function could be added (see logic
in TTree::Fill).
I cannot understand why you would like to do branch fills and not tree 
fill.
Note that you can always make as many Trees as you have branches, fill
each Tree separately and then use the TTree::AddFriend function
to make a super logical Tree with all these Trees.

> 
> -I would like to know how I can TTree::Draw into a TTree, I mean that I
> TTree::Draw with a varexp expression and I want to put the result in a
> new TTree. Is to TTree::GetVar and then to TTree::Fill the most efficient
> way to do that?

This is easy to do. 
  TH1F *hdraw = 0;
  mytree.Branch("histo","TH1F",&hdraw, 8000,0); //use no split mode
then for each entry

   hdraw = new TH1F("hdraw","tile",....)
   anothertree.Draw("var>>hdraw","some selection");
   mytree.Fill();

or if you want to use the default htemp histogram
   anothertree.Draw("var");
   hdraw = (TH1F*)gPad->GetPrimitive("htemp");
   mytree.Fill();

Rene Brun

> 
> Thank you!
> 
> Pierre-Luc Drouin
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET