class TEntryList: public TNamed


TEntryList: a List of entry numbers in a TTree or TChain

There are two types of entry lists:
  1. for a TTree (fBlocks data member is non-zero) Entry numbers are stored in TEntryListBlocks, which, in their turn, are stored in the TObjArray fBlocks. The range of the entry numbers is cut into intervals of kBlockSize entries (currently 64000), so that the first block contains information which entries out of the first 64000 pass the selection, the second block - which entries out of the 64000-127999 interval pass the selection, etc. Some blocks, obviously, might be empty. The internal representation of entry numbers in the blocks is described in the TEntryListBlock class description, and this representation might be changed by calling OptimizeStorage() function (when the list is filled via the Enter() function, this is done automatically, except for the last block). Individual entry lists can be merged (functions Merge() and Add()) to make an entry list for a TChain of corresponding TTrees.
    output of MACRO_TEntryList_1_c
    {
    //=========Macro generated from canvas: c/c
    //=========  (Tue Jan 23 16:58:56 2007) by ROOT version5.15/01
       TCanvas *c = new TCanvas("c", "c",213,172,460,253);
       c->Range(0,0,1,1);
       c->SetBorderSize(2);
       c->SetFrameFillColor(0);
       
       TPaveText *pt = new TPaveText(0.00518135,0.810811,0.507772,0.989189,"br");
       pt->SetFillColor(19);
       pt->SetTextColor(4);
       TText *text = pt->AddText("TEntryList for a TTree");
       pt->Draw();
       
       pt = new TPaveText(0.0387597,0.483696,0.307494,0.657609,"br");
       pt->SetFillColor(19);
       text = pt->AddText("TEntryList");
       pt->Draw();
       
       pt = new TPaveText(0.0363636,0.107527,0.306494,0.489247,"br");
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("fBlocks");
       text = pt->AddText("fLists = 0");
       pt->Draw();
       
       pt = new TPaveText(0.338501,0.23913,0.627907,0.375,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       text = pt->AddText("Info on entries 0-63999");
       pt->Draw();
       
       pt = new TPaveText(0.643411,0.23913,0.989664,0.375,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       text = pt->AddText("entries 64000-127999");
       pt->Draw();
       
       pt = new TPaveText(0.423773,0.423913,0.870801,0.576087,"br");
       pt->SetFillColor(19);
       text = pt->AddText("TObjArray of TEntryListBlock objects");
       pt->Draw();
       TArrow *arrow = new TArrow(0.277202,0.356757,0.418605,0.505435,0.05,">");
       arrow->SetFillColor(1);
       arrow->SetFillStyle(1001);
       arrow->Draw();
       return c;
    }
    
    
  2. for a TChain (fLists data member is non-zero) It contains a TList of sub-lists (TEntryList objects, corresponding to each TTree) Trees and lists are matched by the TTree name and its file name (full path). All sub-lists are returned by the GetLists() function and individual lists are returned by GetEntryList() function. Such lists are no different from the lists for TTrees, described above.
    output of MACRO_TEntryList_3_c
    {
    //=========Macro generated from canvas: c/c
    //=========  (Mon Jan 22 19:00:21 2007) by ROOT version5.15/01
       TCanvas *c = new TCanvas("c", "c",172,104,447,249);
       c->Range(0,0,1,1);
       c->SetBorderSize(2);
       c->SetFrameFillColor(0);
       
       TPaveText *pt = new TPaveText(0.0026738,0.790055,0.417112,0.994475,"br");
       pt->SetFillColor(19);
       pt->SetTextColor(4);
       TText *text = pt->AddText("TEntryList for a TChain");
       pt->Draw();
       
       pt = new TPaveText(0.00802139,0.541436,0.294118,0.701657,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("TEntryList");
       pt->Draw();
       
       pt = new TPaveText(0.0106952,0.237569,0.294118,0.546961,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("fBlocks = 0");
       text = pt->AddText("fLists");
       pt->Draw();
       
       pt = new TPaveText(0.483957,0.607735,0.68984,0.773481,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("TChain");
       pt->Draw();
       
       pt = new TPaveText(0.347594,0.475138,0.494652,0.596685,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("TTree_1");
       pt->Draw();
       
       pt = new TPaveText(0.508021,0.475138,0.660428,0.59116,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("TTree_2");
       pt->Draw();
       
       pt = new TPaveText(0.673797,0.469613,0.826203,0.59116,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       pt->SetTextFont(42);
       text = pt->AddText("TTree_3");
       pt->Draw();
       
       pt = new TPaveText(0.251337,0.0331492,0.483957,0.165746,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       text = pt->AddText("TEntryList for TTree_1");
       pt->Draw();
       
       pt = new TPaveText(0.491979,0.038674,0.729947,0.171271,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       text = pt->AddText("TEntryList for TTree_2");
       pt->Draw();
       
       pt = new TPaveText(0.737968,0.038674,0.97861,0.171271,"br");
       pt->SetBorderSize(1);
       pt->SetFillColor(19);
       text = pt->AddText("TEntryList for TTree_3");
       pt->Draw();
       
       pt = new TPaveText(0.410667,0.21978,0.816,0.395604,"br");
       pt->SetFillColor(19);
       text = pt->AddText("TList of TEntryList* objects");
       pt->Draw();
       TArrow *arrow = new TArrow(0.224,0.296703,0.4,0.296703,0.05,">");
       arrow->SetFillColor(1);
       arrow->SetFillStyle(1001);
       arrow->Draw();
       return c;
    }
    
    

Operations on entry lists

  • Add() - if the lists are for the same tree, adds all the entries of the second list to the first list. If the lists are for different trees, creates a TEntryList with 2 sublists for each TTree. If the lists are for TChains, merges the ones for the same trees and adds new sublists for the TTrees that were not included in the first TEntryList
  • Subtract() - if the lists are for the same TTree, removes the entries of the second list from the first list. If the lists are for TChains, loops over all sub-lists
  • GetEntry(n) - returns the n-th entry number
  • Next() - returns next entry number. Note, that this function is much faster than GetEntry, and it's called when GetEntry() is called for 2 or more indices in a row.

TTree::Draw() and TChain::Draw()

Use option entrylist to write the results of TTree::Draw and TChain::Draw into an entry list. Example:
     tree->Draw(">>elist", "x<0 && y>0", "entrylist");
     TEntryList *elist = (TEntryList*)gDirectory->Get("elist");

TSelectors

To fill an TEntryList from a TSelector correctly, one must add the TEntryList object to the output list of the selector (TSelector::fOutput). This is the only way to make the sub-lists of the TEntryList switch when the current tree of the TChain is changed.

Using a TEntryList as input (TTree::SetEntryList() and TChain::SetEntryList())

while the TTree::SetEntryList() function is only setting the TTree::fEntryList data member, the same function in TChain also finds correspondance between the TTrees of this TChain and the sub-lists of this TEntryList.

TEntryList and the current directory

TEntryList objects are automatically added to the current directory (like TTrees). However, in case of a TEntryList for a chain, only the top-level entry list is added, not the sub-lists for specific trees. Placing entry lists in the current directory allows calling them as a part of a TTreeFormula expression, so if the user wants to extract a sublist from a TChain entry list via the GetEntryList() or some other function, he has to add it to the current directory to be able to use it in TTreeFormula expressions.

TEntryList and TEventList

TTree::SetEventList() and TChain::SetEventList() transform a TEventList into a TEntryList See comments to those functions for more details
 

Function Members (Methods)

public:
TEntryList()
TEntryList(const TTree* tree)
TEntryList(const TEntryList& elist)
TEntryList(const char* name, const char* title)
TEntryList(const char* name, const char* title, const TTree* tree)
TEntryList(const char* name, const char* title, const char* treename, const char* filename)
virtual~TEntryList()
voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(const TEntryList* elist)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual Int_tContains(Long64_t entry, TTree* tree = 0)
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual voidDirectoryAutoAdd(TDirectory*)
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual Bool_tEnter(Long64_t entry, TTree* tree = 0)
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual TEntryList*GetCurrentList() const
virtual TDirectory*GetDirectory() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Long64_tGetEntriesToProcess() const
virtual Long64_tGetEntry(Int_t index)
virtual Long64_tGetEntryAndTree(Int_t index, Int_t& treenum)
virtual TEntryList*GetEntryList(const char* treename, const char* filename, Option_t* opt = "")
virtual const char*GetFileName() const
virtual const char*TObject::GetIconName() const
virtual TList*GetLists() const
virtual Long64_tGetN() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual Bool_tGetReapplyCut() const
virtual const char*TNamed::GetTitle() const
virtual const char*GetTreeName() const
virtual Int_tGetTreeNumber() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Int_tMerge(TCollection* list)
virtual Long64_tNext()
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidOptimizeStorage()
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual Bool_tRemove(Long64_t entry, TTree* tree = 0)
virtual voidReset()
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidSetDirectory(TDirectory* dir)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidSetEntriesToProcess(Long64_t nen)
virtual voidSetFileName(const char* filename)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidSetReapplyCut(Bool_t apply = kFALSE)TOGGLE
virtual voidSetShift(Bool_t shift)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidSetTree(const TTree* tree)
virtual voidSetTree(const char* treename, const char* filename)
virtual voidSetTreeName(const char* treename)
virtual voidSetTreeNumber(Int_t index)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidSubtract(const TEntryList* elist)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
TEntryList&operator=(const TEntryList&)

Data Members

public:
enum { kBlockSize
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
TObjArray*fBlocksblocks with indices of passing events (TEntryListBlocks)
TEntryList*fCurrent! currently filled entry list
TDirectory*fDirectory! Pointer to directory holding this tree
Long64_tfEntriesToProcessused on proof to set the number of entries to process in a packet
TStringfFileNamename of the file, where the tree is
Long64_tfLastIndexQueried! used to optimize GetEntry() function from a loop
Long64_tfLastIndexReturned! used to optimize GetEntry() function from a loop
TList*fListsa list of underlying entry lists for each tree of a chain
Long64_tfNnumber of entries in the list
Int_tfNBlocksnumber of TEntryListBlocks
TStringTNamed::fNameobject identifier
Bool_tfReapplyIf true, TTree::Draw will 'reapply' the original cut
Bool_tfShift! true when some sub-lists don't correspond to trees
ULong_tfStringHash! Hash value of a string of treename and filename
TStringTNamed::fTitleobject title
TStringfTreeNamename of the tree
Int_tfTreeNumber! the index of the tree in the chain (used when the entry

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TEntryList()
default c-tor
TEntryList(const char* name, const char* title)
c-tor with name and title
TEntryList(const char* name, const char* title, const TTree* tree)
constructor with name and title, which also sets the tree
TEntryList(const char* name, const char* title, const char* treename, const char* filename)
c-tor with name and title, which also sets the treename and the filename
TEntryList(const TTree *tree)
c-tor, which sets the tree
TEntryList(const TEntryList &elist)
copy c-tor
~TEntryList()
 Destructor.
void Add(const TEntryList* elist)
Add 2 entry lists
Int_t Contains(Long64_t entry, TTree* tree = 0)
When tree = 0, returns from the current list
When tree != 0, finds the list, corresponding to this tree
When tree is a chain, the entry is assumed to be global index and the local
entry is recomputed from the treeoffset information of the chain
void DirectoryAutoAdd(TDirectory* )
 Called by TKey and others to automatically add us to a directory when we are read from a file.
Bool_t Enter(Long64_t entry, TTree* tree = 0)
Add entry #entry to the list
When tree = 0, adds to the current list
When tree != 0, finds the list, corresponding to this tree
When tree is a chain, the entry is assumed to be global index and the local
entry is recomputed from the treeoffset information of the chain
Bool_t Remove(Long64_t entry, TTree* tree = 0)
Remove entry #entry from the list
When tree = 0, removes from the current list
When tree != 0, finds the list, corresponding to this tree
When tree is a chain, the entry is assumed to be global index and the local
entry is recomputed from the treeoffset information of the chain
Long64_t GetEntry(Int_t index)
return the number of the entry #index of this TEntryList in the TTree or TChain
See also Next().
Long64_t GetEntryAndTree(Int_t index, Int_t& treenum)
return the index of "index"-th non-zero entry in the TTree or TChain
and the # of the corresponding tree in the chain
TEntryList * GetEntryList(const char* treename, const char* filename, Option_t* opt = "")
return the entry list, correspoding to treename and filename
By default, the filename is first tried as is, and then, if the corresponding list
is not found, the filename is expanded to the absolute path, and compared again.
To avoid it, use option "ne"
Int_t Merge(TCollection* list)
Merge this list with the lists from the collection
Long64_t Next()
return the next non-zero entry index (next after fLastIndexQueried)
this function is faster than GetEntry()
void OptimizeStorage()
Checks if the array representation is more economical and if so, switches to it
void Print(Option_t* option = "") const
Print this list
option = "" - default - print the name of the tree and file
option = "all" - print all the entry numbers
void Reset()
Reset this list
void SetDirectory(TDirectory* dir)
Add reference to directory dir. dir can be 0.
void SetTree(const char* treename, const char* filename)
If a list for a tree with such name and filename exists, sets it as the current sublist
If not, creates this list and sets it as the current sublist

 ! the filename is taken as provided, no extensions to full path or url !
void SetTree(const TTree* tree)
If a list for a tree with such name and filename exists, sets it as the current sublist
If not, creates this list and sets it as the current sublist
The name of the file, where the tree is, is taken as
tree->GetTree()->GetCurrentFile()->GetName(), and then expanded either to the absolute path,
or to full url. If, for some reason, you want to provide
the filename in a different format, use SetTree(const char *treename, const char *filename),
where the filename is taken "as is".
void Subtract(const TEntryList* elist)
remove all the entries of this entry list, that are contained in elist
TEntryList& operator=(const TEntryList& )
TEntryList * GetCurrentList()
{ return fCurrent; }
Long64_t GetEntriesToProcess()
{return fEntriesToProcess;}
TList * GetLists()
{ return fLists; }
TDirectory * GetDirectory()
{ return fDirectory; }
Long64_t GetN()
{ return fN; }
const char * GetTreeName()
{ return fTreeName.Data(); }
const char * GetFileName()
{ return fFileName.Data(); }
Int_t GetTreeNumber()
{ return fTreeNumber; }
Bool_t GetReapplyCut()
{ return fReapply; }
void SetEntriesToProcess(Long64_t nen)
{ fEntriesToProcess = nen; }
void SetShift(Bool_t shift)
{ fShift = shift; }
void SetTreeName(const char* treename)
{ fTreeName = treename; }
void SetFileName(const char* filename)
{ fFileName = filename; }
void SetTreeNumber(Int_t index)
{ fTreeNumber=index; }
void SetReapplyCut(Bool_t apply = kFALSE)
{fReapply = apply;}

Author: Anna Kreshuk 27/10/2006
Last change: root/tree:$Id: TEntryList.h 22992 2008-04-05 09:43:01Z pcanal $
Last generated: 2008-06-25 08:36
Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.