Return type of TSpectrum2::GetPositionX()

I am trying to use a TSpectrum2 to find peaks in a TH2:

void locatePoints(TH2* hist){
	TSpectrum2* spec = new TSpectrum2(100);
	int n_peaks_found = spec->Search(hist,2,"col");
	std::cout << n_peaks_found << " peaks found" << std::endl;
	Double_t* x = spec->GetPositionX();
	Double_t* y = spec->GetPositionY();
	for (int i=0;i<n_peaks_found;i++){
		std::cout << x[i] << " " << y[i] << std::endl;
	}
}

This is almost an exact copy paste from this example: root.cern.ch/root/html/tutorial … ks2.C.html
Also the online documentation (root.cern.ch/doc/master/classTSpectrum2.html) says that the signature is:

Double_t * 	GetPositionX () const 

However, I get the error:

If I replace Double_t with Float_t it seems to work. I just want to be sure, that this is the correct return type. Did it change at some point? I am using root 5.34.

Hi,

I guess if you’re working with ROOT 5.34, you’d better look at the documentation for ROOT 5.34
root.cern.ch/root/html534/TSpectrum2.html
, not 6.07 as your link suggests. In 5.34, GetPositionX() and GetPositionY() are of type Float_t*.

Yes it seems that the type has been changed between ROOT 5 and ROOT 6. In the ROOT5 documentation, it is written that a float is returned.