void AddBranch() { // TFILE TFile f("EXISITING_FILE","update"); // Variable for filling int isMuonStream; // Exisiting ttree TTree *t = (TTree*)f.Get("mini"); // New branches to add TBranch *newBranch = t->Branch("isMuonStream",&isMuonStream,"isMuonStream/i"); //read the number of entries in the tree int nentries = (int)t->GetEntries(); // Loop for (int i = 0; i < nentries; i++){ // Calc value isMuonStream = 1; // Fill new branch newBranch->Fill(); } // Save the updated version of the ttree t->Write("",TObject::kOverwrite); // Close file f.Close(); }