Logo ROOT  
Reference Guide
TEventIter.h
Go to the documentation of this file.
1 // @(#)root/proofplayer:$Id$
2 // Author: Maarten Ballintijn 07/01/02
3 // Modified: Long Tran-Thanh 04/09/07 (Addition of TEventIterUnit)
4 
5 /*************************************************************************
6  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 #ifndef ROOT_TEventIter
14 #define ROOT_TEventIter
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TEventIter //
19 // //
20 // Special iterator class used in TProofPlayer to iterate over events //
21 // or objects in the packets. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "TNamed.h"
26 #include "TString.h"
27 
28 class TDSet;
29 class TDSetElement;
30 class TFile;
31 class TDirectory;
32 class TSelector;
33 class TList;
34 class TIter;
35 class TTree;
36 class TTreeCache;
37 class TEventList;
38 class TEntryList;
39 
40 //------------------------------------------------------------------------
41 
42 class TEventIter : public TObject {
43 
44 public:
45  enum EIterType { kData = 15}; // True if iterating over data
46 
47 protected:
48  TDSet *fDSet; // data set over which to iterate
49 
50  TDSetElement *fElem; // Current Element
51 
52  TString fFilename; // Name of the current file
53  TFile *fFile; // Current file
54  Long64_t fOldBytesRead; // last reported number of bytes read
55  TString fPath; // Path to current TDirectory
56  TDirectory *fDir; // directory containing the objects or the TTree
57  Long64_t fElemFirst; // first entry to process for this element
58  Long64_t fElemNum; // number of entries to process for this element
59  Long64_t fElemCur; // current entry for this element
60 
61  TSelector *fSel; // selector to be used
62  Long64_t fFirst; // first entry to process
63  Long64_t fNum; // number of entries to process
64  Long64_t fCur; // current entry
65  Bool_t fStop; // termination of run requested
66  TEventList *fEventList; //! eventList for processing
67  Int_t fEventListPos; //! current position in the eventList
68  TEntryList *fEntryList; //! entry list for processing
69  Long64_t fEntryListPos; //! current position in the entrylist
70 
71  TList *fPackets; // list of packets processed packets
72 
73  Int_t LoadDir(); // Load the directory pointed to by fElem
74  virtual void PreProcessEvent(Long64_t) { }
75 
76 public:
77  TEventIter();
78  TEventIter(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
79  virtual ~TEventIter();
80 
81  virtual Long64_t GetCacheSize() = 0;
82  virtual Int_t GetLearnEntries() = 0;
83  virtual Long64_t GetNextEvent() = 0;
84  virtual Int_t GetNextPacket(Long64_t &first, Long64_t &num) = 0;
85  virtual void InvalidatePacket();
87  virtual void StopProcess(Bool_t abort);
88 
89  TList *GetPackets() { return fPackets; }
90 
91  static TEventIter *Create(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
92 
93  ClassDef(TEventIter,0) // Event iterator used by TProofPlayer's
94 };
95 
96 
97 //------------------------------------------------------------------------
98 
99 class TEventIterUnit : public TEventIter {
100 
101 private:
104 
105 
106 public:
107  TEventIterUnit();
108  TEventIterUnit(TDSet *dset, TSelector *sel, Long64_t num);
110 
111  Long64_t GetCacheSize() {return -1;}
112  Int_t GetLearnEntries() {return -1;}
115 
116  ClassDef(TEventIterUnit,0) // Event iterator for objects
117 };
118 
119 
120 //------------------------------------------------------------------------
121 
122 class TEventIterObj : public TEventIter {
123 
124 private:
125  TString fClassName; // class name of objects to iterate over
126  TList *fKeys; // list of keys
127  TIter *fNextKey; // next key in directory
128  TObject *fObj; // object found
129 
130 protected:
132 
133 public:
134  TEventIterObj();
135  TEventIterObj(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
136  ~TEventIterObj();
137 
138  Long64_t GetCacheSize() {return -1;}
139  Int_t GetLearnEntries() {return -1;}
142 
143  ClassDef(TEventIterObj,0) // Event iterator for objects
144 };
145 
146 
147 //------------------------------------------------------------------------
148 class TEventIterTree : public TEventIter {
149 
150 private:
151  TString fTreeName; // name of the tree object to iterate over
152  TTree *fTree; // tree we are iterating over
153  TTreeCache *fTreeCache; // instance of the tree cache for the tree
154  Bool_t fTreeCacheIsLearning; // Whether cache is in learning phase
155  Bool_t fUseTreeCache; // Control usage of the tree cache
156  Long64_t fCacheSize; // Cache size
157  Bool_t fUseParallelUnzip; // Control usage of parallel unzip
158  Bool_t fDontCacheFiles; // Control OS caching of read files (Mac Os X only)
159  TList *fFileTrees; // Files && Trees currently open
160 
161  // Auxilliary class to keep track open files and loaded trees
162  class TFileTree : public TNamed {
163  public:
168  TFileTree(const char *name, TFile *f, Bool_t islocal);
169  virtual ~TFileTree();
170  };
171 
172  TTree* Load(TDSetElement *elem, Bool_t &localfile, const char *objname = 0);
173  TTree* GetTrees(TDSetElement *elem);
174 
175 protected:
176  void PreProcessEvent(Long64_t ent);
177 
178 public:
179  TEventIterTree();
181  ~TEventIterTree();
182 
187 
188  ClassDef(TEventIterTree,0) // Event iterator for Trees
189 };
190 
191 #endif
TEventIter::GetPackets
TList * GetPackets()
Definition: TEventIter.h:89
TEventIterTree::TEventIterTree
TEventIterTree()
Default ctor.
Definition: TEventIter.cxx:690
TEventIterTree::TFileTree::~TFileTree
virtual ~TFileTree()
Default dtor.
Definition: TEventIter.cxx:673
TEventIterObj::PreProcessEvent
void PreProcessEvent(Long64_t)
To be executed before by TProofPlayer calling TSelector::Process.
Definition: TEventIter.cxx:544
first
Definition: first.py:1
TEventIter::fElem
TDSetElement * fElem
Definition: TEventIter.h:50
TEventIterTree::Load
TTree * Load(TDSetElement *elem, Bool_t &localfile, const char *objname=0)
Load a tree from s TDSetElement.
Definition: TEventIter.cxx:861
TEventIterTree::~TEventIterTree
~TEventIterTree()
Destructor.
Definition: TEventIter.cxx:730
TEventList
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:31
TSelector
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:31
TEventIter::fSel
TSelector * fSel
Definition: TEventIter.h:61
f
#define f(i)
Definition: RSha256.hxx:104
TEventIterUnit::~TEventIterUnit
~TEventIterUnit()
Definition: TEventIter.h:109
TEventIterTree::GetLearnEntries
Int_t GetLearnEntries()
Return the number of entries in the learning phase.
Definition: TEventIter.cxx:751
TEventIterUnit
Definition: TEventIter.h:99
TEventIter::fElemCur
Long64_t fElemCur
Definition: TEventIter.h:59
TEventIterTree::TFileTree::fUsed
Bool_t fUsed
Definition: TEventIter.h:164
TEventIter::fEventListPos
Int_t fEventListPos
eventList for processing
Definition: TEventIter.h:67
TEventIterUnit::TEventIterUnit
TEventIterUnit()
Default constructor.
Definition: TEventIter.cxx:256
TEventIter::Create
static TEventIter * Create(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num)
Create and instance of the appropriate iterator.
Definition: TEventIter.cxx:149
TEventIter::kData
@ kData
Definition: TEventIter.h:45
TEventIterTree::fCacheSize
Long64_t fCacheSize
Definition: TEventIter.h:156
TEventIter
Special iterator class used in TProofPlayer to iterate over events or objects in the packets.
Definition: TEventIter.h:42
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:80
TEventIterTree::fTree
TTree * fTree
Definition: TEventIter.h:152
TTree
A TTree represents a columnar dataset.
Definition: TTree.h:79
TEventIterObj::~TEventIterObj
~TEventIterObj()
Destructor.
Definition: TEventIter.cxx:434
TEventIter::fOldBytesRead
Long64_t fOldBytesRead
Definition: TEventIter.h:54
TEventIter::GetLearnEntries
virtual Int_t GetLearnEntries()=0
TEventIterUnit::GetNextEvent
Long64_t GetNextEvent()
Get next event.
Definition: TEventIter.cxx:340
Int_t
int Int_t
Definition: RtypesCore.h:45
TEventIterUnit::GetCacheSize
Long64_t GetCacheSize()
Definition: TEventIter.h:111
TEventIterUnit::fNum
Long64_t fNum
Definition: TEventIter.h:102
TEventIterTree::GetNextEvent
Long64_t GetNextEvent()
Get next event.
Definition: TEventIter.cxx:1189
TEventIter::fPath
TString fPath
Definition: TEventIter.h:55
TEventIterObj::fKeys
TList * fKeys
Definition: TEventIter.h:126
TEventIter::LoadDir
Int_t LoadDir()
Load directory.
Definition: TEventIter.cxx:163
TEventIterObj::GetNextPacket
Int_t GetNextPacket(Long64_t &first, Long64_t &num)
Get loop range.
Definition: TEventIter.cxx:444
TString
Basic string class.
Definition: TString.h:136
TEventIterTree::GetCacheSize
Long64_t GetCacheSize()
Return the size in bytes of the cache, if any Return -1 if not used.
Definition: TEventIter.cxx:742
TDSetElement
Manages an element of a TDSet.
Definition: TDSet.h:66
TEventIter::fDir
TDirectory * fDir
Definition: TEventIter.h:56
TString.h
TEventIter::fEntryList
TEntryList * fEntryList
current position in the eventList
Definition: TEventIter.h:68
bool
TEventIterTree::GetTrees
TTree * GetTrees(TDSetElement *elem)
Create a Tree for the main TDSetElement and for all the friends.
Definition: TEventIter.cxx:760
TEventIterTree::fTreeCacheIsLearning
Bool_t fTreeCacheIsLearning
Definition: TEventIter.h:154
TEventIter::fDSet
TDSet * fDSet
Definition: TEventIter.h:48
TEventIterTree::TFileTree::fTrees
TList * fTrees
Definition: TEventIter.h:167
TEventIter::fEventList
TEventList * fEventList
Definition: TEventIter.h:66
TEventIter::GetNextEvent
virtual Long64_t GetNextEvent()=0
TEventIterTree::TFileTree
Definition: TEventIter.h:162
TEventIterTree::TFileTree::fFile
TFile * fFile
Definition: TEventIter.h:166
TEventIterTree::fTreeName
TString fTreeName
Definition: TEventIter.h:151
TEventIterObj::GetLearnEntries
Int_t GetLearnEntries()
Definition: TEventIter.h:139
TEventIterObj
Definition: TEventIter.h:122
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TEventIter::fFile
TFile * fFile
Definition: TEventIter.h:53
TEventIterTree::fDontCacheFiles
Bool_t fDontCacheFiles
Definition: TEventIter.h:158
TEventIterTree::fUseParallelUnzip
Bool_t fUseParallelUnzip
Definition: TEventIter.h:157
TEventIterUnit::GetNextPacket
Int_t GetNextPacket(Long64_t &first, Long64_t &num)
Get loop range.
Definition: TEventIter.cxx:284
TEventIter::fElemNum
Long64_t fElemNum
Definition: TEventIter.h:58
TDSet
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:153
TEventIterTree::fFileTrees
TList * fFileTrees
Definition: TEventIter.h:159
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TEventIter::GetNextPacket
virtual Int_t GetNextPacket(Long64_t &first, Long64_t &num)=0
TEntryList
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:26
TEventIter::fFilename
TString fFilename
Definition: TEventIter.h:52
TEventIter::InvalidatePacket
virtual void InvalidatePacket()
Invalidated the current packet (if any) by setting the TDSetElement::kCorrupted bit.
Definition: TEventIter.cxx:133
TEventIter::EIterType
EIterType
Definition: TEventIter.h:45
TEventIterTree::PreProcessEvent
void PreProcessEvent(Long64_t ent)
Actions to be done just before processing entry 'entry'.
Definition: TEventIter.cxx:1165
TEventIterTree::TFileTree::fIsLocal
Bool_t fIsLocal
Definition: TEventIter.h:165
TTreeCache
A cache to speed-up the reading of ROOT datasets.
Definition: TTreeCache.h:32
TEventIter::fElemFirst
Long64_t fElemFirst
Definition: TEventIter.h:57
TEventIter::fStop
Bool_t fStop
Definition: TEventIter.h:65
TEventIterUnit::GetLearnEntries
Int_t GetLearnEntries()
Definition: TEventIter.h:112
TEventIter::fNum
Long64_t fNum
Definition: TEventIter.h:63
TEventIterTree::GetNextPacket
Int_t GetNextPacket(Long64_t &first, Long64_t &num)
Get loop range.
Definition: TEventIter.cxx:1009
TEventIter::StopProcess
virtual void StopProcess(Bool_t abort)
Set flag to stop the process.
Definition: TEventIter.cxx:141
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TEventIter::GetCacheSize
virtual Long64_t GetCacheSize()=0
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TEventIter::fFirst
Long64_t fFirst
Definition: TEventIter.h:62
name
char name[80]
Definition: TGX11.cxx:110
TEventIterObj::fClassName
TString fClassName
Definition: TEventIter.h:125
TEventIter::fEntryListPos
Long64_t fEntryListPos
entry list for processing
Definition: TEventIter.h:69
TEventIterObj::fNextKey
TIter * fNextKey
Definition: TEventIter.h:127
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:45
TEventIterTree
Definition: TEventIter.h:148
TIter
Definition: TCollection.h:233
TEventIter::~TEventIter
virtual ~TEventIter()
Destructor.
Definition: TEventIter.cxx:121
TEventIter::TEventIter
TEventIter()
Default constructor.
Definition: TEventIter.cxx:54
TEventIterTree::fTreeCache
TTreeCache * fTreeCache
Definition: TEventIter.h:153
TEventIterTree::fUseTreeCache
Bool_t fUseTreeCache
Definition: TEventIter.h:155
TEventIterObj::TEventIterObj
TEventIterObj()
Default ctor.
Definition: TEventIter.cxx:411
TEventIterTree::TFileTree::TFileTree
TFileTree(const char *name, TFile *f, Bool_t islocal)
Default ctor.
Definition: TEventIter.cxx:664
TEventIter::fPackets
TList * fPackets
current position in the entrylist
Definition: TEventIter.h:71
TEventIterObj::GetCacheSize
Long64_t GetCacheSize()
Definition: TEventIter.h:138
TEventIter::fCur
Long64_t fCur
Definition: TEventIter.h:64
TEventIter::PreProcessEvent
virtual void PreProcessEvent(Long64_t)
Definition: TEventIter.h:74
TEventIterObj::GetNextEvent
Long64_t GetNextEvent()
Get next event.
Definition: TEventIter.cxx:559
TList
A doubly linked list.
Definition: TList.h:44
TEventIterObj::fObj
TObject * fObj
Definition: TEventIter.h:128
TEventIterUnit::fCurrent
Long64_t fCurrent
Definition: TEventIter.h:103
int
TEventIter::GetEntryNumber
virtual Long64_t GetEntryNumber(Long64_t)
Definition: TEventIter.cxx:229