Chain in MakeClass

Dear All,
I generated the framework with tree->MakeClass() which is perfectly works
with for single root file containing a tree. And now I want to use a chain of trees, but don’t know how to add a chain. So for a sigle tree in .h file in Constructor I used the following code:

t3333::t3333(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(“CBNT.root”);
if (!f) {
f = new TFile(“file1.root”);
f->cd(“file1.root:/CBNT”);
}
tree = (TTree
)gDirectory->Get(“3333”);

}
Init(tree);
}
I suspect istead of tree here I should initialize a Chain but how to do it?
I tried to replace the code by:

t3333::t3333(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) {
chain=new TChain(“CBNT”);
chain->Add(“file1.root”); // add the files
chain->Add(“file2.root”);
}
Init(chain);
}

But it crashes in Notify() call

I have a macro which I execute by typing,

root runtest.C

runtest.C is below.
test.C and test.h are made by doing, ntp3->MakeClass(“test”)


runtest(){

gROOT->ProcessLine(".L test.C+");

TChain *p1 = new TChain(“ntp3”,“chain XsPhi”);

p1->Add(“file1.root”);
p1->Add(“file2.root”);

// run over the files
TTree* mytree = (TTree*)p1;
test a(mytree);

a.Loop();
//

}

Thank you! So easy!