Re: (no subject)

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Thu, 24 Nov 2005 18:02:38 +0100 (MET)


The t->setEntries should be done on the individual trees, not on the TChain.

Rene

On Thu, 24 Nov 2005, Dmitry Naumov wrote:

> Rene,
> I do not understand your answer. If I have 1 entry in t1 and 1 entry in t2
> and doing TChain of t1 and t2 I expect to have in total 2 entries. Is not it?
> I read first entry from the TChain with
> t->GetBranch("fEvent")->GetEntry(0)
> and it reads 425 bytes. Then I try read the second entry from the TChain
> (first entry
> from t2 which is there as I wrote you) with
> t->GetBranch("fEvent")->GetEntry(1)
> and it reads zero bytes. Why this is normal?
> Dmitry
>
> Rene Brun wrote:
>
>> 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 Nov 24 2005 - 18:02:49 MET

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