Reading from few root files

I am new to root. I need to read from few root files in the template code, genarated by ->MakeClass(“filename”).
when I check the xx.h file I see where the root file added:

[code]Zee::Zee(TTree *tree)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
TFile f = (TFile)gROOT->GetListOfFiles()->FindObject(“trig1_misal1_valid1.005144.PythiaZee.recon.NTUP.v12000605_tid009163._00023.root”);
if (!f) {
f = new TFile(“trig1_misal1_valid1.005144.PythiaZee.recon.NTUP.v12000605_tid009163._00023.root”);

  }
  tree = (TTree*)gDirectory->Get("CollectionTree");

}
Init(tree);
}[/code]

But I need to read from few more files, How could I include them:?:

Hi,

create a TChain, and pass it to the Zee() constructor as an argument. A TChain inherits from a TTree.

Cheers, Axel.

Hi,

I am having the same question. But after reading the suggestion, I am still not quite sure how to implement it. Here is my shot:
(I want to use loop to read over 40 .root files with the name, file01, file02,… file40)

susy::susy (TChain *ch) { TChain ch("tree"); for (Int_t j=1;j<40;j++){ ch.Add("file%d"); // don't really know how to do this part } ch = (TTree*)gDirectory->Get("tree") }

I think there are many errors. Please help.

Thank you in advance,

Raksapol

Replace your loop by:

TChain ch("tree"); for (Int_t j=1;j<40;j++){ ch.Add(Form("file%d",i)); // don't really know how to do this part } .. ch.Draw("something");
Rene

Hi,

Thank you for your help. The code is working fine now.

Cheers,

Raksapol