Re: TEntryList for TChain

From: Hovhannes Khandanyan <khandan_at_cern.ch>
Date: Wed, 23 Jun 2010 11:46:25 +0200

   Hello Rene,

I tried the prescription that you recommended but it had the same problem. Anyhow, when I tried using TEventList instead of TEntryList that worked ! Maybe I have to somehow additionally instruct the TChain to go to the specific tree? If so that presumably is an extra complication when using TEntryList wrt TEventList.

Thanks,
Hovhannes

On Jun 23, 2010, at 10:28 AM, Rene Brun wrote:

> I see that there is a missing function in TEntryList to loop the
> way you intend to do it.
> So,instead of:
>
> CollectionTree->Draw(">>seltrackevents",cut,"entrylist");
> TEntryList *seltrackevents = (TEntryList*)gDirectory->Get
> ("seltrackevents");
>
> Int_t jj = -1;
> seltrackevents->GetEntry(0);
> do {
>
> jj = seltrackevents->Next();
> cout << "jj = " << jj << endl;
>
> CollectionTree->GetEntry(jj);
> //
> .....
> .......
>
> } while(jj != -1);
>
> I suggest to do:
>
> CollectionTree->Draw(">>seltrackevents",cut);
> TEventList *seltrackevents = (TEventList*)gDirectory->Get
> ("seltrackevents");
>
> int nentries = seltrackevents->GetN();
> for (int jj = 0;jj<nentries;jj++) {
> Long64_t entry = seltrackevents->GetEntry(jj);
> cout << "jj = " << jj <<" entry= " <<entry << endl;
>
> CollectionTree->GetEntry(entry);
> //
> .....
> .......
> }
>
>
> Rene Brun
>
>
>
> Hovhannes Khandanyan wrote:
>>
>> Dear ROOTers,
>>
>> I have a chain of ROOT trees:
>>
>> TChain* CollectionTree = new TChain("CollectionTree");
>> CollectionTree->Add("many files *.root");
>>
>> for which I create an entrylist
>>
>> CollectionTree->Draw(">>seltrackevents",cut,"entrylist");
>> TEntryList *seltrackevents = (TEntryList*)gDirectory->Get
>> ("seltrackevents");
>>
>> Then I try to look through my entrylist in the following way:
>>
>> Int_t jj = -1;
>> seltrackevents->GetEntry(0);
>> do {
>>
>> jj = seltrackevents->Next();
>> cout << "jj = " << jj << endl;
>>
>> CollectionTree->GetEntry(jj);
>> //
>> .....
>> .......
>>
>> } while(jj != -1);
>>
>> This works correctly only for the 1st file of the chain, since jj
>> is always the event number within the given file 'local event
>> number' as opposed 'global event number' for the whole chain.
>> Please let me know what I should use instead/on top of jj =
>> seltrackevents->Next(); to make sure that I get the event from
>> the correct chain file.
>>
>> Thanks for any help,
>> Hovhannes
>>
>
Received on Wed Jun 23 2010 - 11:49:03 CEST

This archive was generated by hypermail 2.2.0 : Wed Jun 23 2010 - 17:50:01 CEST