Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
17class TTree;
18class TDirectory;
19class TObjArray;
20class TString;
21
22class TList;
23class TCollection;
24
25class 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 * = nullptr);
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 ~TEntryList() override;
63
64 virtual void Add(const TEntryList *elist);
65 void AddSubList(TEntryList *elist);
66 virtual Int_t Contains(Long64_t entry, TTree *tree = nullptr);
67 virtual void DirectoryAutoAdd(TDirectory *);
68 virtual Bool_t Enter(Long64_t entry, TTree *tree = nullptr);
69 virtual Bool_t Enter(Long64_t localentry, const char *treename, const char *filename);
70 void EnterRange(Long64_t start, Long64_t end, TTree *tree = nullptr, UInt_t step = 1U);
71 virtual TEntryList *GetCurrentList() const { return fCurrent; };
72 virtual TEntryList *GetEntryList(const char *treename, const char *filename, Option_t *opt="");
74 virtual Long64_t GetEntryAndTree(Long64_t index, Int_t &treenum);
76 virtual TList *GetLists() const { return fLists; }
77 virtual TDirectory *GetDirectory() const { return fDirectory; }
78 virtual Long64_t GetN() const { return fN; }
79 virtual const char *GetTreeName() const { return fTreeName.Data(); }
80 virtual const char *GetFileName() const { return fFileName.Data(); }
81 virtual Int_t GetTreeNumber() const { return fTreeNumber; }
82 virtual Bool_t GetReapplyCut() const { return fReapply; };
83
85 {
86 if ((fLists || fBlocks)) return kTRUE;
87 return kFALSE;
88 }
89
90 virtual Int_t Merge(TCollection *list);
91
92 virtual Long64_t Next();
93 virtual void OptimizeStorage();
94 virtual Int_t RelocatePaths(const char *newloc, const char *oldloc = nullptr);
95 virtual Bool_t Remove(Long64_t entry, TTree *tree = nullptr);
96 virtual void Reset();
97 virtual Int_t ScanPaths(TList *roots, Bool_t notify = kTRUE);
98
99 void Print(const Option_t* option = "") const override;
100 virtual void SetDirectory(TDirectory *dir);
101 virtual void SetEntriesToProcess(Long64_t nen) { fEntriesToProcess = nen; }
102 virtual void SetShift(Bool_t shift) { fShift = shift; };
103 virtual void SetTree(const TTree *tree);
104 virtual void SetTree(const char *treename, const char *filename);
105 virtual void SetTreeName(const char *treename){ fTreeName = treename; };
106 virtual void SetFileName(const char *filename){ fFileName = filename; };
108 virtual void SetReapplyCut(Bool_t apply = kFALSE) {fReapply = apply;}; // *TOGGLE* *GETTER=GetReapplyCut
109 virtual void Subtract(const TEntryList *elist);
110
111 static Int_t Relocate(const char *fn,
112 const char *newroot, const char *oldroot = nullptr, const char *enlnm = nullptr);
113 static Int_t Scan(const char *fn, TList *roots);
114
115// Preventing warnings with -Weffc++ in GCC since the overloading of the || operator was a design choice.
116#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
117#pragma GCC diagnostic push
118#pragma GCC diagnostic ignored "-Weffc++"
119#endif
120 friend TEntryList operator||(TEntryList& elist1, TEntryList& elist2);
121#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
122#pragma GCC diagnostic pop
123#endif
124
125 ClassDefOverride(TEntryList, 2); //A list of entries in a TTree
126};
127#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
Definition TGX11.cxx:110
Collection abstract base class.
Definition TCollection.h:65
Describe directory structure in memory.
Definition TDirectory.h:45
A List of entry numbers in a TTree or TChain.
Definition TEntryList.h:26
Long64_t fLastIndexQueried
! used to optimize GetEntry() function from a loop
Definition TEntryList.h:44
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...
Long64_t fEntriesToProcess
used on proof to set the number of entries to process in a packet
Definition TEntryList.h:37
Bool_t fReapply
If true, TTree::Draw will 'reapply' the original cut.
Definition TEntryList.h:49
virtual Int_t GetTreeNumber() const
Definition TEntryList.h:81
TString fFileName
name of the file, where the tree is
Definition TEntryList.h:39
virtual void OptimizeStorage()
Checks if the array representation is more economical and if so, switches to it.
virtual void SetShift(Bool_t shift)
Definition TEntryList.h:102
virtual TList * GetLists() const
Definition TEntryList.h:76
virtual Int_t Contains(Long64_t entry, TTree *tree=nullptr)
virtual Bool_t Remove(Long64_t entry, TTree *tree=nullptr)
Remove entry #entry from the list.
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
virtual void SetReapplyCut(Bool_t apply=kFALSE)
Definition TEntryList.h:108
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,...
virtual Long64_t GetEntriesToProcess() const
Definition TEntryList.h:75
TDirectory * fDirectory
! Pointer to directory holding this tree
Definition TEntryList.h:48
virtual void SetEntriesToProcess(Long64_t nen)
Definition TEntryList.h:101
virtual TDirectory * GetDirectory() const
Definition TEntryList.h:77
TObjArray * fBlocks
blocks with indices of passing events (TEntryListBlocks)
Definition TEntryList.h:35
TEntryList & operator=(const TEntryList &)
virtual Long64_t GetEntryAndTree(Long64_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...
virtual const char * GetFileName() const
Definition TEntryList.h:80
virtual Bool_t Enter(Long64_t entry, TTree *tree=nullptr)
Add entry #entry to the list.
static Int_t Scan(const char *fn, TList *roots)
Scan TEntryList in 'fn' to find the common parts of paths.
virtual void DirectoryAutoAdd(TDirectory *)
Called by TKey and others to automatically add us to a directory when we are read from a file.
Long64_t fN
number of entries in the list
Definition TEntryList.h:36
virtual void SetTreeNumber(Int_t index)
Definition TEntryList.h:107
Long64_t fLastIndexReturned
! used to optimize GetEntry() function from a loop
Definition TEntryList.h:45
virtual Bool_t GetReapplyCut() const
Definition TEntryList.h:82
virtual Long64_t Next()
Return the next non-zero entry index (next after fLastIndexQueried) this function is faster than GetE...
virtual void SetDirectory(TDirectory *dir)
Add reference to directory dir. dir can be 0.
void EnterRange(Long64_t start, Long64_t end, TTree *tree=nullptr, UInt_t step=1U)
Enter all entries in a range in the TEntryList.
virtual TEntryList * GetCurrentList() const
Definition TEntryList.h:71
virtual void SetTreeName(const char *treename)
Definition TEntryList.h:105
virtual void Reset()
Reset this list.
Int_t fNBlocks
number of TEntryListBlocks
Definition TEntryList.h:34
virtual Long64_t GetEntry(Long64_t index)
Return the number of the entry #index of this TEntryList in the TTree or TChain See also Next().
virtual void SetFileName(const char *filename)
Definition TEntryList.h:106
virtual Int_t RelocatePaths(const char *newloc, const char *oldloc=nullptr)
Relocate the file paths.
virtual const char * GetTreeName() const
Definition TEntryList.h:79
virtual Int_t Merge(TCollection *list)
Merge this list with the lists from the collection.
TEntryList * fCurrent
! currently filled entry list
Definition TEntryList.h:32
void Print(const Option_t *option="") const override
Print this list.
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
ULong_t fStringHash
! Hash value of a string of treename and filename
Definition TEntryList.h:40
static Int_t Relocate(const char *fn, const char *newroot, const char *oldroot=nullptr, const char *enlnm=nullptr)
Relocate entry list 'enlnm' in file 'fn' replacing 'oldroot' with 'newroot' in filenames.
Bool_t IsValid() const
Definition TEntryList.h:84
TList * fLists
a list of underlying entry lists for each tree of a chain
Definition TEntryList.h:31
virtual Int_t ScanPaths(TList *roots, Bool_t notify=kTRUE)
Scan the paths to find the common roots.
~TEntryList() override
Destructor.
TString fTreeName
name of the tree
Definition TEntryList.h:38
void AddSubList(TEntryList *elist)
Add a sub entry list to the current list.
TEntryList()
default c-tor
virtual void Subtract(const TEntryList *elist)
Remove all the entries of this entry list, that are contained in elist.
virtual void Add(const TEntryList *elist)
Add 2 entry lists.
friend TEntryList operator||(TEntryList &elist1, TEntryList &elist2)
virtual Long64_t GetN() const
Definition TEntryList.h:78
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
An array of TObjects.
Definition TObjArray.h:31
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:380
A TTree represents a columnar dataset.
Definition TTree.h:79
Definition tree.py:1
TCanvas * roots()
Definition roots.C:1