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:?:
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")
}