RE: (no subject)

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 01 Dec 2005 11:20:46 -0600


> I do not think that this is a bad idea to have different numbers of
entries for different branches

In the strict sense, it is very bad because then there is NO way to correlate
the information belong to the same 'event' store in different branches. However I think there is some confusion on the name. You mentioned:

> By the way this kind of TChain is already implemented in root
TTree::MakeClass() method
> where root splits the TTree obtained after conversion from the PAW ntuple
into individual
> branches each of them having different number of entries.

This is __very__ different from you did. Each branch have the same number of
'entries' (in other word, the exact same number of call to Fill). However each Fill store more than one value. So for each entry in a branch there is possibly more than one value. The typical use is for example an event where you have one value for the EventNumber and an Array (std::vector or TClonesArray or something else) of Tracks. In this example you would have 2 branches (one for the EventNumber, one for the array of Tracks).
You would call Fill only once per Event. This would call Fill once for each branch, which will store one object per event. It just so happens that semantically the object in EventNumber has only one value for this event, while the object in Tracks (the array) has several values.

Cheers,
Philippe.

-----Original Message-----
From: Dmitry Naumov [mailto:naumov_at_nusun.jinr.ru] Sent: Friday, November 25, 2005 2:31 AM
To: Philippe Canal
Cc: 'Rene Brun'; roottalk_at_cern.ch
Subject: Re: [ROOT] (no subject)

Dear Phillipe,

Thank you for this information. Therefore this is the expected behaviour for TTree with unevenly filled branches. I do not think that this is a bad idea to have different numbers of entries for different branches - because this looks to me just reasonable for the experimental situation: TTree with a branch of events, branch of data taking parameters (which are not much different for each event - thus why they should be another TTree?), branch with calibration data, etc. Otherwise what you say is equivalent to say that
TTree is assumed to have basically only one TBranch. Then why to make two different objects TTree and TBranch?

In fact I do see any problem why doing TChain of TTree with some branches can not simply take into account that each branch may have its own number of entries and make the TChain of each branch?

I understood your answer that TBranch is linked only to the current TTree, but it looks to me not so bad idea to let the TChain object to make into account
the branches. By the way this kind of TChain is already implemented in root TTree::MakeClass() method where root splits the TTree obtained after conversion
from the PAW ntuple into individual branches each of them having different number of
entries.

Kind regards, Dmitry

Philippe Canal wrote:

>Hi Dmitry,
>
>Note also that TChain::GetBranch returns a TBranch object
>that explicitly pertain ___only__ to the current underlying TTree.
>
>In the general case, having unevenly filled TTree is a bad idea
>(it causes many issues including the one you are stumpling upon).
>
>It may (or may not) be more appropriate in your case to separate
>the branches in different trees.
>
>Cheers,
>Philippe.
>
>-----Original Message-----
>From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
>On Behalf Of Rene Brun
>Sent: Thursday, November 24, 2005 10:45 AM
>To: Dmitry Naumov
>Cc: Rene Brun; roottalk_at_cern.ch
>Subject: Re: [ROOT] (no subject)
>
>Dmitry,
>
>When you do
>root [5] t2->GetBranch("fEvent")->GetEntries()
>you get 1 entry. So it is normal that
>root [4] t->GetBranch("fEvent")->GetEntry(0)
> (Int_t)425
> root [5] t->GetBranch("fEvent")->GetEntry(1)
> (Int_t)0
>The last command must return 0, since you only have one entry.
>
>Rene
>
>
>On Thu, 24 Nov
>2005, Dmitry
>Naumov wrote:
>
>
>
>>Sorry, I forgot to mention that I first tried what you suggested and it
>>
>>
>did
>
>
>>not work (By the way
>>why it should work if the tree can have in principle different branches
>>
>>
>each
>
>
>>having
>>different number of events? What does it mean "Entries" in this case?)
>>Thus I though that you probably meant setting number of events in the
>>
>>
>given
>
>
>>branch.
>>Just a check of your first message:
>>
>>root [0] TChain *t = new TChain("nuclon")
>>root [1] t->AddFile("t1.root")
>>(Int_t)1
>>root [2] t->AddFile("t2.root")
>>(Int_t)1
>>root [3] t->SetEntries(2)
>>(Long64_t)2
>>root [4] t->GetBranch("fEvent")->GetEntry(0)
>>(Int_t)425
>>root [5] t->GetBranch("fEvent")->GetEntry(1)
>>(Int_t)0
>>
>>
>>Just a check that each event has its 1 event:
>>root [0] TFile f1("t1.root")
>>root [1] TTree *t1 = (TTree*)f1.Get("nuclon")
>>root [2] t1->GetBranch("fEvent")->GetEntries()
>>(const Long64_t)1
>>root [3] TFile f2("t2.root")
>>root [4] TTree *t2 = (TTree*)f2.Get("nuclon")
>>root [5] t2->GetBranch("fEvent")->GetEntries()
>>(const Long64_t)1
>>
>>Rene Brun wrote:
>>
>>
>>
>>>You did not read my mail correctly. I told you to do
>>> t->SetEntries(nentries);
>>>and not
>>> t->GetBranch("fEvent")->SetEntries*();
>>>
>>>Rene Brun
>>>
>>>On Thu, 24 Nov 2005, Dmitry Naumov wrote:
>>>
>>>
>>>
>>>>Dear Rene,
>>>>
>>>>thank you for this advice. I tried it but it does not read anyway the
>>>>second event:
>>>>
>>>>root [0] TChain *t = new TChain("nuclon")
>>>>root [1] t->AddFile("t1.root")
>>>>(Int_t)1
>>>>root [2] t->AddFile("t2.root")
>>>>(Int_t)1
>>>>root [3] t->GetBranch("fEvent")->SetEntries(2)
>>>>root [4] t->GetBranch("fEvent")->GetEntries() // to check!
>>>>(const Long64_t)2
>>>>root [5] t->GetBranch("fEvent")->GetEntry(0)
>>>>(Int_t)425 // OK
>>>>root [6] t->GetBranch("fEvent")->GetEntry(1)
>>>>(Int_t)0 // empty ?!
>>>>
>>>>root Version 5.02/00 Dmitry
>>>>
>>>>Rene Brun wrote:
>>>>
>>>>
>>>>
>>>>>Dmitry,
>>>>>
>>>>>Call t->SetEntries(nentries);
>>>>>where nentries is the number of entries if your branches.
>>>>>
>>>>>Rene Brun
>>>>>
>>>>>On Thu, 24 Nov 2005, Dmitry Naumov wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Dear rooters,
>>>>>>
>>>>>>I have a strange problem:
>>>>>>I create TTree with two branches: fRunPars and fEvent.
>>>>>>fRunPars is filled only once and it containes simulation settings
>>>>>>fEvent s filled for each event:
>>>>>>
>>>>>>fTree->GetBranch("fEvent")->Fill()
>>>>>>
>>>>>>Now I created a set of files with these trees. I want to make a TChain
>>>>>>
>>>>>>
>
>
>
>>>>>>of them:
>>>>>>TChain *t = new TChain("nuclon");
>>>>>>t->AddFile("t1.root"); // has 1 event
>>>>>>t->AddFile("t2.root"); // has 1 event
>>>>>>t->GetEntries(); // gives 0. It is OK because TTree
>>>>>> // has two branches one of
>>>>>>
>>>>>>
>which
>
>
>>>>>>is filled
>>>>>> // many times, another only
>>>>>>
>>>>>>
>once,
>
>
>>>>>>thus Entries probably has no sense
>>>>>>t->GetBranch("fEvent")->GetEntries(); // gives 1 ?! Why not 2?
>>>>>>
>>>>>>If I do
>>>>>>t->GetBranch("fEvent")->GetEntry(0); // it is OK
>>>>>>t->GetBranch("fEvent")->GetEntry(1); // this event is empty.
>>>>>>
>>>>>>
>>>>>>Do I misunderstand something? Many thanks in advance, Dmitry
>>>>>>
>>>>>>
>>>>>>
>
>
>
Received on Thu Dec 01 2005 - 18:35:35 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:14 MET