I have spectrum with few negative values. I would like to use deconvolution in TSpectrum to extract peaks. However, it doesn’t work well. You can see it in c1.jpg.
I include here my code and my spectrum. Could you please help me to make it work well. Only positive peak is considered as a peak.
Thank you so much, 6901.txt (103 KB) na.C (1.6 KB)
the deconvolution works well for positive data. I would suggest to do not subtract the offset that makes the data negative.
I am not expert on this function, so I am afraid I am not able to help you more on this problem
Either before or after you “d->GetXaxis()->SetRange(xmin-1,xmax);”, try to add: if (d->GetMinimum() < 0.0) {
TF1 *f = gROOT->GetFunction("pol0"); // use ROOT's pre-defined function
f->SetRange(d->GetXaxis()->GetXmin(), d->GetXaxis()->GetXmax());
f->SetParameter(0, TMath::Abs(d->GetMinimum()));
d->Add(f); // shift bins
} or: if (d->GetMinimum() < 0.0) {
TF1 *f = new TF1("f",
TString::Format("%25.17g", TMath::Abs(d->GetMinimum())),
d->GetXaxis()->GetXmin(), d->GetXaxis()->GetXmax());
d->Add(f); // shift bins
delete f; // no longer needed
}
You can’t use TSpectrum::Deconvolution for positive and negative data at the same time.
It is property of algorithm.
I have the same problem.
I have contacted with developer of TSpectrum class (Vladislav Matousek) and he told: “My short answer is: Gold deconvolution algorithm is constrained to process positive data only. But this needs further explanation.”.
I am not expert in this theme but, as I understand, if you use only positive data you will have more stable solution.
What should we do in case of positive and negative data at the same time?
I’m so sorry to answer very late. It was a long vacation in my country.
The reason that I have negative value come from my background subtraction algorithms. In my method, I cannot not subtract background directly, therefore I need to detect background in another experiment, than subtract it. The statistical fluctuation and the instability of devices caused the negative values after subtraction, but the total average of background is near zero.