Newbie: Using TSpectrum with Graphs

Hi -

I’m a ROOT newbie, so excuse any idiotic questions I may ask.

I am investigating using ROOT to analyze some Raman spectra (I need to automate the analysis), and have a couple of questions:

  1. I gather one cannot use the peak finding functions in TSPectrum with TGraph objects - is that correct?

  2. Assuming I have to use histograms with TSPectrum, how can I create one from a set of (x,y) pairs where x gives the bin and y the bin contents? (i.e. - use a histogram to emulate a graph). I’ve not been successful in my attempts.


TSpectrum works only with TH1 objects.

You can create an histogram from a TGraph IF your x values are equidistant.
Create a TH1
TH1 h(“h”,“my spectrum”,nbins,xmin,xmax);
h.SetContents(y); //where y is the array of y values


Wow - that was fast. Thank you!