TBranch.h

Go to the documentation of this file.
00001 // @(#)root/tree:$Id: TBranch.h 38060 2011-02-13 21:17:54Z pcanal $
00002 // Author: Rene Brun   12/01/96
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TBranch
00013 #define ROOT_TBranch
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TBranch                                                              //
00019 //                                                                      //
00020 // A TTree object is a list of TBranchs.                                //
00021 //   A TBranch describes the branch data structure and supports :       //
00022 //     the list of TBaskets (branch buffers) associated to this branch. //
00023 //     the list of TLeaves (branch description)                         //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 
00027 #ifndef ROOT_TNamed
00028 #include "TNamed.h"
00029 #endif
00030 
00031 #ifndef ROOT_TObjArray
00032 #include "TObjArray.h"
00033 #endif
00034 
00035 #ifndef ROOT_TAttFill
00036 #include "TAttFill.h"
00037 #endif
00038 
00039 #ifndef ROOT_TDataType
00040 #include "TDataType.h"
00041 #endif
00042 
00043 class TTree;
00044 class TBasket;
00045 class TLeaf;
00046 class TBrowser;
00047 class TDirectory;
00048 class TFile;
00049 class TClonesArray;
00050 
00051    const Int_t kDoNotProcess = BIT(10); // Active bit for branches
00052    const Int_t kIsClone      = BIT(11); // to indicate a TBranchClones
00053    const Int_t kBranchObject = BIT(12); // branch is a TObject*
00054    const Int_t kBranchAny    = BIT(17); // branch is an object*
00055    const Int_t kMapObject    = kBranchObject | kBranchAny;
00056 
00057 class TBranch : public TNamed , public TAttFill {
00058 
00059 protected:
00060    // TBranch status bits
00061    enum { kAutoDelete = BIT(15) };
00062 
00063    static Int_t fgCount;          //! branch counter
00064    Int_t       fCompress;        //  (=1 branch is compressed, 0 otherwise)
00065    Int_t       fBasketSize;      //  Initial Size of  Basket Buffer
00066    Int_t       fEntryOffsetLen;  //  Initial Length of fEntryOffset table in the basket buffers
00067    Int_t       fWriteBasket;     //  Last basket number written
00068    Long64_t    fEntryNumber;     //  Current entry number (last one filled in this branch)
00069    Int_t       fOffset;          //  Offset of this branch
00070    Int_t       fMaxBaskets;      //  Maximum number of Baskets so far
00071    Int_t       fNBaskets;        //! Number of baskets in memory
00072    Int_t       fSplitLevel;      //  Branch split level
00073    Int_t       fNleaves;         //! Number of leaves
00074    Int_t       fReadBasket;      //! Current basket number when reading
00075    Long64_t    fReadEntry;       //! Current entry number when reading
00076    Long64_t    fEntries;         //  Number of entries
00077    Long64_t    fFirstEntry;      //  Number of the first entry in this branch
00078    Long64_t    fTotBytes;        //  Total number of bytes in all leaves before compression
00079    Long64_t    fZipBytes;        //  Total number of bytes in all leaves after compression
00080    TObjArray   fBranches;        //-> List of Branches of this branch
00081    TObjArray   fLeaves;          //-> List of leaves of this branch
00082    TObjArray   fBaskets;         //-> List of baskets of this branch
00083    Int_t      *fBasketBytes;     //[fMaxBaskets] Lenght of baskets on file
00084    Long64_t   *fBasketEntry;     //[fMaxBaskets] Table of first entry in eack basket
00085    Long64_t   *fBasketSeek;      //[fMaxBaskets] Addresses of baskets on file
00086    TTree      *fTree;            //! Pointer to Tree header
00087    TBranch    *fMother;          //! Pointer to top-level parent branch in the tree.
00088    TBranch    *fParent;          //! Pointer to parent branch.
00089    char       *fAddress;         //! Address of 1st leaf (variable or object)
00090    TDirectory *fDirectory;       //! Pointer to directory where this branch buffers are stored
00091    TString     fFileName;        //  Name of file where buffers are stored ("" if in same file as Tree header)
00092    TBuffer    *fEntryBuffer;     //! Buffer used to directly pass the content without streaming
00093    TList      *fBrowsables;      //! List of TVirtualBranchBrowsables used for Browse()
00094 
00095    Bool_t      fSkipZip;         //! After being read, the buffer will not be unziped.
00096 
00097    typedef void (TBranch::*ReadLeaves_t)(TBuffer &b); 
00098    ReadLeaves_t fReadLeaves;     //! Pointer to the ReadLeaves implementation to use. 
00099    void     ReadLeavesImpl(TBuffer &b);
00100 
00101    void     SetSkipZip(Bool_t skip = kTRUE) { fSkipZip = skip; }
00102    void     Init(const char *name, const char *leaflist, Int_t compress);
00103 
00104    TBasket *GetFreshBasket();
00105    Int_t    WriteBasket(TBasket* basket, Int_t where);
00106    
00107    TString  GetRealFileName() const;
00108 
00109 private:
00110    TBranch(const TBranch&);             // not implemented
00111    TBranch& operator=(const TBranch&);  // not implemented
00112 
00113 public:
00114    TBranch();
00115    TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize=32000, Int_t compress=-1);
00116    TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Int_t basketsize=32000, Int_t compress=-1);
00117    virtual ~TBranch();
00118 
00119    virtual void      AddBasket(TBasket &b, Bool_t ondisk, Long64_t startEntry);
00120    virtual void      AddLastBasket(Long64_t startEntry);
00121    virtual void      Browse(TBrowser *b);
00122    virtual void      DeleteBaskets(Option_t* option="");
00123    virtual void      DropBaskets(Option_t *option = "");
00124            void      ExpandBasketArrays();
00125    virtual Int_t     Fill();
00126    virtual void      FillLeaves(TBuffer &b);
00127    virtual TBranch  *FindBranch(const char *name);
00128    virtual TLeaf    *FindLeaf(const char *name);
00129            Int_t     FlushBaskets();
00130            Int_t     FlushOneBasket(UInt_t which);
00131 
00132    virtual char     *GetAddress() const {return fAddress;}
00133            TBasket  *GetBasket(Int_t basket);
00134            Int_t    *GetBasketBytes() const {return fBasketBytes;}
00135            Long64_t *GetBasketEntry() const {return fBasketEntry;}
00136    virtual Long64_t  GetBasketSeek(Int_t basket) const;
00137    virtual Int_t     GetBasketSize() const {return fBasketSize;}
00138    virtual TList    *GetBrowsables();
00139    virtual const char* GetClassName() const;
00140    virtual Int_t     GetCompressionLevel() const {return fCompress;}
00141    TDirectory       *GetDirectory() const {return fDirectory;}
00142    virtual Int_t     GetEntry(Long64_t entry=0, Int_t getall = 0);
00143    virtual Int_t     GetEntryExport(Long64_t entry, Int_t getall, TClonesArray *list, Int_t n);
00144            Int_t     GetEntryOffsetLen() const { return fEntryOffsetLen; }
00145            Int_t     GetEvent(Long64_t entry=0) {return GetEntry(entry);}
00146    const char       *GetIconName() const;
00147    virtual Int_t     GetExpectedType(TClass *&clptr,EDataType &type);
00148    virtual TLeaf    *GetLeaf(const char *name) const;
00149    virtual TFile    *GetFile(Int_t mode=0);
00150    const char       *GetFileName()    const {return fFileName.Data();}
00151            Int_t     GetOffset()      const {return fOffset;}
00152            Int_t     GetReadBasket()  const {return fReadBasket;}
00153            Long64_t  GetReadEntry()   const {return fReadEntry;}
00154            Int_t     GetWriteBasket() const {return fWriteBasket;}
00155            Long64_t  GetTotalSize(Option_t *option="")   const;
00156            Long64_t  GetTotBytes(Option_t *option="")    const;
00157            Long64_t  GetZipBytes(Option_t *option="")    const;
00158            Long64_t  GetEntryNumber() const {return fEntryNumber;}
00159            Long64_t  GetFirstEntry()  const {return fFirstEntry; }
00160          TObjArray  *GetListOfBaskets()  {return &fBaskets;}
00161          TObjArray  *GetListOfBranches() {return &fBranches;}
00162          TObjArray  *GetListOfLeaves()   {return &fLeaves;}
00163            Int_t     GetMaxBaskets()  const  {return fMaxBaskets;}
00164            Int_t     GetNleaves()     const {return fNleaves;}
00165            Int_t     GetSplitLevel()  const {return fSplitLevel;}
00166            Long64_t  GetEntries()     const {return fEntries;}
00167            TTree    *GetTree()        const {return fTree;}
00168    virtual Int_t     GetRow(Int_t row);
00169    virtual Bool_t    GetMakeClass() const;
00170    TBranch          *GetMother() const;
00171    TBranch          *GetSubBranch(const TBranch *br) const;
00172    Bool_t            IsAutoDelete() const;
00173    Bool_t            IsFolder() const;
00174    virtual void      KeepCircular(Long64_t maxEntries);
00175    virtual Int_t     LoadBaskets();
00176    virtual void      Print(Option_t *option="") const;
00177    virtual void      ReadBasket(TBuffer &b);
00178    virtual void      Refresh(TBranch *b);
00179    virtual void      Reset(Option_t *option="");
00180    virtual void      ResetAddress();
00181    virtual void      ResetReadEntry() {fReadEntry = -1;}
00182    virtual void      SetAddress(void *add);
00183    virtual void      SetObject(void *objadd);
00184    virtual void      SetAutoDelete(Bool_t autodel=kTRUE);
00185    virtual void      SetBasketSize(Int_t buffsize);
00186    virtual void      SetBufferAddress(TBuffer *entryBuffer);
00187    virtual void      SetCompressionLevel(Int_t level=1);
00188    virtual void      SetEntries(Long64_t entries);
00189    virtual void      SetEntryOffsetLen(Int_t len, Bool_t updateSubBranches = kFALSE);
00190    virtual void      SetFirstEntry( Long64_t entry );
00191    virtual void      SetFile(TFile *file=0);
00192    virtual void      SetFile(const char *filename);
00193    virtual Bool_t    SetMakeClass(Bool_t decomposeObj = kTRUE);
00194    virtual void      SetOffset(Int_t offset=0) {fOffset=offset;}
00195    virtual void      SetStatus(Bool_t status=1);
00196    virtual void      SetTree(TTree *tree) { fTree = tree;}
00197    virtual void      SetupAddresses();
00198    virtual void      UpdateAddress() {;}
00199    virtual void      UpdateFile();
00200 
00201    static  void      ResetCount();
00202 
00203    ClassDef(TBranch,12);  //Branch descriptor
00204 };
00205 
00206 #endif

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