library: libTreePlayer
#include "TTreeIndex.h"

TTreeIndex


class description - source file - inheritance tree (.pdf)

class TTreeIndex : public TVirtualIndex

Inheritance Chart:
TObject
<-
TNamed
<-
TVirtualIndex
<-
TTreeIndex

    public:
TTreeIndex() TTreeIndex(const TTree* T, const char* majorname, const char* minorname) TTreeIndex(const TTreeIndex&) virtual ~TTreeIndex() static TClass* Class() virtual Int_t GetEntryNumberFriend(const TTree* T) virtual Long64_t GetEntryNumberWithBestIndex(Int_t major, Int_t minor) const virtual Long64_t GetEntryNumberWithIndex(Int_t major, Int_t minor) const virtual Long64_t* GetIndex() const virtual Long64_t* GetIndexValues() const virtual TTreeFormula* GetMajorFormula() virtual TTreeFormula* GetMajorFormulaParent(const TTree* T) virtual const char* GetMajorName() const virtual TTreeFormula* GetMinorFormula() virtual TTreeFormula* GetMinorFormulaParent(const TTree* T) virtual const char* GetMinorName() const virtual Long64_t GetN() const virtual TClass* IsA() const TTreeIndex& operator=(const TTreeIndex&) virtual void Print(Option_t* option = "") const virtual void SetTree(const TTree* T) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) virtual void UpdateFormulaLeaves()

Data Members


    protected:
TString fMajorName Index major name TString fMinorName Index minor name Long64_t fN Number of entries Long64_t* fIndexValues [fN] Sorted index values Long64_t* fIndex [fN] Index of sorted values TTreeFormula* fMajorFormula ! Pointer to major TreeFormula TTreeFormula* fMinorFormula ! Pointer to minor TreeFormula TTreeFormula* fMajorFormulaParent ! Pointer to major TreeFormula in Parent tree (if any) TTreeFormula* fMinorFormulaParent ! Pointer to minor TreeFormula in Parent tree (if any)

Class Description

                                                                      
 A Tree Index with majorname and minorname.                           
                                                                      


TTreeIndex(): TVirtualIndex()
 Default constructor for TTreeIndex

TTreeIndex(const TTree *T, const char *majorname, const char *minorname) : TVirtualIndex()
 Normal constructor for TTreeIndex

 Build an index table using the leaves of Tree T with  major & minor names
 The index is built with the expressions given in "majorname" and "minorname".

 a Long64_t array fIndexValues is built with:
    major = the value of majorname converted to an integer
    minor = the value of minorname converted to an integer
    fIndexValues[i] = major<<31 + minor
 This array is sorted. The sorted fIndex[i] contains the serial number
 in the Tree corresponding to the pair "major,minor" in fIndexvalues[i].

  Once the index is computed, one can retrieve one entry via
    T->GetEntryWithIndex(majornumber, minornumber)
 Example:
  tree.BuildIndex("Run","Event"); //creates an index using leaves Run and Event
  tree.GetEntryWithIndex(1234,56789); //reads entry corresponding to
                                        Run=1234 and Event=56789

 Note that majorname and minorname may be expressions using original
 Tree variables eg: "run-90000", "event +3*xx". However the result
 must be integer.
 In case an expression is specified, the equivalent expression must be computed
 when calling GetEntryWithIndex.

 To build an index with only majorname, specify minorname="0" (default)

    TreeIndex and Friend Trees
    ---------------------------
 Assuming a parent Tree T and a friend Tree TF, the following cases are supported:
 CASE 1: T->GetEntry(entry) is called
         In this case, the serial number entry is used to retrieve
         the data in both Trees.
 CASE 2: T->GetEntry(entry) is called, TF has a TreeIndex
         the expressions given in major/minorname of TF are used
         to compute the value pair major,minor with the data in T.
         TF->GetEntry(major,minor) is then called (tricky case!)
 CASE 3: T->GetEntry(major,minor) is called.
         It is assumed that both T and TF have a TreeIndex built using
         the same major and minor name.

    Saving the TreeIndex
    --------------------
 Once the index is built, it can be saved with the TTree object
 with tree.Write(); (if the file has been open in "update" mode).

 The most convenient place to create the index is at the end of
 the filling process just before saving the Tree header.
 If a previous index was computed, it is redefined by this new call.

 Note that this function can also be applied to a TChain.

 The return value is the number of entries in the Index (< 0 indicates failure)

 It is possible to play with different TreeIndex in the same Tree.
 see comments in TTree::SetTreeIndex.

~TTreeIndex()

Int_t GetEntryNumberFriend(const TTree *T)
 returns the entry number in this friend Tree corresponding to entry in
 the master Tree T.
 In case this friend Tree and T do not share an index with the same
 major and minor name, the entry serial number in the friend tree
 and in the master Tree are assumed to be the same

Long64_t GetEntryNumberWithBestIndex(Int_t major, Int_t minor) const
 Return entry number corresponding to major and minor number
 Note that this function returns only the entry number, not the data
 To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
 the BuildIndex function has created a table of Double_t* of sorted values
 corresponding to val = major<<31 + minor;
 The function performs binary search in this sorted table.
 If it finds a pair that maches val, it returns directly the
 index in the table.
 If an entry corresponding to major and minor is not found, the function
 returns the index of the major,minor pair immediatly lower than the
 requested value, ie it will return -1 if the pair is lower than
 the first entry in the index.

 See also GetEntryNumberWithIndex

Long64_t GetEntryNumberWithIndex(Int_t major, Int_t minor) const
 Return entry number corresponding to major and minor number
 Note that this function returns only the entry number, not the data
 To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
 the BuildIndex function has created a table of Double_t* of sorted values
 corresponding to val = major<<31 + minor;
 The function performs binary search in this sorted table.
 If it finds a pair that maches val, it returns directly the
 index in the table, otherwise it returns -1.

 See also GetEntryNumberWithBestIndex

TTreeFormula* GetMajorFormula()
 return a pointer to the TreeFormula corresponding to the majorname

TTreeFormula* GetMinorFormula()
 return a pointer to the TreeFormula corresponding to the minorname

TTreeFormula* GetMajorFormulaParent(const TTree *T)
 return a pointer to the TreeFormula corresponding to the majorname in parent tree T

TTreeFormula* GetMinorFormulaParent(const TTree *T)
 return a pointer to the TreeFormula corresponding to the minorname in parent tree T

void Print(Option_t * option) const
 print the table with : serial number, majorname, minorname
 if option = "10" print only the first 10 entries
 if option = "100" print only the first 100 entries
 if option = "1000" print only the first 1000 entries

void Streamer(TBuffer &R__b)
 Stream an object of class TTreeIndex.
 Note that this Streamer should be changed to an automatic Streamer
 once TStreamerInfo supports an index of type Long64_t

void UpdateFormulaLeaves()
 Called by TChain::LoadTree when the parent chain changes it's tree.

void SetTree(const TTree *T)
 this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
 when a new Tree is loaded.
 Because Trees in a TChain may have a different list of leaves, one
 must update the leaves numbers in the TTreeFormula used by the TreeIndex.



Inline Functions


          Long64_t* GetIndexValues() const
          Long64_t* GetIndex() const
        const char* GetMajorName() const
        const char* GetMinorName() const
           Long64_t GetN() const
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void StreamerNVirtual(TBuffer& b)
         TTreeIndex TTreeIndex(const TTreeIndex&)
        TTreeIndex& operator=(const TTreeIndex&)


Author: Rene Brun 05/07/2004
Last update: root/tree:$Name: $:$Id: TTreeIndex.cxx,v 1.12 2005/06/13 19:19:07 pcanal Exp $
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.