Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
16 #include "TNamed.h"
17 #endif
18 
19 class TTree;
20 class TDirectory;
21 class TObjArray;
22 class TString;
23 
24 class TList;
25 class TCollection;
26 
27 class TEntryList: public TNamed
28 {
29  private:
30  TEntryList& operator=(const TEntryList&); // Not implemented
31 
32  protected:
33  TList *fLists; ///< a list of underlying entry lists for each tree of a chain
34  TEntryList *fCurrent; ///<! currently filled entry list
35 
36  Int_t fNBlocks; ///< number of TEntryListBlocks
37  TObjArray *fBlocks; ///< blocks with indices of passing events (TEntryListBlocks)
38  Long64_t fN; ///< number of entries in the list
39  Long64_t fEntriesToProcess; ///< used on proof to set the number of entries to process in a packet
40  TString fTreeName; ///< name of the tree
41  TString fFileName; ///< name of the file, where the tree is
42  ULong_t fStringHash; ///<! Hash value of a string of treename and filename
43  Int_t fTreeNumber; ///<! the index of the tree in the chain (used when the entry
44  ///< list is used as input (TTree::SetEntryList())
45 
46  Long64_t fLastIndexQueried; ///<! used to optimize GetEntry() function from a loop
47  Long64_t fLastIndexReturned; ///<! used to optimize GetEntry() function from a loop
48  Bool_t fShift; ///<! true when some sub-lists don't correspond to trees
49  ///< (when the entry list is used as input in TChain)
50  TDirectory *fDirectory; ///<! Pointer to directory holding this tree
51  Bool_t fReapply; ///< If true, TTree::Draw will 'reapply' the original cut
52 
53  void GetFileName(const char *filename, TString &fn, Bool_t * = 0);
54 
55  public:
56  enum {kBlockSize = 64000}; //number of entries in each block (not the physical size).
57 
58  TEntryList();
59  TEntryList(const char *name, const char *title);
60  TEntryList(const char *name, const char *title, const TTree *tree);
61  TEntryList(const char *name, const char *title, const char *treename, const char *filename);
62  TEntryList(const TTree *tree);
63  TEntryList(const TEntryList& elist);
64  virtual ~TEntryList();
65 
66  virtual void Add(const TEntryList *elist);
67  virtual Int_t Contains(Long64_t entry, TTree *tree = 0);
68  virtual void DirectoryAutoAdd(TDirectory *);
69  virtual Bool_t Enter(Long64_t entry, TTree *tree = 0);
70  virtual TEntryList *GetCurrentList() const { return fCurrent; };
71  virtual TEntryList *GetEntryList(const char *treename, const char *filename, Option_t *opt="");
72  virtual Long64_t GetEntry(Int_t index);
73  virtual Long64_t GetEntryAndTree(Int_t index, Int_t &treenum);
75  virtual TList *GetLists() const { return fLists; }
76  virtual TDirectory *GetDirectory() const { return fDirectory; }
77  virtual Long64_t GetN() const { return fN; }
78  virtual const char *GetTreeName() const { return fTreeName.Data(); }
79  virtual const char *GetFileName() const { return fFileName.Data(); }
80  virtual Int_t GetTreeNumber() const { return fTreeNumber; }
81  virtual Bool_t GetReapplyCut() const { return fReapply; };
82  virtual Int_t Merge(TCollection *list);
83 
84  virtual Long64_t Next();
85  virtual void OptimizeStorage();
86  virtual Int_t RelocatePaths(const char *newloc, const char *oldloc = 0);
87  virtual Bool_t Remove(Long64_t entry, TTree *tree = 0);
88  virtual void Reset();
89  virtual Int_t ScanPaths(TList *roots, Bool_t notify = kTRUE);
90 
91  virtual void Print(const Option_t* option = "") const;
92  virtual void SetDirectory(TDirectory *dir);
93  virtual void SetEntriesToProcess(Long64_t nen) { fEntriesToProcess = nen; }
94  virtual void SetShift(Bool_t shift) { fShift = shift; };
95  virtual void SetTree(const TTree *tree);
96  virtual void SetTree(const char *treename, const char *filename);
97  virtual void SetTreeName(const char *treename){ fTreeName = treename; };
98  virtual void SetFileName(const char *filename){ fFileName = filename; };
99  virtual void SetTreeNumber(Int_t index) { fTreeNumber=index; }
100  virtual void SetReapplyCut(Bool_t apply = kFALSE) {fReapply = apply;}; // *TOGGLE* *GETTER=GetReapplyCut
101  virtual void Subtract(const TEntryList *elist);
102 
103  static Int_t Relocate(const char *fn,
104  const char *newroot, const char *oldroot = 0, const char *enlnm = 0);
105  static Int_t Scan(const char *fn, TList *roots);
106 
107 // Preventing warnings with -Weffc++ in GCC since the overloading of the || operator was a design choice.
108 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
109 #pragma GCC diagnostic push
110 #pragma GCC diagnostic ignored "-Weffc++"
111 #endif
112  friend TEntryList operator||(TEntryList& elist1, TEntryList& elist2);
113 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
114 #pragma GCC diagnostic pop
115 #endif
116 
117  ClassDef(TEntryList, 2); //A list of entries in a TTree
118 };
119 #endif
virtual void SetEntriesToProcess(Long64_t nen)
Definition: TEntryList.h:93
virtual void SetFileName(const char *filename)
Definition: TEntryList.h:98
Long64_t fEntriesToProcess
used on proof to set the number of entries to process in a packet
Definition: TEntryList.h:39
virtual void SetTreeName(const char *treename)
Definition: TEntryList.h:97
An array of TObjects.
Definition: TObjArray.h:39
virtual Long64_t Next()
Return the next non-zero entry index (next after fLastIndexQueried) this function is faster than GetE...
Definition: TEntryList.cxx:888
virtual TDirectory * GetDirectory() const
Definition: TEntryList.h:76
long long Long64_t
Definition: RtypesCore.h:69
virtual Long64_t GetN() const
Definition: TEntryList.h:77
virtual void SetReapplyCut(Bool_t apply=kFALSE)
Definition: TEntryList.h:100
virtual const char * GetFileName() const
Definition: TEntryList.h:79
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t GetTreeNumber() const
Definition: TEntryList.h:80
virtual TList * GetLists() const
Definition: TEntryList.h:75
virtual ~TEntryList()
Destructor.
Definition: TEntryList.cxx:323
Basic string class.
Definition: TString.h:137
virtual void OptimizeStorage()
Checks if the array representation is more economical and if so, switches to it.
Definition: TEntryList.cxx:975
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetShift(Bool_t shift)
Definition: TEntryList.h:94
Int_t fNBlocks
number of TEntryListBlocks
Definition: TEntryList.h:36
TList * fLists
a list of underlying entry lists for each tree of a chain
Definition: TEntryList.h:33
static Int_t Scan(const char *fn, TList *roots)
Scan TEntryList in &#39;fn&#39; to find the common parts of paths.
Long64_t fLastIndexQueried
! used to optimize GetEntry() function from a loop
Definition: TEntryList.h:46
ULong_t fStringHash
! Hash value of a string of treename and filename
Definition: TEntryList.h:42
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...
Bool_t fShift
! true when some sub-lists don&#39;t correspond to trees (when the entry list is used as input in TChain)...
Definition: TEntryList.h:48
TEntryList & operator=(const TEntryList &)
virtual void SetDirectory(TDirectory *dir)
Add reference to directory dir. dir can be 0.
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual Long64_t GetEntriesToProcess() const
Definition: TEntryList.h:74
TCanvas * roots()
Definition: roots.C:1
TDirectory * fDirectory
! Pointer to directory holding this tree
Definition: TEntryList.h:50
A doubly linked list.
Definition: TList.h:47
Bool_t fReapply
If true, TTree::Draw will &#39;reapply&#39; the original cut.
Definition: TEntryList.h:51
virtual void Add(const TEntryList *elist)
Add 2 entry lists.
Definition: TEntryList.cxx:345
TString fTreeName
name of the tree
Definition: TEntryList.h:40
friend TEntryList operator||(TEntryList &elist1, TEntryList &elist2)
TEntryList * fCurrent
! currently filled entry list
Definition: TEntryList.h:34
Collection abstract base class.
Definition: TCollection.h:48
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:655
virtual Int_t Contains(Long64_t entry, TTree *tree=0)
Definition: TEntryList.cxx:519
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
virtual Int_t ScanPaths(TList *roots, Bool_t notify=kTRUE)
Scan the paths to find the common roots.
Long64_t fN
number of entries in the list
Definition: TEntryList.h:38
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:731
virtual Int_t Merge(TCollection *list)
Merge this list with the lists from the collection.
Definition: TEntryList.cxx:869
Long64_t fLastIndexReturned
! used to optimize GetEntry() function from a loop
Definition: TEntryList.h:47
Describe directory structure in memory.
Definition: TDirectory.h:44
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual Bool_t GetReapplyCut() const
Definition: TEntryList.h:81
TEntryList()
default c-tor
Definition: TEntryList.cxx:161
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
Definition: TEntryList.cxx:560
TObjArray * fBlocks
blocks with indices of passing events (TEntryListBlocks)
Definition: TEntryList.h:37
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:43
virtual TEntryList * GetCurrentList() const
Definition: TEntryList.h:70
virtual void Print(const Option_t *option="") const
Print this list.
Definition: TEntryList.cxx:991
virtual void Reset()
Reset this list.
virtual const char * GetTreeName() const
Definition: TEntryList.h:78
virtual Bool_t Remove(Long64_t entry, TTree *tree=0)
Remove entry #entry from the list.
Definition: TEntryList.cxx:615
virtual 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 ...
Definition: TEntryList.cxx:779
virtual void SetTreeNumber(Int_t index)
Definition: TEntryList.h:99
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TString fFileName
name of the file, where the tree is
Definition: TEntryList.h:41
static Int_t Relocate(const char *fn, const char *newroot, const char *oldroot=0, const char *enlnm=0)
Relocate entry list &#39;enlnm&#39; in file &#39;fn&#39; replacing &#39;oldroot&#39; with &#39;newroot&#39; in filenames.
const Bool_t kTRUE
Definition: Rtypes.h:91
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
virtual void Subtract(const TEntryList *elist)
Remove all the entries of this entry list, that are contained in elist.
decltype(auto) constexpr apply(F &&f, Tuple &&t)
char name[80]
Definition: TGX11.cxx:109
virtual Int_t RelocatePaths(const char *newloc, const char *oldloc=0)
Relocate the file paths.
const char * Data() const
Definition: TString.h:349