void bla() { // -- The new file with the custom tree to be written TFile *n = new TFile("new.root", "RECREATE"); TTree* tt = new TTree("tt","tt"); // -- The variables you want in the new tree double npcms, nbla; tt->Branch("pcms", &npcms ,"pcms/D"); tt->Branch("bla",&nbla,"bla/D"); // -- The file with the big tree TFile *o = new TFile("old.root"); TTree *t = (TTree*)o->Get("oldtree"); // -- Get the needed variables from the old tree double bmxhad, bpcms; t->SetBranchAddress("mxhad",&bmxhad); t->SetBranchAddress("pcms",&bpcms); double bla; // -- Read in old tree int nb, nbytes; Int_t nentries = Int_t(t->GetEntries()); for (Int_t jentry = 0; jentry < nentries; jentry++) { nb = t->GetEntry(jentry); nbytes += nb; bla = 4.123*bpcms; // just to compute a new variable ... npcms = bpcms; nbla = bla; tt->Fill(); } n->Write(); }