Table of Contents

How to use chains in ROOT

Idea

A chain is sort of a container for trees. A chain can contain an arbitrary number of trees and can be used the same way as a tree, as the class chain inherits from the class tree.

Adding Files

A simple example is the following:

TChain* myChain = new TChain("DecayTree");
myChain->Add("myRootFile.root");

Note the following:

TChain* myChain = new TChain("mySubdirectory/DecayTree");

Accessing the chain

All the trees in the chain can be accessed the same way as it is done with trees, for example:

myChain->Draw("B_M");

to make a histogram with the B-mass.

Note: The first time you access the chain in a ROOT session, it takes a little longer, as the file has to be checked (there is a way around this, but it hasn't worked out yet…)