RooFit or TSpectrum for peak-finding?

I’m trying to create a macro that finds peaks in a histogram, and then is able to fit them with a specified fitting function. I need to do this a lot, so I need a useful peak-search method. Searching around points me to the TSpectrum class, and it is quite trivial to search for peaks with this. However, the class page has a scary message saying that this is now legacy code and I should use RooFit or TUnfold where possible. I can’t see a peak-searching method in either of these. Am I not seeing the right method? Or is it better to use TSpectrum for this? I want the code to be maintainable for the forseeable future, so I am hesitant to write something with the TSpectrum class if it will not be maintained.

Hi @PTMac73,
That you for reaching out! I think that @jonas can probably help you on this. BTW, can you please include a small code snipped reproducing what you want to do with TSpecrum?

Cheers,
Monica

This issue has now come up many times without a definite answer from the core development team, so let me give you my 2 cents.

The team wants to consolidate the number of algorithms for fitting and unfolding in ROOT. One of the candidates to replace is TSpectrum with appropriate code using RooFit and TUnfold. Unfortunately the obsolete announcement exists now for a very long time without a clear alternative (yet).

If I were you, I would use for the moment TSpectrum for finding the peaks , like in example 15 - script SearchHR1.C on this page. and insert the results into a RooFit script. This way you are ready when the search option is available in RoFit.

-Eddy

1 Like

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.