Hi!
I have a problem involving SearchHighRes method from TSpectrum2 class. First I tried to do ordinary Search
[code]
TSpectrum2* s= new TSpectrum2(20,1);
Int_t val=s->Search(histo,3.,"",0.2);
/code]
It worked fine, but when I tried to do
binx=(xmax-xmin)/nbinsx;
biny=(ymax- ymin)/nbinsy;
PosX=s->GetPositionX();
PosY=s->GetPositionY();
cout<<"positions acquired"<<endl;
//initial values
for(Int_t i=0;i<n;i++){
FixPosX[i]=kFALSE;
FixPosY[i]=kFALSE;
FixAmp[i]=kFALSE;
Amp[i]=source[(int)((PosX[i]-xmin)/binx+0.5)][(int)((PosY[i]-ymin)/biny+0.5)];
AmpXY[i]=0;
}
TSpectrum2Fit *pfit=new TSpectrum2Fit(n);
pfit->SetFitParameters(xmin, xmax-1,ymin, ymax-1, 1000, 0.1, pfit->kFitOptimChiCounts,pfit->kFitAlphaHalving,pfit->kFitPower2,pfit->kFitTaylorOrderFirst);
pfit->SetPeakParameters(2, kFALSE,2 , kFALSE, 0, kTRUE, PosX, (Bool_t *) FixPosX, PosY, (Bool_t *) FixPosY, PosX, (Bool_t *) FixPosX, PosY, (Bool_t *) FixPosY, Amp, (Bool_t *) FixAmp, AmpXY, (Bool_t *) FixAmp, AmpXY, (Bool_t *) FixAmp);
pfit->SetBackgroundParameters(0,kFALSE,0,kTRUE,0,kTRUE);
cout<<"fit parameters set!"<<endl;
pfit->FitAwmi(source);
, I got segmentation fault, right at the point of fitting! Despite the fact that I already used a lot of tutorial program from reference guide, I simply copied it this time completely, now involving SearchHighRes method. Of course, it was taken care of proper binning and ranges for input histogram. Now the situation was even worse. The program gave me peak positions out of the proper range of histogram! Then I tried to assume these are the relative positions above the xmin and ymin of histogram, but calculated amplitudes were then zero. I’m not sure why this is happening, why program crashes in first case, and why it behaves strangely in second case. I will be very thankful for any help.
Here’s also the source with ordinary search attached.
peak_fitter2D.cpp (3.06 KB)