.! $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); oldtree->SetBranchStatus("*", 0); for (auto activeBranchName : {"event", "fNtrack", "fNseg", "fH"}) oldtree->SetBranchStatus(activeBranchName, 1); TFile newfile("small.root", "recreate"); auto newtree = oldtree->CloneTree(); newtree->Print(); newfile.Write();