TEventIter.h

Go to the documentation of this file.
00001 // @(#)root/proofplayer:$Id: TEventIter.h 30859 2009-10-24 14:53:07Z ganis $
00002 // Author: Maarten Ballintijn   07/01/02
00003 // Modified: Long Tran-Thanh    04/09/07  (Addition of TEventIterUnit)
00004 
00005 /*************************************************************************
00006  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #ifndef ROOT_TEventIter
00014 #define ROOT_TEventIter
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TEventIter                                                           //
00019 //                                                                      //
00020 // Special iterator class used in TProofPlayer to iterate over events   //
00021 // or objects in the packets.                                           //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TNamed
00026 #include "TNamed.h"
00027 #endif
00028 #ifndef ROOT_TString
00029 #include "TString.h"
00030 #endif
00031 
00032 class TDSet;
00033 class TDSetElement;
00034 class TFile;
00035 class TDirectory;
00036 class TSelector;
00037 class TList;
00038 class TIter;
00039 class TTree;
00040 class TTreeCache;
00041 class TEventList;
00042 class TEntryList;
00043 
00044 //------------------------------------------------------------------------
00045 
00046 class TEventIter : public TObject {
00047 
00048 protected:
00049    TDSet         *fDSet;         // data set over which to iterate
00050 
00051    TDSetElement  *fElem;         // Current Element
00052 
00053    TString        fFilename;     // Name of the current file
00054    TFile         *fFile;         // Current file
00055    Long64_t       fOldBytesRead; // last reported number of bytes read
00056    TString        fPath;         // Path to current TDirectory
00057    TDirectory    *fDir;          // directory containing the objects or the TTree
00058    Long64_t       fElemFirst;    // first entry to process for this element
00059    Long64_t       fElemNum;      // number of entries to process for this element
00060    Long64_t       fElemCur;      // current entry for this element
00061 
00062    TSelector     *fSel;          // selector to be used
00063    Long64_t       fFirst;        // first entry to process
00064    Long64_t       fNum;          // number of entries to process
00065    Long64_t       fCur;          // current entry
00066    Bool_t         fStop;         // termination of run requested
00067    TEventList    *fEventList;    //! eventList for processing
00068    Int_t          fEventListPos; //! current position in the eventList
00069    TEntryList    *fEntryList;    //! entry list for processing
00070    Long64_t       fEntryListPos; //! current position in the entrylist
00071 
00072    Int_t          LoadDir();     // Load the directory pointed to by fElem
00073 
00074 public:
00075    TEventIter();
00076    TEventIter(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
00077    virtual ~TEventIter();
00078 
00079    virtual Long64_t  GetCacheSize() = 0;
00080    virtual Int_t     GetLearnEntries() = 0;
00081    virtual Long64_t  GetNextEvent() = 0;
00082    virtual void      StopProcess(Bool_t abort);
00083 
00084    static TEventIter *Create(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
00085 
00086    ClassDef(TEventIter,0)  // Event iterator used by TProofPlayer's
00087 };
00088 
00089 
00090 //------------------------------------------------------------------------
00091 
00092 class TEventIterUnit : public TEventIter {
00093 
00094 private:
00095  Long64_t fNum;
00096  Long64_t fCurrent;
00097 
00098 
00099 public:
00100    TEventIterUnit();
00101    TEventIterUnit(TDSet *dset, TSelector *sel, Long64_t num);
00102    ~TEventIterUnit() { }
00103 
00104    Long64_t GetCacheSize() {return -1;}
00105    Int_t    GetLearnEntries() {return -1;}
00106    Long64_t GetNextEvent();
00107 
00108    ClassDef(TEventIterUnit,0)  // Event iterator for objects
00109 };
00110 
00111 
00112 //------------------------------------------------------------------------
00113 
00114 class TEventIterObj : public TEventIter {
00115 
00116 private:
00117    TString  fClassName;    // class name of objects to iterate over
00118    TList   *fKeys;         // list of keys
00119    TIter   *fNextKey;      // next key in directory
00120    TObject *fObj;          // object found
00121 
00122 public:
00123    TEventIterObj();
00124    TEventIterObj(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
00125    ~TEventIterObj();
00126 
00127    Long64_t GetCacheSize() {return -1;}
00128    Int_t    GetLearnEntries() {return -1;}
00129    Long64_t GetNextEvent();
00130 
00131    ClassDef(TEventIterObj,0)  // Event iterator for objects
00132 };
00133 
00134 
00135 //------------------------------------------------------------------------
00136 class TEventIterTree : public TEventIter {
00137 
00138 private:
00139    TString     fTreeName;     // name of the tree object to iterate over
00140    TTree      *fTree;         // tree we are iterating over
00141    TTreeCache *fTreeCache;    // instance of the tree cache for the tree
00142    Bool_t      fTreeCacheIsLearning; // Whether cache is in learning phase
00143    Bool_t      fUseTreeCache; // Control usage of the tree cache
00144    Long64_t    fCacheSize;    // Cache size
00145    Bool_t      fUseParallelUnzip; // Control usage of parallel unzip
00146    TList      *fFileTrees;    // Files && Trees currently open
00147 
00148    // Auxilliary class to keep track open files and loaded trees
00149    class TFileTree : public TNamed {
00150    public:
00151       Bool_t    fUsed;
00152       Bool_t    fIsLocal;
00153       TFile    *fFile;
00154       TList    *fTrees;
00155       TFileTree(const char *name, TFile *f, Bool_t islocal);
00156       virtual ~TFileTree();
00157    };
00158 
00159    TTree* Load(TDSetElement *elem, Bool_t &localfile);
00160    TTree* GetTrees(TDSetElement *elem);
00161 public:
00162    TEventIterTree();
00163    TEventIterTree(TDSet *dset, TSelector *sel, Long64_t first, Long64_t num);
00164    ~TEventIterTree();
00165 
00166    Long64_t GetCacheSize();
00167    Int_t    GetLearnEntries();
00168    Long64_t GetNextEvent();
00169 
00170    ClassDef(TEventIterTree,0)  // Event iterator for Trees
00171 };
00172 
00173 #endif

Generated on Tue Jul 5 14:26:47 2011 for ROOT_528-00b_version by  doxygen 1.5.1