Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: C++
So I am trying to use TSpectrum to locate two peaks in this spectrum and it is only finding one of the peaks. How can I get TSpectrum to see the other peak? Right now I am not making the fits right now so the other part is from older parts of the code just temporally put on hold.
//Making fits.
const int NbPeaks = 2;
double fitlow[NbPeaks], fithigh[NbPeaks];
float centroid[NbPeaks][2], sigma[NbPeaks][2];
TSpectrum *peakFind = new TSpectrum(NbPeaks,0.5);
Int_t nfound = peakFind->Search(myh,2);
printf("Found %d candidate peaks to fitn",nfound);
//fitlow[0]=93;
//fithigh[0]=115;
//fitlow[1]=1014.5;
//fithigh[1]=1037;
for(int peak=0;peak<NbPeaks;peak++)
{
TString gausname = Form("gaus_%s%i_peak%i",ListRaw.Data(),pie,peak);
TF1 *gaus = new TF1(gausname,"gaus",fitlow[peak],fithigh[peak]);
myh->Fit(gaus,"RQN0+");
gaus->Draw("same");
centroid[pie][peak] = gaus->GetParameter(1);
//centroid[pie][peak] = gaus->GetParError(1);
sigma[pie][peak] = (gaus->GetParameter(2));
//sigma[pie][peak] = (gaus->GetParError(2));
cout << sigma[pie][peak]<<endl;
}
TString outname = "/data/x1/Detector/SiWinter20/Data/";
outname += Form("%s_Run%s_%s%02i.txt",Serial.Data(),Run,ListRaw.Data(),Pienum.Data());
ofstream fout;
fout.open(outname);
for (int peak=0;peak<NbPeaks;peak++)
{
fout<<centroid[pie][peak]<<endl;
}
out.Close();
}