Hi,
please take a look here for an overview of the different methods available to read values of a branch and fill a histogram.
Once you have the histogram filled, if I understand correctly you would just need to call ComputeIntegral on it (see the docs).