#ifndef ROOT_TChainIndex
#define ROOT_TChainIndex
#ifndef ROOT_TVirtualIndex
#include "TVirtualIndex.h"
#endif
#include <vector>
class TTreeFormula;
class TTreeIndex;
class TChain;
class TChainIndex : public TVirtualIndex {
public:
class TChainIndexEntry {
public:
TChainIndexEntry() : fMinIndexValue(0), fMinIndexValMinor(0),
fMaxIndexValue(0), fMaxIndexValMinor(0),
fTreeIndex(0) {}
typedef std::pair<Long64_t, Long64_t> IndexValPair_t;
IndexValPair_t GetMinIndexValPair() const { return IndexValPair_t(fMinIndexValue, fMinIndexValMinor); }
IndexValPair_t GetMaxIndexValPair() const { return IndexValPair_t(fMaxIndexValue, fMaxIndexValMinor); }
void SetMinMaxFrom(const TTreeIndex *index );
Long64_t fMinIndexValue;
Long64_t fMinIndexValMinor;
Long64_t fMaxIndexValue;
Long64_t fMaxIndexValMinor;
TVirtualIndex* fTreeIndex;
};
protected:
TString fMajorName;
TString fMinorName;
TTreeFormula *fMajorFormulaParent;
TTreeFormula *fMinorFormulaParent;
std::vector<TChainIndexEntry> fEntries;
std::pair<TVirtualIndex*, Int_t> GetSubTreeIndex(Long64_t major, Long64_t minor) const;
void ReleaseSubTreeIndex(TVirtualIndex* index, Int_t treeNo) const;
void DeleteIndices();
public:
TChainIndex();
TChainIndex(const TTree *T, const char *majorname, const char *minorname);
virtual ~TChainIndex();
virtual void Append(const TVirtualIndex *, Bool_t delaySort = kFALSE);
virtual Long64_t GetEntryNumberFriend(const TTree *parent);
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const;
virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const;
const char *GetMajorName() const {return fMajorName.Data();}
const char *GetMinorName() const {return fMinorName.Data();}
virtual Long64_t GetN() const {return fEntries.size();}
virtual TTreeFormula *GetMajorFormulaParent(const TTree *parent);
virtual TTreeFormula *GetMinorFormulaParent(const TTree *parent);
virtual void UpdateFormulaLeaves(const TTree *parent);
virtual void SetTree(const TTree *T);
ClassDef(TChainIndex,1)
};
#endif