Convert canvas to histogram in the same plot

Can you post the root file used by this macro ?