Baseline Calculaion

Hiii ROOT Users

I would like to do baseline calculation for the figure shown in the attachments .For Screenshot.png it is present at the bottom and for Screenshot-1.png this is present at the top,I already know that there exist TSpectrum class in ROOT which does the background calculations of the spectrum but I have doubt that whether can I use this for such type of data or not

thanks
with Regards