old optimization code, runs on his.root files