created -9.76 34.9074 7
created -9.28 29.9207 6
created -8.8 24.9339 5
created -8.32 19.9471 4
created -7.84 49.8678 10
created -7.36 49.8678 10
created -6.88 29.9207 6
created -6.4 14.9603 3
created -5.92 49.8678 10
created -5.44 4.98678 1
created -4.96 24.9339 5
created -4.48 9.97356 2
created -4 44.881 9
created -3.52 19.9471 4
created -3.04 34.9074 7
created -2.56 24.9339 5
created -2.08 44.881 9
created -1.6 49.8678 10
created -1.12 44.881 9
created -0.64 39.8942 8
created -0.16 4.98678 1
created 0.32 24.9339 5
created 0.8 34.9074 7
created 1.28 14.9603 3
created 1.76 9.97356 2
created 2.24 44.881 9
created 2.72 24.9339 5
created 3.2 44.881 9
created 3.68 9.97356 2
created 4.16 24.9339 5
created 4.64 24.9339 5
created 5.12 44.881 9
created 5.6 44.881 9
created 6.08 44.881 9
created 6.56 24.9339 5
created 7.04 19.9471 4
created 7.52 9.97356 2
created 8 44.881 9
created 8.48 24.9339 5
created 8.96 34.9074 7
created 9.44 49.8678 10
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.98589e-05)
fit chi^2 = 5.62937e-06
found -7.84 (+-0.000261263) 49.8678 (+-0.160501) 10.0001 (+-0.00106287)
found -7.36 (+-0.000261596) 49.8679 (+-0.160526) 10.0002 (+-0.00106303)
found -5.92 (+-0.000259435) 49.8673 (+-0.160369) 10 (+-0.00106199)
found -1.6 (+-0.000261873) 49.868 (+-0.160547) 10.0002 (+-0.00106317)
found 9.44 (+-0.000259186) 49.868 (+-0.160369) 10.0002 (+-0.00106199)
found -4 (+-0.000274197) 44.8807 (+-0.152185) 9.00006 (+-0.0010078)
found -2.08 (+-0.000275795) 44.8812 (+-0.152292) 9.00015 (+-0.0010085)
found -1.12 (+-0.000276261) 44.8813 (+-0.152324) 9.00018 (+-0.00100871)
found 2.24 (+-0.000274388) 44.8808 (+-0.152198) 9.00007 (+-0.00100788)
found 3.2 (+-0.000274388) 44.8808 (+-0.152198) 9.00007 (+-0.00100788)
found 5.12 (+-0.000275675) 44.8811 (+-0.152283) 9.00014 (+-0.00100845)
found 5.6 (+-0.00027627) 44.8813 (+-0.152324) 9.00018 (+-0.00100872)
found 6.08 (+-0.000275675) 44.8811 (+-0.152283) 9.00014 (+-0.00100845)
found 8 (+-0.000274388) 44.8808 (+-0.152198) 9.00007 (+-0.00100788)
found -0.640001 (+-0.00029145) 39.8942 (+-0.143522) 8.0001 (+-0.000950431)
found -9.76 (+-0.000312318) 34.9073 (+-0.134276) 7.00006 (+-0.000889197)
found -3.04 (+-0.000312214) 34.9074 (+-0.134281) 7.00009 (+-0.000889232)
found 0.8 (+-0.000311932) 34.9074 (+-0.134266) 7.00008 (+-0.000889136)
found 8.96 (+-0.00031334) 34.9078 (+-0.134343) 7.00015 (+-0.00088964)
found -9.28 (+-0.000338335) 29.9209 (+-0.124371) 6.00012 (+-0.000823608)
found -6.88 (+-0.000338282) 29.9209 (+-0.124371) 6.00013 (+-0.000823606)
found -8.8 (+-0.000370615) 24.9341 (+-0.113534) 5.0001 (+-0.000751845)
found -2.56 (+-0.000372184) 24.9344 (+-0.113597) 5.00016 (+-0.00075226)
found 2.72 (+-0.000372634) 24.9345 (+-0.113615) 5.00018 (+-0.000752382)
found 6.56 (+-0.000371315) 24.9342 (+-0.113563) 5.00013 (+-0.000752034)
found 8.48 (+-0.000372184) 24.9344 (+-0.113597) 5.00016 (+-0.00075226)
found -4.96 (+-0.000367672) 24.9337 (+-0.113425) 5.00003 (+-0.000751119)
found 0.320002 (+-0.00036936) 24.934 (+-0.11349) 5.00008 (+-0.000751553)
found 4.16 (+-0.000369481) 24.9339 (+-0.113492) 5.00007 (+-0.000751561)
found 4.64 (+-0.000371641) 24.9343 (+-0.113576) 5.00014 (+-0.000752118)
found -3.52 (+-0.000417042) 19.9477 (+-0.101635) 4.00016 (+-0.000673045)
found -8.32 (+-0.000416623) 19.9476 (+-0.101622) 4.00015 (+-0.000672958)
found 7.04 (+-0.000413761) 19.9472 (+-0.10153) 4.00007 (+-0.000672353)
found -6.4 (+-0.00048298) 14.961 (+-0.0880548) 3.00016 (+-0.000583115)
found 1.28 (+-0.000479692) 14.9606 (+-0.0879747) 3.00009 (+-0.000582584)
found 3.68 (+-0.000593393) 9.97414 (+-0.0719289) 2.00014 (+-0.000476326)
found -4.48 (+-0.000593393) 9.97414 (+-0.0719289) 2.00014 (+-0.000476326)
found 1.76 (+-0.00059182) 9.97404 (+-0.0719031) 2.00012 (+-0.000476155)
found 7.52 (+-0.000592672) 9.97409 (+-0.0719169) 2.00013 (+-0.000476247)
found -5.44001 (+-0.00084808) 4.98748 (+-0.0509423) 1.00015 (+-0.000337349)
found -0.160004 (+-0.000846495) 4.98738 (+-0.050927) 1.00013 (+-0.000337248)
#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()