Logo ROOT   6.14/05
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
virtual Long64_t GetNextEvent()=0
Int_t GetLearnEntries()
Definition: TEventIter.h:112
long long Long64_t
Definition: RtypesCore.h:69
Long64_t GetCacheSize()
Definition: TEventIter.h:138
Long64_t fCurrent
Definition: TEventIter.h:103
TFile * fFile
Definition: TEventIter.h:53
TString fFilename
Definition: TEventIter.h:52
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:153
A specialized TFileCacheRead object for a TTree.
Definition: TTreeCache.h:35
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:47
TList * fKeys
Definition: TEventIter.h:126
Long64_t fElemNum
Definition: TEventIter.h:58
Long64_t fElemFirst
Definition: TEventIter.h:57
Basic string class.
Definition: TString.h:131
virtual Int_t GetNextPacket(Long64_t &first, Long64_t &num)=0
Bool_t fStop
Definition: TEventIter.h:65
#define f(i)
Definition: RSha256.hxx:104
Long64_t fNum
Definition: TEventIter.h:63
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void StopProcess(Bool_t abort)
Set flag to stop the process.
Definition: TEventIter.cxx:142
virtual Long64_t GetCacheSize()=0
virtual void InvalidatePacket()
Invalidated the current packet (if any) by setting the TDSetElement::kCorrupted bit.
Definition: TEventIter.cxx:134
TObject * fObj
Definition: TEventIter.h:128
virtual ~TEventIter()
Destructor.
Definition: TEventIter.cxx:122
TEventIter()
Default constructor.
Definition: TEventIter.cxx:55
TTree * fTree
Definition: TEventIter.h:152
Manages an element of a TDSet.
Definition: TDSet.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:320
Bool_t fUseParallelUnzip
Definition: TEventIter.h:157
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Long64_t fEntryListPos
entry list for processing
Definition: TEventIter.h:69
Long64_t fFirst
Definition: TEventIter.h:62
TList * fPackets
current position in the entrylist
Definition: TEventIter.h:71
virtual void PreProcessEvent(Long64_t)
Definition: TEventIter.h:74
Bool_t fDontCacheFiles
Definition: TEventIter.h:158
virtual Long64_t GetEntryNumber(Long64_t)
Definition: TEventIter.cxx:230
TList * GetPackets()
Definition: TEventIter.h:89
Long64_t fNum
Definition: TEventIter.h:102
Bool_t fTreeCacheIsLearning
Definition: TEventIter.h:154
A doubly linked list.
Definition: TList.h:44
Long64_t fCacheSize
Definition: TEventIter.h:156
Long64_t fCur
Definition: TEventIter.h:64
TIter * fNextKey
Definition: TEventIter.h:127
Long64_t fElemCur
Definition: TEventIter.h:59
Int_t fEventListPos
eventList for processing
Definition: TEventIter.h:67
TString fTreeName
Definition: TEventIter.h:151
TDSetElement * fElem
Definition: TEventIter.h:50
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:31
Special iterator class used in TProofPlayer to iterate over events or objects in the packets...
Definition: TEventIter.h:42
TSelector * fSel
Definition: TEventIter.h:61
static TEventIter * Create(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num)
Create and instance of the appropriate iterator.
Definition: TEventIter.cxx:150
TList * fFileTrees
Definition: TEventIter.h:159
Describe directory structure in memory.
Definition: TDirectory.h:34
TString fPath
Definition: TEventIter.h:55
TString fClassName
Definition: TEventIter.h:125
Long64_t fOldBytesRead
Definition: TEventIter.h:54
Int_t LoadDir()
Load directory.
Definition: TEventIter.cxx:164
virtual Int_t GetLearnEntries()=0
TTreeCache * fTreeCache
Definition: TEventIter.h:153
Mother of all ROOT objects.
Definition: TObject.h:37
TDirectory * fDir
Definition: TEventIter.h:56
TEntryList * fEntryList
current position in the eventList
Definition: TEventIter.h:68
Int_t GetLearnEntries()
Definition: TEventIter.h:139
Bool_t fUseTreeCache
Definition: TEventIter.h:155
Long64_t GetCacheSize()
Definition: TEventIter.h:111
TEventList * fEventList
Definition: TEventIter.h:66
A TTree object has a header with a name and a title.
Definition: TTree.h:70
Definition: first.py:1
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:33
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:25
TDSet * fDSet
Definition: TEventIter.h:48
char name[80]
Definition: TGX11.cxx:109