Logo ROOT  
Reference Guide
TEntryList.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Anna Kreshuk 27/10/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TEntryList
13 #define ROOT_TEntryList
14 
15 #include "TNamed.h"
16 
17 class TTree;
18 class TDirectory;
19 class TObjArray;
20 class TString;
21 
22 class TList;
23 class TCollection;
24 
25 class TEntryList: public TNamed
26 {
27  private:
28  TEntryList& operator=(const TEntryList&); // Not implemented
29 
30  protected:
31  TList *fLists; ///< a list of underlying entry lists for each tree of a chain
32  TEntryList *fCurrent; ///<! currently filled entry list
33 
34  Int_t fNBlocks; ///< number of TEntryListBlocks
35  TObjArray *fBlocks; ///< blocks with indices of passing events (TEntryListBlocks)
36  Long64_t fN; ///< number of entries in the list
37  Long64_t fEntriesToProcess; ///< used on proof to set the number of entries to process in a packet
38  TString fTreeName; ///< name of the tree
39  TString fFileName; ///< name of the file, where the tree is
40  ULong_t fStringHash; ///<! Hash value of a string of treename and filename
41  Int_t fTreeNumber; ///<! the index of the tree in the chain (used when the entry
42  ///< list is used as input (TTree::SetEntryList())
43 
44  Long64_t fLastIndexQueried; ///<! used to optimize GetEntry() function from a loop
45  Long64_t fLastIndexReturned; ///<! used to optimize GetEntry() function from a loop
46  Bool_t fShift; ///<! true when some sub-lists don't correspond to trees
47  ///< (when the entry list is used as input in TChain)
48  TDirectory *fDirectory; ///<! Pointer to directory holding this tree
49  Bool_t fReapply; ///< If true, TTree::Draw will 'reapply' the original cut
50 
51  void GetFileName(const char *filename, TString &fn, Bool_t * = 0);
52 
53  public:
54  enum {kBlockSize = 64000}; //number of entries in each block (not the physical size).
55 
56  TEntryList();
57  TEntryList(const char *name, const char *title);
58  TEntryList(const char *name, const char *title, const TTree *tree);
59  TEntryList(const char *name, const char *title, const char *treename, const char *filename);
60  TEntryList(const TTree *tree);
61  TEntryList(const TEntryList& elist);
62  virtual ~TEntryList();
63 
64  virtual void Add(const TEntryList *elist);
65  virtual Int_t Contains(Long64_t entry, TTree *tree = 0);
66  virtual void DirectoryAutoAdd(TDirectory *);
67  virtual Bool_t Enter(Long64_t entry, TTree *tree = 0);
68  virtual TEntryList *GetCurrentList() const { return fCurrent; };
69  virtual TEntryList *GetEntryList(const char *treename, const char *filename, Option_t *opt="");
70  virtual Long64_t GetEntry(Int_t index);
71  virtual Long64_t GetEntryAndTree(Int_t index, Int_t &treenum);
73  virtual TList *GetLists() const { return fLists; }
74  virtual TDirectory *GetDirectory() const { return fDirectory; }
75  virtual Long64_t GetN() const { return fN; }
76  virtual const char *GetTreeName() const { return fTreeName.Data(); }
77  virtual const char *GetFileName() const { return fFileName.Data(); }
78  virtual Int_t GetTreeNumber() const { return fTreeNumber; }
79  virtual Bool_t GetReapplyCut() const { return fReapply; };
80 
81  Bool_t IsValid() const
82  {
83  if ((fLists || fBlocks)) return kTRUE;
84  return kFALSE;
85  }
86 
87  virtual Int_t Merge(TCollection *list);
88 
89  virtual Long64_t Next();
90  virtual void OptimizeStorage();
91  virtual Int_t RelocatePaths(const char *newloc, const char *oldloc = 0);
92  virtual Bool_t Remove(Long64_t entry, TTree *tree = 0);
93  virtual void Reset();
94  virtual Int_t ScanPaths(TList *roots, Bool_t notify = kTRUE);
95 
96  virtual void Print(const Option_t* option = "") const;
97  virtual void SetDirectory(TDirectory *dir);
98  virtual void SetEntriesToProcess(Long64_t nen) { fEntriesToProcess = nen; }
99  virtual void SetShift(Bool_t shift) { fShift = shift; };
100  virtual void SetTree(const TTree *tree);
101  virtual void SetTree(const char *treename, const char *filename);
102  virtual void SetTreeName(const char *treename){ fTreeName = treename; };
103  virtual void SetFileName(const char *filename){ fFileName = filename; };
104  virtual void SetTreeNumber(Int_t index) { fTreeNumber=index; }
105  virtual void SetReapplyCut(Bool_t apply = kFALSE) {fReapply = apply;}; // *TOGGLE* *GETTER=GetReapplyCut
106  virtual void Subtract(const TEntryList *elist);
107 
108  static Int_t Relocate(const char *fn,
109  const char *newroot, const char *oldroot = 0, const char *enlnm = 0);
110  static Int_t Scan(const char *fn, TList *roots);
111 
112 // Preventing warnings with -Weffc++ in GCC since the overloading of the || operator was a design choice.
113 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
114 #pragma GCC diagnostic push
115 #pragma GCC diagnostic ignored "-Weffc++"
116 #endif
117  friend TEntryList operator||(TEntryList& elist1, TEntryList& elist2);
118 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
119 #pragma GCC diagnostic pop
120 #endif
121 
122  ClassDef(TEntryList, 2); //A list of entries in a TTree
123 };
124 #endif
TEntryList::DirectoryAutoAdd
virtual void DirectoryAutoAdd(TDirectory *)
Called by TKey and others to automatically add us to a directory when we are read from a file.
Definition: TEntryList.cxx:548
TEntryList::TEntryList
TEntryList()
default c-tor
Definition: TEntryList.cxx:161
TEntryList::kBlockSize
@ kBlockSize
Definition: TEntryList.h:54
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TEntryList::GetDirectory
virtual TDirectory * GetDirectory() const
Definition: TEntryList.h:74
TObjArray
Definition: TObjArray.h:37
TEntryList::GetTreeName
virtual const char * GetTreeName() const
Definition: TEntryList.h:76
TEntryList::Remove
virtual Bool_t Remove(Long64_t entry, TTree *tree=0)
Remove entry #entry from the list.
Definition: TEntryList.cxx:615
TEntryList::SetEntriesToProcess
virtual void SetEntriesToProcess(Long64_t nen)
Definition: TEntryList.h:98
TString::Data
const char * Data() const
Definition: TString.h:369
TEntryList::fTreeName
TString fTreeName
name of the tree
Definition: TEntryList.h:38
tree
Definition: tree.py:1
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TTree
Definition: TTree.h:79
TEntryList::fCurrent
TEntryList * fCurrent
! currently filled entry list
Definition: TEntryList.h:32
TEntryList::SetShift
virtual void SetShift(Bool_t shift)
Definition: TEntryList.h:99
Int_t
int Int_t
Definition: RtypesCore.h:45
TEntryList::OptimizeStorage
virtual void OptimizeStorage()
Checks if the array representation is more economical and if so, switches to it.
Definition: TEntryList.cxx:983
TEntryList::Scan
static Int_t Scan(const char *fn, TList *roots)
Scan TEntryList in 'fn' to find the common parts of paths.
Definition: TEntryList.cxx:1506
TEntryList::fLastIndexQueried
Long64_t fLastIndexQueried
! used to optimize GetEntry() function from a loop
Definition: TEntryList.h:44
TEntryList::fShift
Bool_t fShift
! true when some sub-lists don't correspond to trees (when the entry list is used as input in TChain)
Definition: TEntryList.h:46
roots
TCanvas * roots()
Definition: roots.C:1
TEntryList::IsValid
Bool_t IsValid() const
Definition: TEntryList.h:81
TEntryList::fLists
TList * fLists
a list of underlying entry lists for each tree of a chain
Definition: TEntryList.h:31
TEntryList::SetTree
virtual 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,...
Definition: TEntryList.cxx:1194
TEntryList::~TEntryList
virtual ~TEntryList()
Destructor.
Definition: TEntryList.cxx:323
TString
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TEntryList::SetFileName
virtual void SetFileName(const char *filename)
Definition: TEntryList.h:103
bool
TEntryList::SetTreeName
virtual void SetTreeName(const char *treename)
Definition: TEntryList.h:102
TEntryList::fStringHash
ULong_t fStringHash
! Hash value of a string of treename and filename
Definition: TEntryList.h:40
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TEntryList::GetEntry
virtual Long64_t GetEntry(Int_t index)
Return the number of the entry #index of this TEntryList in the TTree or TChain See also Next().
Definition: TEntryList.cxx:657
TEntryList::operator||
friend TEntryList operator||(TEntryList &elist1, TEntryList &elist2)
Definition: TEntryList.cxx:1283
TEntryList::fDirectory
TDirectory * fDirectory
! Pointer to directory holding this tree
Definition: TEntryList.h:48
TEntryList::GetLists
virtual TList * GetLists() const
Definition: TEntryList.h:73
TEntryList::Enter
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
Definition: TEntryList.cxx:560
TEntryList::fBlocks
TObjArray * fBlocks
blocks with indices of passing events (TEntryListBlocks)
Definition: TEntryList.h:35
TNamed
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TEntryList::fFileName
TString fFileName
name of the file, where the tree is
Definition: TEntryList.h:39
TEntryList::fReapply
Bool_t fReapply
If true, TTree::Draw will 'reapply' the original cut.
Definition: TEntryList.h:49
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TEntryList
Definition: TEntryList.h:25
TEntryList::Next
virtual Long64_t Next()
Return the next non-zero entry index (next after fLastIndexQueried) this function is faster than GetE...
Definition: TEntryList.cxx:896
TEntryList::Merge
virtual Int_t Merge(TCollection *list)
Merge this list with the lists from the collection.
Definition: TEntryList.cxx:877
TEntryList::SetReapplyCut
virtual void SetReapplyCut(Bool_t apply=kFALSE)
Definition: TEntryList.h:105
TEntryList::GetEntryAndTree
virtual 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 t...
Definition: TEntryList.cxx:733
TEntryList::GetEntriesToProcess
virtual Long64_t GetEntriesToProcess() const
Definition: TEntryList.h:72
TEntryList::Add
virtual void Add(const TEntryList *elist)
Add 2 entry lists.
Definition: TEntryList.cxx:345
TEntryList::GetTreeNumber
virtual Int_t GetTreeNumber() const
Definition: TEntryList.h:78
TEntryList::ScanPaths
virtual Int_t ScanPaths(TList *roots, Bool_t notify=kTRUE)
Scan the paths to find the common roots.
Definition: TEntryList.cxx:1449
TEntryList::Relocate
static Int_t Relocate(const char *fn, const char *newroot, const char *oldroot=0, const char *enlnm=0)
Relocate entry list 'enlnm' in file 'fn' replacing 'oldroot' with 'newroot' in filenames.
Definition: TEntryList.cxx:1363
TEntryList::Print
virtual void Print(const Option_t *option="") const
Print this list.
Definition: TEntryList.cxx:999
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TEntryList::Subtract
virtual void Subtract(const TEntryList *elist)
Remove all the entries of this entry list, that are contained in elist.
Definition: TEntryList.cxx:1230
name
char name[80]
Definition: TGX11.cxx:110
TDirectory
Definition: TDirectory.h:40
TEntryList::fLastIndexReturned
Long64_t fLastIndexReturned
! used to optimize GetEntry() function from a loop
Definition: TEntryList.h:45
TEntryList::GetCurrentList
virtual TEntryList * GetCurrentList() const
Definition: TEntryList.h:68
TEntryList::GetFileName
virtual const char * GetFileName() const
Definition: TEntryList.h:77
TEntryList::RelocatePaths
virtual Int_t RelocatePaths(const char *newloc, const char *oldloc=0)
Relocate the file paths.
Definition: TEntryList.cxx:1304
TEntryList::Reset
virtual void Reset()
Reset this list.
Definition: TEntryList.cxx:1036
TCollection
Definition: TCollection.h:63
TEntryList::fN
Long64_t fN
number of entries in the list
Definition: TEntryList.h:36
TEntryList::fTreeNumber
Int_t fTreeNumber
! the index of the tree in the chain (used when the entry list is used as input (TTree::SetEntryList(...
Definition: TEntryList.h:41
TEntryList::GetN
virtual Long64_t GetN() const
Definition: TEntryList.h:75
TEntryList::operator=
TEntryList & operator=(const TEntryList &)
TEntryList::SetDirectory
virtual void SetDirectory(TDirectory *dir)
Add reference to directory dir. dir can be 0.
Definition: TEntryList.cxx:1068
TList
Definition: TList.h:44
TEntryList::fNBlocks
Int_t fNBlocks
number of TEntryListBlocks
Definition: TEntryList.h:34
TEntryList::GetEntryList
virtual TEntryList * GetEntryList(const char *treename, const char *filename, Option_t *opt="")
Return the entry list, corresponding to treename and filename By default, the filename is first tried...
Definition: TEntryList.cxx:787
TEntryList::SetTreeNumber
virtual void SetTreeNumber(Int_t index)
Definition: TEntryList.h:104
int
TEntryList::Contains
virtual Int_t Contains(Long64_t entry, TTree *tree=0)
Definition: TEntryList.cxx:519
TEntryList::GetReapplyCut
virtual Bool_t GetReapplyCut() const
Definition: TEntryList.h:79
TEntryList::fEntriesToProcess
Long64_t fEntriesToProcess
used on proof to set the number of entries to process in a packet
Definition: TEntryList.h:37