ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TNamed
26 #include "TNamed.h"
27 #endif
28 #ifndef ROOT_TString
29 #include "TString.h"
30 #endif
31 
32 class TDSet;
33 class TDSetElement;
34 class TFile;
35 class TDirectory;
36 class TSelector;
37 class TList;
38 class TIter;
39 class TTree;
40 class TTreeCache;
41 class TEventList;
42 class TEntryList;
43 
44 //------------------------------------------------------------------------
45 
46 class TEventIter : public TObject {
47 
48 public:
49  enum EIterType { kData = 15}; // True if iterating over data
50 
51 protected:
52  TDSet *fDSet; // data set over which to iterate
53 
54  TDSetElement *fElem; // Current Element
55 
56  TString fFilename; // Name of the current file
57  TFile *fFile; // Current file
58  Long64_t fOldBytesRead; // last reported number of bytes read
59  TString fPath; // Path to current TDirectory
60  TDirectory *fDir; // directory containing the objects or the TTree
61  Long64_t fElemFirst; // first entry to process for this element
62  Long64_t fElemNum; // number of entries to process for this element
63  Long64_t fElemCur; // current entry for this element
64 
65  TSelector *fSel; // selector to be used
66  Long64_t fFirst; // first entry to process
67  Long64_t fNum; // number of entries to process
68  Long64_t fCur; // current entry
69  Bool_t fStop; // termination of run requested
70  TEventList *fEventList; //! eventList for processing
71  Int_t fEventListPos; //! current position in the eventList
72  TEntryList *fEntryList; //! entry list for processing
73  Long64_t fEntryListPos; //! current position in the entrylist
74 
75  TList *fPackets; // list of packets processed packets
76 
77  Int_t LoadDir(); // Load the directory pointed to by fElem
78  virtual void PreProcessEvent(Long64_t) { }
79 
80 public:
81  TEventIter();
82  TEventIter(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
83  virtual ~TEventIter();
84 
85  virtual Long64_t GetCacheSize() = 0;
86  virtual Int_t GetLearnEntries() = 0;
87  virtual Long64_t GetNextEvent() = 0;
88  virtual Int_t GetNextPacket(Long64_t &first, Long64_t &num) = 0;
89  virtual void InvalidatePacket();
91  virtual void StopProcess(Bool_t abort);
92 
93  TList *GetPackets() { return fPackets; }
94 
95  static TEventIter *Create(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
96 
97  ClassDef(TEventIter,0) // Event iterator used by TProofPlayer's
98 };
99 
100 
101 //------------------------------------------------------------------------
102 
103 class TEventIterUnit : public TEventIter {
104 
105 private:
108 
109 
110 public:
111  TEventIterUnit();
112  TEventIterUnit(TDSet *dset, TSelector *sel, Long64_t num);
114 
115  Long64_t GetCacheSize() {return -1;}
116  Int_t GetLearnEntries() {return -1;}
119 
120  ClassDef(TEventIterUnit,0) // Event iterator for objects
121 };
122 
123 
124 //------------------------------------------------------------------------
125 
126 class TEventIterObj : public TEventIter {
127 
128 private:
129  TString fClassName; // class name of objects to iterate over
130  TList *fKeys; // list of keys
131  TIter *fNextKey; // next key in directory
132  TObject *fObj; // object found
133 
134 protected:
136 
137 public:
138  TEventIterObj();
139  TEventIterObj(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
140  ~TEventIterObj();
141 
142  Long64_t GetCacheSize() {return -1;}
143  Int_t GetLearnEntries() {return -1;}
146 
147  ClassDef(TEventIterObj,0) // Event iterator for objects
148 };
149 
150 
151 //------------------------------------------------------------------------
152 class TEventIterTree : public TEventIter {
153 
154 private:
155  TString fTreeName; // name of the tree object to iterate over
156  TTree *fTree; // tree we are iterating over
157  TTreeCache *fTreeCache; // instance of the tree cache for the tree
158  Bool_t fTreeCacheIsLearning; // Whether cache is in learning phase
159  Bool_t fUseTreeCache; // Control usage of the tree cache
160  Long64_t fCacheSize; // Cache size
161  Bool_t fUseParallelUnzip; // Control usage of parallel unzip
162  Bool_t fDontCacheFiles; // Control OS caching of read files (Mac Os X only)
163  TList *fFileTrees; // Files && Trees currently open
164 
165  // Auxilliary class to keep track open files and loaded trees
166  class TFileTree : public TNamed {
167  public:
172  TFileTree(const char *name, TFile *f, Bool_t islocal);
173  virtual ~TFileTree();
174  };
175 
176  TTree* Load(TDSetElement *elem, Bool_t &localfile, const char *objname = 0);
177  TTree* GetTrees(TDSetElement *elem);
178 
179 protected:
180  void PreProcessEvent(Long64_t ent);
181 
182 public:
183  TEventIterTree();
185  ~TEventIterTree();
186 
191 
192  ClassDef(TEventIterTree,0) // Event iterator for Trees
193 };
194 
195 #endif
virtual Long64_t GetNextEvent()=0
Int_t GetLearnEntries()
Definition: TEventIter.h:116
long long Long64_t
Definition: RtypesCore.h:69
Long64_t GetCacheSize()
Definition: TEventIter.h:142
~TEventIterObj()
Destructor.
Definition: TEventIter.cxx:435
Long64_t fCurrent
Definition: TEventIter.h:107
Long64_t GetCacheSize()
Return the size in bytes of the cache, if any Return -1 if not used.
Definition: TEventIter.cxx:743
Long64_t GetNextEvent()
Get next event.
Definition: TEventIter.cxx:341
TFile * fFile
Definition: TEventIter.h:57
TString fFilename
Definition: TEventIter.h:56
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:34
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
TList * fKeys
Definition: TEventIter.h:130
Long64_t fElemNum
Definition: TEventIter.h:62
Long64_t fElemFirst
Definition: TEventIter.h:61
Basic string class.
Definition: TString.h:137
virtual Int_t GetNextPacket(Long64_t &first, Long64_t &num)=0
Bool_t fStop
Definition: TEventIter.h:69
Long64_t fNum
Definition: TEventIter.h:67
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
TFile * f
Long64_t GetNextEvent()
Get next event.
Definition: TEventIter.cxx:560
TObject * fObj
Definition: TEventIter.h:132
virtual ~TEventIter()
Destructor.
Definition: TEventIter.cxx:122
TTree * fTree
Definition: TEventIter.h:156
Manages an element of a TDSet.
Definition: TDSet.h:68
Long64_t GetNextEvent()
Get next event.
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t fUseParallelUnzip
Definition: TEventIter.h:161
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Long64_t fEntryListPos
entry list for processing
Definition: TEventIter.h:73
Long64_t fFirst
Definition: TEventIter.h:66
TList * fPackets
current position in the entrylist
Definition: TEventIter.h:75
virtual void PreProcessEvent(Long64_t)
Definition: TEventIter.h:78
Bool_t fDontCacheFiles
Definition: TEventIter.h:162
virtual Long64_t GetEntryNumber(Long64_t)
Definition: TEventIter.cxx:230
TList * GetPackets()
Definition: TEventIter.h:93
void PreProcessEvent(Long64_t ent)
Actions to be done just before processing entry 'entry'.
Long64_t fNum
Definition: TEventIter.h:106
Bool_t fTreeCacheIsLearning
Definition: TEventIter.h:158
A doubly linked list.
Definition: TList.h:47
Long64_t fCacheSize
Definition: TEventIter.h:160
Long64_t fCur
Definition: TEventIter.h:68
TIter * fNextKey
Definition: TEventIter.h:131
TTree * GetTrees(TDSetElement *elem)
Create a Tree for the main TDSetElement and for all the friends.
Definition: TEventIter.cxx:761
Long64_t fElemCur
Definition: TEventIter.h:63
Int_t fEventListPos
eventList for processing
Definition: TEventIter.h:71
TString fTreeName
Definition: TEventIter.h:155
bool first
Definition: line3Dfit.C:48
TDSetElement * fElem
Definition: TEventIter.h:54
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
Special iterator class used in TProofPlayer to iterate over events or objects in the packets...
Definition: TEventIter.h:46
Int_t GetNextPacket(Long64_t &first, Long64_t &num)
Get loop range.
Definition: TEventIter.cxx:445
TSelector * fSel
Definition: TEventIter.h:65
virtual ~TFileTree()
Default dtor.
Definition: TEventIter.cxx:674
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:163
TTree * Load(TDSetElement *elem, Bool_t &localfile, const char *objname=0)
Load a tree from s TDSetElement.
Definition: TEventIter.cxx:861
~TEventIterTree()
Destructor.
Definition: TEventIter.cxx:731
void PreProcessEvent(Long64_t)
To be executed before by TProofPlayer calling TSelector::Process.
Definition: TEventIter.cxx:545
Describe directory structure in memory.
Definition: TDirectory.h:44
TString fPath
Definition: TEventIter.h:59
TString fClassName
Definition: TEventIter.h:129
Long64_t fOldBytesRead
Definition: TEventIter.h:58
Int_t LoadDir()
Load directory.
Definition: TEventIter.cxx:164
virtual Int_t GetLearnEntries()=0
TTreeCache * fTreeCache
Definition: TEventIter.h:157
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
TDirectory * fDir
Definition: TEventIter.h:60
TEntryList * fEntryList
current position in the eventList
Definition: TEventIter.h:72
Int_t GetNextPacket(Long64_t &first, Long64_t &num)
Get loop range.
Int_t GetLearnEntries()
Return the number of entries in the learning phase.
Definition: TEventIter.cxx:752
Int_t GetLearnEntries()
Definition: TEventIter.h:143
Bool_t fUseTreeCache
Definition: TEventIter.h:159
Long64_t GetCacheSize()
Definition: TEventIter.h:115
Int_t GetNextPacket(Long64_t &first, Long64_t &num)
Get loop range.
Definition: TEventIter.cxx:285
TEventList * fEventList
Definition: TEventIter.h:70
A TTree object has a header with a name and a title.
Definition: TTree.h:98
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
TDSet * fDSet
Definition: TEventIter.h:52
TFileTree(const char *name, TFile *f, Bool_t islocal)
Default ctor.
Definition: TEventIter.cxx:665