newBranch = 0.5 * (data_a + data_b); avgBranch->Fill();
with “newer” versions of ROOT (starting with v6.14), it’s recommended to use:
newBranch = 0.5 * (data_a + data_b); avgBranch->BackFill();
BTW. After the “for
” loop, you need: tree->Write();