Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TVirtualIndex.h"
32
33#include <vector>
34#include <utility>
35
36class TTreeFormula;
37class TTreeIndex;
38class TChain;
39
40class TChainIndex : public TVirtualIndex {
41public:
42 // holds a description of indices of trees in the chain.
44 void Swap(TChainIndexEntry &other);
45
46 public:
49 fTreeIndex(nullptr) {}
52 {
53 other.Swap(*this);
54 return *this;
55 }
56 typedef std::pair<Long64_t, Long64_t> IndexValPair_t;
57
60 void SetMinMaxFrom(const TTreeIndex *index );
61
62 Long64_t fMinIndexValue; // the minimum value of the index (upper bits)
63 Long64_t fMinIndexValMinor; // the minimum value of the index (lower bits)
64 Long64_t fMaxIndexValue; // the maximum value of the index (upper bits)
65 Long64_t fMaxIndexValMinor; // the maximum value of the index (lower bits)
66 TVirtualIndex* fTreeIndex; // the tree index in case it was created in the constructor,
67 // otherwise 0
68 };
69protected:
70
71 TString fMajorName; // Index major name
72 TString fMinorName; // Index minor name
73 TTreeFormula *fMajorFormulaParent; //! Pointer to major TreeFormula in Parent tree (if any)
74 TTreeFormula *fMinorFormulaParent; //! Pointer to minor TreeFormula in Parent tree (if any)
75 std::vector<TChainIndexEntry> fEntries; // descriptions of indices of trees in the chain.
76
77 std::pair<TVirtualIndex*, Int_t> GetSubTreeIndex(Long64_t major, Long64_t minor) const;
78 void ReleaseSubTreeIndex(TVirtualIndex* index, Int_t treeNo) const;
79 void DeleteIndices();
80
83
84public:
86 TChainIndex(const TTree *T, const char *majorname, const char *minorname);
87 ~TChainIndex() override;
88 void Append(const TVirtualIndex *, bool delaySort = false) override;
89 Long64_t GetEntryNumberFriend(const TTree *parent) override;
90 Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const override;
91 Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const override;
92 const char *GetMajorName() const override {return fMajorName.Data();}
93 const char *GetMinorName() const override {return fMinorName.Data();}
94 Long64_t GetN() const override {return fEntries.size();}
95 bool IsValidFor(const TTree *parent) override;
96 void UpdateFormulaLeaves(const TTree *parent) override;
97 void SetTree(TTree *T) override;
98 TObject *Clone(const char *newname = "") const override;
99
100 ClassDefOverride(TChainIndex,1) //A Tree Index with majorname and minorname.
101};
102
103#endif
long long Long64_t
Definition RtypesCore.h:69
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Holds a description of indices of trees in the chain.
Definition TChainIndex.h:43
std::pair< Long64_t, Long64_t > IndexValPair_t
Definition TChainIndex.h:56
IndexValPair_t GetMaxIndexValPair() const
Definition TChainIndex.h:59
void Swap(TChainIndexEntry &other)
TChainIndexEntry & operator=(TChainIndexEntry other)
Definition TChainIndex.h:51
void SetMinMaxFrom(const TTreeIndex *index)
IndexValPair_t GetMinIndexValPair() const
Definition TChainIndex.h:58
A Chain Index.
Definition TChainIndex.h:40
std::vector< TChainIndexEntry > fEntries
Pointer to minor TreeFormula in Parent tree (if any)
Definition TChainIndex.h:75
const char * GetMinorName() const override
Definition TChainIndex.h:93
TTreeFormula * fMinorFormulaParent
Pointer to major TreeFormula in Parent tree (if any)
Definition TChainIndex.h:74
~TChainIndex() override
The destructor.
TString fMinorName
Definition TChainIndex.h:72
bool IsValidFor(const TTree *parent) override
Return true if index can be applied to the TTree.
TObject * Clone(const char *newname="") const override
Create a deep copy of the TChainIndex.
void Append(const TVirtualIndex *, bool delaySort=false) override
Add an index to this chain.
const char * GetMajorName() const override
Definition TChainIndex.h:92
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...
Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const override
Returns the entry number with given index values.
void ReleaseSubTreeIndex(TVirtualIndex *index, Int_t treeNo) const
Releases the tree index got using GetSubTreeIndex.
Long64_t GetN() const override
Definition TChainIndex.h:94
Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const override
See TTreeIndex::GetEntryNumberWithBestIndex for details.
void UpdateFormulaLeaves(const TTree *parent) override
Updates the parent formulae.
TChainIndex()
Default constructor for TChainIndex.
void DeleteIndices()
Delete all the indices which were built by this object.
TString fMajorName
Definition TChainIndex.h:71
TTreeFormula * fMajorFormulaParent
Definition TChainIndex.h:73
Long64_t GetEntryNumberFriend(const TTree *parent) override
See TTreeIndex::GetEntryNumberFriend for description.
TTreeFormula * GetMajorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the majorname in parent tree T.
void SetTree(TTree *T) override
See TTreeIndex::SetTree.
TTreeFormula * GetMinorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the minorname in parent tree T.
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
Used to pass a selection expression to the Tree drawing routine.
A Tree Index with majorname and minorname.
Definition TTreeIndex.h:29
A TTree represents a columnar dataset.
Definition TTree.h:79
Abstract interface for Tree Index.
#define Swap(a, b)
Definition geom.c:201