{ TChain *chain1 = new TChain("Tree1"); chain1->Add("inputfile1.root"); TChain *chain2 = new TChain("Tree2"); chain2->Add("inputfile2.root"); chain1->AddFriend(chain2); chain1->SetBranchStatus("*",0); chain1->SetBranchStatus("Tree2.d",1); chain1->SetBranchStatus("a",1); chain1->SetBranchStatus("b",1); TCut myTCut="a>1."; TTree *newTree = chain1->CopyTree(myTCut); TFile *fout = new TFile("outputfile.root","recreate"); fout->WriteTObject(newTree); fout->Close(); }