TChain


class description - source file - inheritance tree

class TChain : public TTree

    private:
protected:
public:
TChain TChain() TChain TChain(const char* name, const char* title) TChain TChain(TChain&) virtual void ~TChain() virtual Int_t Add(TChain* chain) virtual Int_t Add(const char* name, Int_t nentries = -1) virtual Int_t AddFile(const char* name, Int_t nentries) virtual TFriendElement* AddFriend(const char* chainname, const char* dummy) virtual void Browse(TBrowser* b) static TClass* Class() virtual void CreatePackets() virtual void Draw(Option_t* opt) virtual Int_t Draw(const char* varexp, TCut selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual Int_t Draw(const char* varexp, const char* selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual Int_t Fill() virtual TBranch* GetBranch(const char* name) virtual Int_t GetChainEntryNumber(Int_t entry) const virtual Int_t GetEntry(Int_t entry = 0, Int_t getall = 0) TFile* GetFile() const virtual TLeaf* GetLeaf(const char* name) virtual TObjArray* GetListOfBranches() TObjArray* GetListOfFiles() const virtual TObjArray* GetListOfLeaves() virtual Double_t GetMaximum(const char* columname) virtual Double_t GetMinimum(const char* columname) virtual Int_t GetNbranches() TObject* GetNotify() const Int_t GetNtrees() const TList* GetStatus() const virtual TTree* GetTree() const virtual Int_t GetTreeNumber() const Int_t* GetTreeOffset() const Int_t GetTreeOffsetLen() const virtual TClass* IsA() const virtual Int_t LoadTree(Int_t entry) virtual void Loop(Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual void ls(Option_t* option) const virtual void Merge(const char* name) virtual void Merge(TFile* file, Int_t basketsize, Option_t* option) virtual void Print(Option_t* option) const virtual Int_t Process(const char* filename, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual Int_t Process(TSelector* selector, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0) virtual void SetBranchAddress(const char* bname, void* add) virtual void SetBranchStatus(const char* bname, Bool_t status = 1) virtual void SetNotify(TObject* obj) virtual void SetPacketSize(Int_t size = 100) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members

    private:
protected:
Int_t fTreeOffsetLen Current size of fTreeOffset array Int_t fNtrees Number of Trees Int_t fTreeNumber ! Current Tree number in fTreeOffset table Int_t* fTreeOffset [fTreeOffsetLen]Array of variables TTree* fTree ! Pointer to current tree TFile* fFile ! Pointer to current file TObjArray* fFiles -> List of file names containing the Trees TList* fStatus -> List of active/inactive branches TObject* fNotify ! Object to be notified when loading a new file public:

Class Description

                                                                      
 TChain                                                               
                                                                      
 A chain is a collection of files containg TTree objects.             
 When the chain is created, the first parameter is the default name   
 for the Tree to be processed later on.                               
                                                                      
 Enter a new element in the chain via the TChain::Add function.       
 Once a chain is defined, one can use the normal TTree functions      
 to Draw,Scan,etc.                                                    
                                                                      
 Use TChain::SetBranchStatus to activate one or more branches for all 
 the trees in the chain.                                              
                                                                      


TChain(): TTree()
*-*-*-*-*-*Default constructor for Chain*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*        ==============================

TChain(const char *name, const char *title) :TTree(name,title)
*-*-*-*-*-*-*-*-*-*-*-*-*Create a Chain*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                      ==============

   A TChain is a collection of TFile objects.
    the first parameter "name" is the name of the TTree object
    in the files added with Add.
   Use TChain::Add to add a new element to this chain.

   In case the Tree is in a subdirectory, do, eg:
     TChain ch("subdir/treename");

    Example:
  Suppose we have 3 files f1.root, f2.root and f3.root. Each file
  contains a TTree object named "T".
     TChain ch("T");  creates a chain to process a Tree called "T"
     ch.Add("f1.root");
     ch.Add("f2.root");
     ch.Add("f3.root");
     ch.Draw("x");
       The Draw function above will process the variable "x" in Tree "T"
       reading sequentially the 3 files in the chain ch.

*-*

~TChain()
*-*-*-*-*-*Default destructor for a Chain*-*-*-*-*-*-*-*-*-*-*-*
*-*        ==============================

Int_t Add(TChain *chain)
 Add all files referenced by the TChain chain to this chain.

Int_t Add(const char *name, Int_t nentries)
       Add a new file to this chain.
    name may have the following format:
       //machine/file_name.root/subdir/tree_name
      machine, subdir and tree_name are optional. If tree_name is missing,
      the chain name will be assumed.
    name may use the wildcarding notation, eg "xxx*.root" means all files
    starting with xxx in the current file system directory.

    if nentries < 0, the file is connected and the tree header read in memory
    to get the number of entries.
    if (nentries >= 0, the file is not connected, nentries is assumed to be
    the number of entries in the file. In this case, no check is made that
    the file exists and the Tree existing in the file. This second mode
    is interesting in case the number of entries in the file is already stored
    in a run data base for example.
  NB. To add all the files of a TChain to a chain, use Add(TChain *chain).

Int_t AddFile(const char *name, Int_t nentries)
       Add a new file to this chain.

    if nentries < 0, the file is connected and the tree header read in memory
    to get the number of entries.
    if (nentries >= 0, the file is not connected, nentries is assumed to be
    the number of entries in the file. In this case, no check is made that
    the file exists and the Tree existing in the file. This second mode
    is interesting in case the number of entries in the file is already stored
    in a run data base for example.

TFriendElement* AddFriend(const char *chain, const char *dummy)
 Add a TFriendElement to the list of friends of this chain.

   A TChain has a list of friends similar to a tree (see TTree::AddFriend).
 You can add a friend to a chain with the TChain::AddFriend method, and you
 can retrieve the list of friends with TChain::GetListOfFriends.
 This example has four chains each has 20 ROOT trees from 20 ROOT files.

 TChain ch("t"); // a chain with 20 trees from 20 files
 TChain ch1("t1");
 TChain ch2("t2");
 TChain ch3("t3");
 Now we can add the friends to the first chain.

 ch.AddFriend("t1")
 ch.AddFriend("t2")
 ch.AddFriend("t3")


/*

*/


 The parameter is the name of friend chain (the name of a chain is always
 the name of the tree from which it was created).
 The original chain has access to all variable in its friends.
 We can use the TChain::Draw method as if the values in the friends were
 in the original chain.
 To specify the chain to use in the Draw method, use the syntax:

 <chainname>.<branchname>.<varname>
 If the variable name is enough to uniquely identify the variable, you can
 leave out the chain and/or branch name.
 For example, this generates a 3-d scatter plot of variable "var" in the
 TChain ch versus variable v1 in TChain t1 versus variable v2 in TChain t2.

 ch.Draw("var:t1.v1:t2.v2");
 When a TChain::Draw is executed, an automatic call to TTree::AddFriend
 connects the trees in the chain. When a chain is deleted, its friend
 elements are also deleted.

 The number of entries in the friend must be equal or greater to the number
 of entries of the original chain. If the friend has fewer entries a warning
 is given and the resulting histogram will have missing entries.
 For additional information see TTree::AddFriend.

void Browse(TBrowser *)

void CreatePackets()
*-*-*-*-*-*-*-*-*Initialize the packet descriptor string*-*-*-*-*-*-*-*-*-*
*-*              =======================================

Int_t Draw(const char *varexp, TCut selection, Option_t *option, Int_t nentries, Int_t firstentry)
 Draw expression varexp for selected entries.

 This function accepts TCut objects as arguments.
 Useful to use the string operator +, example:
    ntuple.Draw("x",cut1+cut2+cut3);


Int_t Draw(const char *varexp, const char *selection, Option_t *option,Int_t nentries, Int_t firstentry)
 Process all entries in this chain and draw histogram
 corresponding to expression varexp.

TBranch* GetBranch(const char *name)
*-*-*-*-*-*-*-*-*Return pointer to the branch name*-*-*-*-*
*-*              ==========================================

Int_t GetChainEntryNumber(Int_t entry) const
 return absolute entry number in the chain
 the input parameter entry is the entry number in the current Tree of this chain

Int_t GetEntry(Int_t entry, Int_t getall)
*-*-*-*-*-*-*-*-*Return entry in memory*-*-*-*-*-*-*-*-*-*
*-*              ======================
     getall = 0 : get only active branches
     getall = 1 : get all branches

TLeaf* GetLeaf(const char *name)
*-*-*-*-*-*-*-*-*Return pointer to the leaf name*-*-*-*-*
*-*              ==========================================

TObjArray* GetListOfBranches()
*-*-*-*-*-*-*-*-*Return pointer to list of branches of current tree*-*-*-*-*
*-*              ================================================

TObjArray* GetListOfLeaves()
*-*-*-*-*-*-*-*-*Return pointer to list of leaves of current tree*-*-*-*-*
*-*              ================================================

Double_t GetMaximum(const char *columname)
*-*-*-*-*-*-*-*-*Return maximum of column with name columname*-*-*-*-*-*-*
*-*              ============================================

Double_t GetMinimum(const char *columname)
*-*-*-*-*-*-*-*-*Return minimum of column with name columname*-*-*-*-*-*-*
*-*              ============================================

Int_t GetNbranches()
*-*-*-*-*-*-*-*-*Return number of branches of current tree*-*-*-*-*
*-*              =========================================

Int_t LoadTree(Int_t entry)
  The input argument entry is the entry serial number in the whole chain.
  The function finds the corresponding Tree and returns the entry number
  in this tree.

void Loop(Option_t *option, Int_t nentries, Int_t firstentry)
*-*-*-*-*-*-*-*-*Loop on nentries of this chain starting at firstentry
*-*              ===================================================

void ls(Option_t *option) const

void Merge(const char *name)
     Merge all files in this chain into a new file
 see important note in the following function Merge

void Merge(TFile *file, Int_t basketsize, Option_t *option)
     Merge all files in this chain into a new file
     if option ="C" is given, the compression level for all branches
        in the new Tree is set to the file compression level.
     By default, the compression level of all branches is the
     original compression level in the old Trees.

     if (basketsize > 1000, the basket size for all branches of the
     new Tree will be set to basketsize.

 IMPORTANT: Before invoking this function, the branch addresses
            of the TTree must have been set.
  example using the file generated in $ROOTSYS/test/Event
  merge two copies of Event.root

        gSystem.Load("libEvent");
        Event *event = new Event();
        TChain ch("T");
        ch.SetBranchAddress("event",&event);
        ch.Add("Event1.root");
        ch.Add("Event2.root");
        ch.Merge("all.root");

  The SetBranchAddress statement is not necessary if the Tree
  contains only basic types (case of files converted from hbook)

void Print(Option_t *option) const

Int_t Process(const char *filename,Option_t *option, Int_t nentries, Int_t firstentry)
 Process all entries in this chain, calling functions in filename
 see TTree::Process

Int_t Process(TSelector *selector,Option_t *option, Int_t nentries, Int_t firstentry)
*-*-*-*-*-*-*-*-*Process this chain executing the code in selector*-*-*-*-*
*-*              ================================================

void SetBranchAddress(const char *bname, void *add)
*-*-*-*-*-*-*-*-*Set branch address*-*-*-*-*-*-*-*
*-*              ==================

      bname is the name of a branch.
      add is the address of the branch.

void SetBranchStatus(const char *bname, Bool_t status)
*-*-*-*-*-*-*-*-*Set branch status Process or DoNotProcess*-*-*-*-*-*-*-*
*-*              =========================================

      bname is the name of a branch. if bname="*", apply to all branches.
      status = 1  branch will be processed
             = 0  branch will not be processed

void SetPacketSize(Int_t size)
*-*-*-*-*-*-*-*-*Set number of entries per packet for parallel root*-*-*-*-*
*-*              =================================================

void Streamer(TBuffer &b)
*-*-*-*-*-*-*-*-*Stream a class object*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*              =========================================



Inline Functions


              Int_t Draw(const char* varexp, const char* selection, Option_t* option, Int_t nentries = 1000000000, Int_t firstentry = 0)
              Int_t Fill()
              Int_t GetNtrees() const
             TFile* GetFile() const
         TObjArray* GetListOfFiles() const
           TObject* GetNotify() const
             TList* GetStatus() const
             TTree* GetTree() const
              Int_t GetTreeNumber() const
             Int_t* GetTreeOffset() const
              Int_t GetTreeOffsetLen() const
               void SetNotify(TObject* obj)
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void StreamerNVirtual(TBuffer& b)
             TChain TChain(TChain&)


Author: Rene Brun 03/02/97
Last update: root/tree:$Name: $:$Id: TChain.cxx,v 1.20 2001/06/07 08:56:05 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - 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.