.! $ROOTSYS/test/eventexe 1000 1 1 1 TString dir = "$ROOTSYS/test/Event.root"; gSystem->ExpandPathName(dir); const auto filename = gSystem->AccessPathName(dir) ? "./Event.root" : "$ROOTSYS/test/Event.root"; TFile oldfile(filename); TTree *oldtree; oldfile.GetObject("T", oldtree); for (auto activeBranchName : {"event", "fNtrack", "fNseg", "fH"}) { oldtree->SetBranchStatus(activeBranchName, 1); } TFile newfile("small.root", "recreate"); auto newtree = oldtree->CloneTree(0); newtree->GetBranch("fH")->SetFile("small_fH.root"); newtree->CopyEntries(oldtree); newtree->Print(); newfile.Write();