created -9.82 53.1923 8
created -9.46 33.2452 5
created -9.1 26.5962 4
created -8.74 53.1923 8
created -8.38 39.8942 6
created -8.02 53.1923 8
created -7.66 66.4904 10
created -7.3 33.2452 5
created -6.94 26.5962 4
created -6.58 59.8413 9
created -6.22 26.5962 4
created -5.86 26.5962 4
created -5.5 46.5433 7
created -5.14 39.8942 6
created -4.78 53.1923 8
created -4.42 53.1923 8
created -4.06 59.8413 9
created -3.7 59.8413 9
created -3.34 13.2981 2
created -2.98 13.2981 2
created -2.62 46.5433 7
created -2.26 26.5962 4
created -1.9 39.8942 6
created -1.54 46.5433 7
created -1.18 13.2981 2
created -0.82 6.64904 1
created -0.46 39.8942 6
created -0.1 59.8413 9
created 0.26 13.2981 2
created 0.62 13.2981 2
created 0.98 66.4904 10
created 1.34 46.5433 7
created 1.7 13.2981 2
created 2.06 33.2452 5
created 2.42 39.8942 6
created 2.78 26.5962 4
created 3.14 39.8942 6
created 3.5 46.5433 7
created 3.86 19.9471 3
created 4.22 26.5962 4
created 4.58 46.5433 7
created 4.94 39.8942 6
created 5.3 19.9471 3
created 5.66 66.4904 10
created 6.02 46.5433 7
created 6.38 46.5433 7
created 6.74 19.9471 3
created 7.1 39.8942 6
created 7.46 66.4904 10
created 7.82 39.8942 6
created 8.18 46.5433 7
created 8.54 13.2981 2
created 8.9 39.8942 6
created 9.26 19.9471 3
created 9.62 6.64904 1
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-5.34056e-06)
fit chi^2 = 4.0621e-07
found -7.66 (+-5.18166e-05) 66.4905 (+-0.0566002) 10.0001 (+-0.000285503)
found 0.98 (+-5.16651e-05) 66.4903 (+-0.0565809) 10.0001 (+-0.000285406)
found 5.66 (+-5.17155e-05) 66.4904 (+-0.0565871) 10.0001 (+-0.000285437)
found 7.46 (+-5.17945e-05) 66.4904 (+-0.0565971) 10.0001 (+-0.000285488)
found -4.06 (+-5.47776e-05) 59.8417 (+-0.053715) 9.00011 (+-0.00027095)
found -3.7 (+-5.45463e-05) 59.8414 (+-0.053688) 9.00007 (+-0.000270813)
found -6.58 (+-5.4492e-05) 59.8413 (+-0.0536804) 9.00005 (+-0.000270775)
found -0.1 (+-5.44635e-05) 59.8413 (+-0.0536776) 9.00005 (+-0.000270761)
found -4.42 (+-5.81562e-05) 53.1927 (+-0.0506492) 8.00011 (+-0.000255485)
found -9.82 (+-5.78809e-05) 53.1922 (+-0.0506149) 8.00003 (+-0.000255312)
found -8.74 (+-5.79189e-05) 53.1924 (+-0.0506232) 8.00007 (+-0.000255354)
found -8.02 (+-5.81179e-05) 53.1926 (+-0.0506451) 8.00011 (+-0.000255465)
found -4.78 (+-5.80631e-05) 53.1926 (+-0.0506389) 8.00009 (+-0.000255433)
found 1.34 (+-6.19827e-05) 46.5435 (+-0.0473611) 7.00008 (+-0.0002389)
found 6.02 (+-6.22374e-05) 46.5437 (+-0.0473845) 7.00011 (+-0.000239018)
found -5.5 (+-6.19756e-05) 46.5434 (+-0.0473591) 7.00007 (+-0.00023889)
found -2.62 (+-6.17613e-05) 46.5432 (+-0.0473394) 7.00004 (+-0.00023879)
found -1.54 (+-6.18502e-05) 46.5433 (+-0.0473479) 7.00005 (+-0.000238833)
found 3.5 (+-6.19195e-05) 46.5433 (+-0.047354) 7.00006 (+-0.000238864)
found 4.58 (+-6.19756e-05) 46.5434 (+-0.0473591) 7.00007 (+-0.00023889)
found 6.38 (+-6.19571e-05) 46.5434 (+-0.0473577) 7.00007 (+-0.000238882)
found 8.18 (+-6.18502e-05) 46.5433 (+-0.0473479) 7.00005 (+-0.000238833)
found -8.38 (+-6.7286e-05) 39.8947 (+-0.0438748) 6.00011 (+-0.000221314)
found 7.82 (+-6.73169e-05) 39.8947 (+-0.0438775) 6.00011 (+-0.000221327)
found -5.14 (+-6.72464e-05) 39.8946 (+-0.0438714) 6.0001 (+-0.000221297)
found -1.9 (+-6.70603e-05) 39.8944 (+-0.0438559) 6.00007 (+-0.000221219)
found -0.459999 (+-6.68807e-05) 39.8944 (+-0.0438432) 6.00007 (+-0.000221154)
found 2.42 (+-6.69693e-05) 39.8943 (+-0.0438483) 6.00006 (+-0.00022118)
found 3.14 (+-6.70603e-05) 39.8944 (+-0.0438559) 6.00007 (+-0.000221219)
found 4.94 (+-6.6996e-05) 39.8944 (+-0.0438508) 6.00007 (+-0.000221193)
found 7.1 (+-6.7105e-05) 39.8945 (+-0.0438603) 6.00009 (+-0.000221241)
found 8.9 (+-6.67081e-05) 39.8942 (+-0.0438275) 6.00003 (+-0.000221075)
found -9.46 (+-7.36151e-05) 33.2455 (+-0.0400457) 5.00008 (+-0.000201999)
found -7.3 (+-7.3697e-05) 33.2456 (+-0.0400517) 5.00009 (+-0.000202029)
found 2.06 (+-7.33496e-05) 33.2453 (+-0.0400276) 5.00005 (+-0.000201908)
found -9.1 (+-8.25466e-05) 26.5965 (+-0.0358317) 4.00009 (+-0.000180743)
found -6.94 (+-8.25981e-05) 26.5966 (+-0.0358348) 4.00009 (+-0.000180758)
found -6.22 (+-8.25195e-05) 26.5965 (+-0.0358304) 4.00009 (+-0.000180736)
found -5.86 (+-8.24123e-05) 26.5965 (+-0.035824) 4.00007 (+-0.000180704)
found -2.26 (+-8.25595e-05) 26.5965 (+-0.0358323) 4.00009 (+-0.000180746)
found 2.78 (+-8.24979e-05) 26.5965 (+-0.0358287) 4.00008 (+-0.000180728)
found 4.22 (+-8.23203e-05) 26.5964 (+-0.035819) 4.00007 (+-0.000180679)
found 3.86 (+-9.54226e-05) 19.9475 (+-0.0310359) 3.00007 (+-0.000156551)
found 5.3 (+-9.58101e-05) 19.9477 (+-0.0310532) 3.00011 (+-0.000156639)
found 6.74 (+-9.56115e-05) 19.9476 (+-0.0310441) 3.00009 (+-0.000156593)
found 9.26 (+-9.48738e-05) 19.9473 (+-0.0310135) 3.00005 (+-0.000156438)
found -3.34 (+-0.000117189) 13.2985 (+-0.0253512) 2.00007 (+-0.000127877)
found 0.259998 (+-0.000117189) 13.2985 (+-0.0253512) 2.00007 (+-0.000127877)
found -1.18 (+-0.000116704) 13.2983 (+-0.0253373) 2.00005 (+-0.000127807)
found 1.7 (+-0.000117521) 13.2985 (+-0.0253602) 2.00008 (+-0.000127922)
found 8.54 (+-0.000117646) 13.2986 (+-0.0253639) 2.00009 (+-0.000127941)
found -2.98 (+-0.000116999) 13.2984 (+-0.0253452) 2.00006 (+-0.000127846)
found 0.620002 (+-0.000117273) 13.2985 (+-0.025354) 2.00008 (+-0.000127891)
found 9.62 (+-0.000163675) 6.64917 (+-0.0179006) 1.00003 (+-9.02946e-05)
found -0.819998 (+-0.000166607) 6.64935 (+-0.0179392) 1.00005 (+-9.0489e-05)
#include <iostream>
TH1F *FitAwmi_Create_Spectrum(
void) {
delete gROOT->FindObject(
"h");
npeaks++;
std::cout << "created "
<< area << std::endl;
}
std::cout << "the total number of created peaks = " << npeaks
<<
" with sigma = " <<
sigma << std::endl;
}
void FitAwmi(void) {
TH1F *
h = FitAwmi_Create_Spectrum();
if (!cFit) cFit =
new TCanvas(
"cFit",
"cFit", 10, 10, 1000, 700);
for (
i = 0;
i < nbins;
i++) source[
i] =
h->GetBinContent(
i + 1);
for(
i = 0;
i < nfound;
i++) FixAmp[
i] = FixPos[
i] =
kFALSE;
for (
i = 0;
i < nfound;
i++) {
bin = 1 +
Int_t(Pos[
i] + 0.5);
Amp[
i] =
h->GetBinContent(bin);
}
delete gROOT->FindObject(
"d");
TH1F *
d =
new TH1F(*
h);
d->SetNameTitle(
"d",
"");
d->Reset(
"M");
for (
i = 0;
i < nbins;
i++)
d->SetBinContent(
i + 1, source[
i]);
sigma *= dx; sigmaErr *= dx;
std::cout << "the total number of found peaks = " << nfound
<<
" with sigma = " <<
sigma <<
" (+-" << sigmaErr <<
")"
<< std::endl;
std::cout <<
"fit chi^2 = " << pfit->
GetChi() << std::endl;
for (
i = 0;
i < nfound;
i++) {
bin = 1 +
Int_t(Positions[
i] + 0.5);
Pos[
i] =
d->GetBinCenter(bin);
Amp[
i] =
d->GetBinContent(bin);
Positions[
i] =
x1 + Positions[
i] * dx;
PositionsErrors[
i] *= dx;
std::cout << "found "
<< Positions[
i] <<
" (+-" << PositionsErrors[
i] <<
") "
<< Amplitudes[
i] <<
" (+-" << AmplitudesErrors[
i] <<
") "
<< Areas[
i] <<
" (+-" << AreasErrors[
i] <<
")"
<< std::endl;
}
d->SetLineColor(
kRed);
d->SetLineWidth(1);
if (pm) {
h->GetListOfFunctions()->Remove(pm);
delete pm;
}
h->GetListOfFunctions()->Add(pm);
delete pfit;
delete [] Amp;
delete [] FixAmp;
delete [] FixPos;
delete s;
delete [] source;
return;
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char x1
R__EXTERN TRandom * gRandom
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
1-D histogram with a float per channel (see TH1 documentation)
A PolyMarker is defined by an array on N points in a 2-D space.
Advanced 1-dimensional spectra fitting functions.
void SetPeakParameters(Double_t sigma, Bool_t fixSigma, const Double_t *positionInit, const Bool_t *fixPosition, const Double_t *ampInit, const Bool_t *fixAmp)
This function sets the following fitting parameters of peaks:
Double_t * GetAmplitudesErrors() const
void FitAwmi(Double_t *source)
This function fits the source spectrum.
Double_t * GetAreasErrors() const
void GetSigma(Double_t &sigma, Double_t &sigmaErr)
This function gets the sigma parameter and its error.
Double_t * GetAreas() const
Double_t * GetAmplitudes() const
void SetFitParameters(Int_t xmin, Int_t xmax, Int_t numberIterations, Double_t alpha, Int_t statisticType, Int_t alphaOptim, Int_t power, Int_t fitTaylor)
This function sets the following fitting parameters:
Double_t * GetPositionsErrors() const
Double_t * GetPositions() const
Advanced Spectra Processing.
Int_t SearchHighRes(Double_t *source, Double_t *destVector, Int_t ssize, Double_t sigma, Double_t threshold, bool backgroundRemove, Int_t deconIterations, bool markov, Int_t averWindow)
One-dimensional high-resolution peak search function.
Double_t * GetPositionX() const
constexpr Double_t Sqrt2()
Double_t Sqrt(Double_t x)
Returns the square root of x.
constexpr Double_t TwoPi()