TChainIndex.h

Go to the documentation of this file.
00001 // @(#)root/treeplayer:$Id: TChainIndex.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Marek Biskup  07/06/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, 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_TChainIndex
00013 #define ROOT_TChainIndex
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //
00018 // TChainIndex
00019 //
00020 // A Chain Index with majorname and minorname.
00021 // It uses tree indices of all the trees in the chain instead of building
00022 // a new index.
00023 // The index values from the first tree should be less then 
00024 // all the index values from the second tree, and so on.
00025 // If a tree in the chain doesn't have an index the index will be created
00026 // and kept inside this chain index.
00027 // 
00028 //////////////////////////////////////////////////////////////////////////
00029 
00030 
00031 #ifndef ROOT_TVirtualIndex
00032 #include "TVirtualIndex.h"
00033 #endif
00034 
00035 #include <vector>
00036 
00037 class TTreeFormula;
00038 class TChain;
00039 
00040 class TChainIndex : public TVirtualIndex {
00041 
00042 public:
00043    class TChainIndexEntry {
00044       // holds a description of indices of trees in the chain. 
00045    public:
00046       TChainIndexEntry() : fMinIndexValue(0), fMaxIndexValue(0), fTreeIndex(0) {}
00047 
00048       Long64_t    fMinIndexValue;           // the minimum value of the index
00049       Long64_t    fMaxIndexValue;           // the maximum value of the index
00050       TVirtualIndex* fTreeIndex;            // the tree index in case it was created in the constructor,
00051                                             // otherwise 0
00052    };
00053 protected:
00054 
00055    TString        fMajorName;               // Index major name
00056    TString        fMinorName;               // Index minor name
00057    TTreeFormula  *fMajorFormulaParent;      //! Pointer to major TreeFormula in Parent tree (if any)
00058    TTreeFormula  *fMinorFormulaParent;      //! Pointer to minor TreeFormula in Parent tree (if any)
00059    std::vector<TChainIndexEntry> fEntries; // descriptions of indices of trees in the chain.
00060 
00061    std::pair<TVirtualIndex*, Int_t> GetSubTreeIndex(Int_t major, Int_t minor) const;
00062    void ReleaseSubTreeIndex(TVirtualIndex* index, Int_t treeNo) const;
00063    void DeleteIndices();
00064 
00065 public:
00066    TChainIndex();
00067    TChainIndex(const TTree *T, const char *majorname, const char *minorname);
00068    virtual               ~TChainIndex();
00069    virtual void           Append(const TVirtualIndex *, Bool_t delaySort = kFALSE);
00070    virtual Int_t          GetEntryNumberFriend(const TTree *T);
00071    virtual Long64_t       GetEntryNumberWithIndex(Int_t major, Int_t minor) const;
00072    virtual Long64_t       GetEntryNumberWithBestIndex(Int_t major, Int_t minor) const;
00073    const char            *GetMajorName()    const {return fMajorName.Data();}
00074    const char            *GetMinorName()    const {return fMinorName.Data();}
00075    virtual Long64_t       GetN()            const {return fEntries.size();}
00076    virtual TTreeFormula  *GetMajorFormulaParent(const TTree *T);
00077    virtual TTreeFormula  *GetMinorFormulaParent(const TTree *T);
00078    virtual void           UpdateFormulaLeaves(const TTree *parent);
00079    virtual void           SetTree(const TTree *T);
00080 
00081    ClassDef(TChainIndex,1)  //A Tree Index with majorname and minorname.
00082 };
00083 
00084 #endif
00085 

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