Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:35

0001 // @(#)root/treeplayer:$Id$
0002 // Author: Marek Biskup  07/06/2005
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TChainIndex
0013 #define ROOT_TChainIndex
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //
0018 // TChainIndex
0019 //
0020 // A Chain Index with majorname and minorname.
0021 // It uses tree indices of all the trees in the chain instead of building
0022 // a new index.
0023 // The index values from the first tree should be less then
0024 // all the index values from the second tree, and so on.
0025 // If a tree in the chain doesn't have an index the index will be created
0026 // and kept inside this chain index.
0027 //
0028 //////////////////////////////////////////////////////////////////////////
0029 
0030 
0031 #include "TVirtualIndex.h"
0032 
0033 #include <vector>
0034 #include <utility>
0035 
0036 class TTreeFormula;
0037 class TTreeIndex;
0038 class TChain;
0039 
0040 class TChainIndex : public TVirtualIndex {
0041 public:
0042    // holds a description of indices of trees in the chain.
0043    class TChainIndexEntry {
0044       void Swap(TChainIndexEntry &other);
0045 
0046    public:
0047       TChainIndexEntry() : fMinIndexValue(0), fMinIndexValMinor(0),
0048                            fMaxIndexValue(0), fMaxIndexValMinor(0),
0049                            fTreeIndex(nullptr) {}
0050       TChainIndexEntry(const TChainIndexEntry &other);
0051       TChainIndexEntry &operator=(TChainIndexEntry other)
0052       {
0053          other.Swap(*this);
0054          return *this;
0055       }
0056       typedef std::pair<Long64_t, Long64_t>      IndexValPair_t;
0057 
0058       IndexValPair_t GetMinIndexValPair() const { return IndexValPair_t(fMinIndexValue, fMinIndexValMinor); }
0059       IndexValPair_t GetMaxIndexValPair() const { return IndexValPair_t(fMaxIndexValue, fMaxIndexValMinor); }
0060       void           SetMinMaxFrom(const TTreeIndex *index );
0061 
0062       Long64_t    fMinIndexValue;           // the minimum value of the index (upper bits)
0063       Long64_t    fMinIndexValMinor;        // the minimum value of the index (lower bits)
0064       Long64_t    fMaxIndexValue;           // the maximum value of the index (upper bits)
0065       Long64_t    fMaxIndexValMinor;        // the maximum value of the index (lower bits)
0066       TVirtualIndex* fTreeIndex;            // the tree index in case it was created in the constructor,
0067                                             // otherwise 0
0068    };
0069 protected:
0070 
0071    TString        fMajorName;               // Index major name
0072    TString        fMinorName;               // Index minor name
0073    TTreeFormula  *fMajorFormulaParent;      //! Pointer to major TreeFormula in Parent tree (if any)
0074    TTreeFormula  *fMinorFormulaParent;      //! Pointer to minor TreeFormula in Parent tree (if any)
0075    std::vector<TChainIndexEntry> fEntries; // descriptions of indices of trees in the chain.
0076 
0077    std::pair<TVirtualIndex*, Int_t> GetSubTreeIndex(Long64_t major, Long64_t minor) const;
0078    void ReleaseSubTreeIndex(TVirtualIndex* index, Int_t treeNo) const;
0079    void DeleteIndices();
0080 
0081    TTreeFormula  *GetMajorFormulaParent(const TTree *parent);
0082    TTreeFormula  *GetMinorFormulaParent(const TTree *parent);
0083 
0084 public:
0085    TChainIndex();
0086    TChainIndex(const TTree *T, const char *majorname, const char *minorname);
0087    ~TChainIndex() override;
0088    void           Append(const TVirtualIndex *, bool delaySort = false) override;
0089    Long64_t       GetEntryNumberFriend(const TTree *parent) override;
0090    Long64_t       GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const override;
0091    Long64_t       GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const override;
0092    const char    *GetMajorName()    const override {return fMajorName.Data();}
0093    const char    *GetMinorName()    const override {return fMinorName.Data();}
0094    Long64_t       GetN()            const override {return fEntries.size();}
0095    bool           IsValidFor(const TTree *parent) override;
0096    void           UpdateFormulaLeaves(const TTree *parent) override;
0097    void           SetTree(TTree *T) override;
0098    TObject *Clone(const char *newname = "") const override;
0099 
0100    ClassDefOverride(TChainIndex,1)  //A Tree Index with majorname and minorname.
0101 };
0102 
0103 #endif