close the output root file at the end
Use vectors for binning storage instead of variable size arrays.