Add Branches to Tree

You can do something line in the piece of code below. See also TTree::AddFriend

Rene

void addBranches() { TFile *fold = TFile::Open("oldfile.root"); TTree *Told = (TTree*)fold->Get("mytreename"); TFile *fnew = TFile::Open("newfile.root","recreate"); TTree *Tnew = Told->CloneTree(0); TBranch *b1 = Tnew->Branch("bnew1",...); TBranch *b2 = Tnew->Branch("bnew2",...); Long64_t nentries = Told->GetEntries(); for (Long64_t i=0;i<nentries;i++) { Told->GetEntry(i); //fill variables/classes to go in branches b1 and b2 //then fill the new Tree with the branch variables b1->Fill(); b2->Fill(); } Tnew->AutoSave(); delete fnew; delete fold; }