Fitting Gaussians without so much user input

Hello! I’m new at ROOT and I’m currently working with gamma spectrums. My goal is to write a ROOT script that can find the peaks and fit them with a Gaussian. I’ve managed to find the peaks, but I’m confused when it comes to fitting the peaks.
It seems to me that TSpectrum() only works if I specify the peak parameters in the script. I’d like to write something that could fit the peaks regardless of the isotope I’m inspecting.
So, I’m currently using TF1, and it works fine as long as I specify when to start/end in the script itself. This is annoying since I’d like to simulate more than one isotope, and I don’t want to keep changing the script to fit the peaks. Also, having to put it the gaussian parameters feels counterproductive.
How can I make the process more automatic?

Hello @liliac,
welcome on the ROOT forum!
I think that @Jonas can help with this, but in the meanwhile I suggest you to have a look at the roofit tutorials.



TSpectrum should be the think you want to use. It is able to find automatically the position of the peaks that can be used later for Gaussian fitting.
You can look at the tutorial peaks.C


Thank you! I ended up using TPolyMarker to find the peaks.

TPolymarker does not “find the peaks”. TSpectrum find them. Then you display what TSpectrum found using TPolymarker.