Hi Thomas,
In your case 1, TTree::Draw is smart enough to read only the branches
having leaves in the query.
In your case 2, if you call TTree::GetEntry (or same with TChain::GetEntry),
by default you read all branches.
You can get the same speed as in case 1 in the following way:
You call SetBranchStatus, eg
chain.SetBranchStatus("*",0); // disable all branches
chain.SetBranchStatus("fImpact",1);
chain.SetBranchStatus("fEnergy",1);
//assuming that fImpact and fEnergy are the names of your branches.
chain.GetEntry(num);
You can also look at an alternate (AND RECOMMENDED WAY) using the TSelector
mechanism. We have an example at $ROOTSYS/tutorials/h1analysis.C
See also the Users Guide.
Rene Brun
Thomas Bretz wrote:
>
> Hi Rene,
>
> mhh... when I understand you correctly, this means, that also TTree:Draw
> cannot read only one leaf. I thought this is the reason for the
> following, seems that it isn't. So let me ask a different question:
> I have two branches in our tree. One of this branches earnes the leafes
> 'fImpact' and 'fEnergy', the other one 'fNumFirstLevel'.
> If I open the tree with the help of TChain I have two possibilities to
> get what I want (fill the TH2D objects All_showers and Trigger_effi):
> 1) calling
> chain.Draw("fImpact/100.:log10(fEnergy)>>All_showers");
> chain.Draw("fImpact/100.:log10(fEnergy)>>Trigger_effi","fNumFirstLevel>0");
>
> 2) Enable the branches by TBranch::SetBranchAddress
> Loop over all Events in the trees using TChain::GetEntry(num++) and
> filling two histograms using TH2D::Fill
>
> The first method is more than 10 times faster than the second one.
> Because of some reasons I would like to use the second one (calling
> TH2D::Fill event by event). What is the reason for this huge difference
> in speed? What makes chain.Draw _so_ fast?
>
> Thanks for your help,
> Thomas.
>
> Rene Brun wrote:
> > You cannot do this. I/O is at the branch level not the leaf.
> > There is one buffer (basket) per branch.
> > Recipee: make a leaf a branch
>
> > Thomas Bretz wrote:
> > > I enabled a branch of my TCHain object by TChain::SetBranchAddress. Now
> > > I'm trying to disable some of its leafs, so that only the variables I
> > > need are read in. How do I do this correctly? I tried using
> > > TChain::GetLeaf->SetAddress(0) but this failed.
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:03 MET