macros and functions to fit pulse height distribution