Peak finding program

I have some root files consisting of spectrums.
I have to write down a code to check gain drift and fitting the peaks.
How do I find out the peaks out of the spectrum and fit them ??

https://root.cern/doc/master/peaks_8C.html
also
https://root-forum.cern.ch/search?q=find%20peaks