Re: Saving selected TChain entries

From: suvayu ali <fatkasuvayu_at_gmail.com>
Date: Mon, 27 Feb 2012 15:20:54 +0100


Hi Daniel,

I was looking for a method like TEntryList::Fill() in the class documentation and missed TEntryList::Enter(). :-p

Thank you so much!

On Mon, Feb 27, 2012 at 15:10, Daniel CUSSOL <cussol_at_in2p3.fr> wrote:
> Le 27/02/2012 15:00, suvayu ali a écrit :
>
> Hi ROOT users & experts,
>
> I want to save the selected entries for a TChain. I could just copy the
> required branches for the selected entries to a smaller tree, but it is
> not easily maintainable for my case as my list of required branches
> changes rather often. So I looked into TEntryList. But it seems I can
> generate a TEntryList only with the TChain::Draw() method. I would
> prefer to select by iterating over the chain instead. Is there anyway to
> get a TEntryList without using TChain::Draw()?
>
> Thanks a lot,
>
> Hi
>  You can directly use the TEntryList::Enter(Long64_t entry, TTree* tree = 0)
> method tu add a given entry to an entry list. The code could be like this:
>
> TEntryList *el=new TEntryList("MyList","List of selected entries");
> Bool_t selected=kFALSE;
> for(Long64_t i=0;i<myChain->GetEntries();i++)
>  {
>  myChain->GetEntry(i);
>  .... // process entry number "i" and adjust the value of "selected" whether
> your want to add this entry to the entry list or not
> if(selected)
>  {
> el->Entrer(i)
>  }
>
>  }
>
> For a detailed description of the TEntryList class, have a look at
> http://root.cern.ch/root/html/TEntryList.html .
> I hope this helps.
>
>
> --
> Daniel CUSSOL
>
> LPC Caen IN2P3/ENSICAEN/Universite de Caen
> Boulevard du Marechal Juin
> 14050 CAEN CEDEX
>
> e-mail : cussol_at_in2p3.fr
> Tel : +33-(0)2-31-45-29-73
> FAX : +33-(0)2-31-45-25-49

-- 
Suvayu

Open source is the future. It sets us free.
Received on Mon Feb 27 2012 - 15:21:24 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 28 2012 - 23:50:01 CET