Logo ROOT   6.07/09
Reference Guide
TChainIndex.h
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Marek Biskup 07/06/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TChainIndex
13 #define ROOT_TChainIndex
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 //
18 // TChainIndex
19 //
20 // A Chain Index with majorname and minorname.
21 // It uses tree indices of all the trees in the chain instead of building
22 // a new index.
23 // The index values from the first tree should be less then
24 // all the index values from the second tree, and so on.
25 // If a tree in the chain doesn't have an index the index will be created
26 // and kept inside this chain index.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 
30 
31 #ifndef ROOT_TVirtualIndex
32 #include "TVirtualIndex.h"
33 #endif
34 
35 #include <vector>
36 
37 class TTreeFormula;
38 class TTreeIndex;
39 class TChain;
40 
41 class TChainIndex : public TVirtualIndex {
42 
43 public:
45  // holds a description of indices of trees in the chain.
46  public:
49  fTreeIndex(0) {}
50 
51  typedef std::pair<Long64_t, Long64_t> IndexValPair_t;
52 
55  void SetMinMaxFrom(const TTreeIndex *index );
56 
57  Long64_t fMinIndexValue; // the minimum value of the index (upper bits)
58  Long64_t fMinIndexValMinor; // the minimum value of the index (lower bits)
59  Long64_t fMaxIndexValue; // the maximum value of the index (upper bits)
60  Long64_t fMaxIndexValMinor; // the maximum value of the index (lower bits)
61  TVirtualIndex* fTreeIndex; // the tree index in case it was created in the constructor,
62  // otherwise 0
63  };
64 protected:
65 
66  TString fMajorName; // Index major name
67  TString fMinorName; // Index minor name
68  TTreeFormula *fMajorFormulaParent; //! Pointer to major TreeFormula in Parent tree (if any)
69  TTreeFormula *fMinorFormulaParent; //! Pointer to minor TreeFormula in Parent tree (if any)
70  std::vector<TChainIndexEntry> fEntries; // descriptions of indices of trees in the chain.
71 
72  std::pair<TVirtualIndex*, Int_t> GetSubTreeIndex(Long64_t major, Long64_t minor) const;
73  void ReleaseSubTreeIndex(TVirtualIndex* index, Int_t treeNo) const;
74  void DeleteIndices();
75 
76 public:
77  TChainIndex();
78  TChainIndex(const TTree *T, const char *majorname, const char *minorname);
79  virtual ~TChainIndex();
80  virtual void Append(const TVirtualIndex *, Bool_t delaySort = kFALSE);
81  virtual Long64_t GetEntryNumberFriend(const TTree *parent);
82  virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const;
83  virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const;
84  const char *GetMajorName() const {return fMajorName.Data();}
85  const char *GetMinorName() const {return fMinorName.Data();}
86  virtual Long64_t GetN() const {return fEntries.size();}
87  virtual TTreeFormula *GetMajorFormulaParent(const TTree *parent);
88  virtual TTreeFormula *GetMinorFormulaParent(const TTree *parent);
89  virtual void UpdateFormulaLeaves(const TTree *parent);
90  virtual void SetTree(const TTree *T);
91 
92  ClassDef(TChainIndex,1) //A Tree Index with majorname and minorname.
93 };
94 
95 #endif
96 
TVirtualIndex * fTreeIndex
Definition: TChainIndex.h:61
long long Long64_t
Definition: RtypesCore.h:69
Abstract interface for Tree Index.
Definition: TVirtualIndex.h:31
virtual Long64_t GetEntryNumberFriend(const TTree *parent)
See TTreeIndex::GetEntryNumberFriend for description.
double T(double x)
Definition: ChebyshevPol.h:34
virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const
See TTreeIndex::GetEntryNumberWithBestIndex for details.
std::pair< Long64_t, Long64_t > IndexValPair_t
Definition: TChainIndex.h:51
virtual ~TChainIndex()
The destructor.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetTree(const TTree *T)
See TTreeIndex::SetTree.
const char * GetMajorName() const
Definition: TChainIndex.h:84
void SetMinMaxFrom(const TTreeIndex *index)
Definition: TChainIndex.cxx:34
A Tree Index with majorname and minorname.
Definition: TTreeIndex.h:32
TString fMinorName
Definition: TChainIndex.h:67
const char * Data() const
Definition: TString.h:349
#define ClassDef(name, id)
Definition: Rtypes.h:254
Used to pass a selection expression to the Tree drawing routine.
Definition: TTreeFormula.h:64
virtual TTreeFormula * GetMinorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the minorname in parent tree T...
std::pair< TVirtualIndex *, Int_t > GetSubTreeIndex(Long64_t major, Long64_t minor) const
Returns a TVirtualIndex for a tree which holds the entry with the specified major and minor values an...
IndexValPair_t GetMaxIndexValPair() const
Definition: TChainIndex.h:54
virtual void Append(const TVirtualIndex *, Bool_t delaySort=kFALSE)
Add an index to this chain.
std::vector< TChainIndexEntry > fEntries
Pointer to minor TreeFormula in Parent tree (if any)
Definition: TChainIndex.h:70
const char * GetMinorName() const
Definition: TChainIndex.h:85
TTreeFormula * fMajorFormulaParent
Definition: TChainIndex.h:68
virtual TTreeFormula * GetMajorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the majorname in parent tree T...
void ReleaseSubTreeIndex(TVirtualIndex *index, Int_t treeNo) const
Releases the tree index got using GetSubTreeIndex.
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const
Returns the entry number with given index values.
TChainIndex()
Default constructor for TChainIndex.
Definition: TChainIndex.cxx:47
void DeleteIndices()
Delete all the indices which were built by this object.
A chain is a collection of files containg TTree objects.
Definition: TChain.h:35
virtual void UpdateFormulaLeaves(const TTree *parent)
Updates the parent formulae.
TTreeFormula * fMinorFormulaParent
Pointer to major TreeFormula in Parent tree (if any)
Definition: TChainIndex.h:69
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TString fMajorName
Definition: TChainIndex.h:66
virtual Long64_t GetN() const
Definition: TChainIndex.h:86
IndexValPair_t GetMinIndexValPair() const
Definition: TChainIndex.h:53
Holds a description of indices of trees in the chain.
Definition: TChainIndex.h:44
A Chain Index.
Definition: TChainIndex.h:41