This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 39.8942 8
created -9.28 39.8942 8
created -8.8 44.881 9
created -8.32 14.9603 3
created -7.84 9.97356 2
created -7.36 44.881 9
created -6.88 24.9339 5
created -6.4 44.881 9
created -5.92 4.98678 1
created -5.44 49.8678 10
created -4.96 14.9603 3
created -4.48 4.98678 1
created -4 9.97356 2
created -3.52 34.9074 7
created -3.04 34.9074 7
created -2.56 29.9207 6
created -2.08 14.9603 3
created -1.6 39.8942 8
created -1.12 19.9471 4
created -0.64 49.8678 10
created -0.16 49.8678 10
created 0.32 24.9339 5
created 0.8 39.8942 8
created 1.28 24.9339 5
created 1.76 14.9603 3
created 2.24 14.9603 3
created 2.72 19.9471 4
created 3.2 14.9603 3
created 3.68 29.9207 6
created 4.16 44.881 9
created 4.64 34.9074 7
created 5.12 4.98678 1
created 5.6 14.9603 3
created 6.08 14.9603 3
created 6.56 44.881 9
created 7.04 39.8942 8
created 7.52 39.8942 8
created 8 9.97356 2
created 8.48 4.98678 1
created 8.96 39.8942 8
created 9.44 14.9603 3
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.76382e-05)
fit chi^2 = 1.74526e-06
found -5.44 (+-0.000144454) 49.8673 (+-0.0892938) 10 (+-0.00059132)
found -0.639999 (+-0.000145471) 49.8678 (+-0.0893672) 10.0001 (+-0.000591806)
found -0.160001 (+-0.00014557) 49.8679 (+-0.0893744) 10.0002 (+-0.000591853)
found -8.8 (+-0.000153191) 44.881 (+-0.0847711) 9.00011 (+-0.00056137)
found -7.36 (+-0.00015278) 44.8808 (+-0.0847437) 9.00007 (+-0.000561188)
found -6.4 (+-0.000152567) 44.8807 (+-0.0847311) 9.00006 (+-0.000561104)
found 4.16 (+-0.000153442) 44.8811 (+-0.0847874) 9.00013 (+-0.000561477)
found 6.56 (+-0.000153191) 44.881 (+-0.0847711) 9.00011 (+-0.00056137)
found -9.76 (+-0.000162766) 39.8941 (+-0.0799331) 8.00008 (+-0.000529331)
found -9.28 (+-0.000163239) 39.8946 (+-0.0799686) 8.00017 (+-0.000529567)
found -1.6 (+-0.000162209) 39.894 (+-0.0799061) 8.00007 (+-0.000529152)
found 0.8 (+-0.000162586) 39.8942 (+-0.0799284) 8.0001 (+-0.0005293)
found 7.04 (+-0.000163239) 39.8946 (+-0.0799686) 8.00017 (+-0.000529567)
found 7.52 (+-0.000162439) 39.8942 (+-0.0799211) 8.0001 (+-0.000529252)
found 8.96 (+-0.000161664) 39.8939 (+-0.0798756) 8.00004 (+-0.000528951)
found -3.52 (+-0.000173712) 34.9074 (+-0.0747621) 7.00009 (+-0.000495088)
found -3.04 (+-0.000174318) 34.9076 (+-0.0747933) 7.00013 (+-0.000495295)
found 4.64 (+-0.000173627) 34.9075 (+-0.0747598) 7.0001 (+-0.000495073)
found -2.56 (+-0.000188051) 29.9208 (+-0.0692349) 6.0001 (+-0.000458486)
found 3.68 (+-0.000188262) 29.9209 (+-0.0692451) 6.00012 (+-0.000458554)
found -6.88 (+-0.000207483) 24.9345 (+-0.0632612) 5.00018 (+-0.000418927)
found 0.319999 (+-0.000207474) 24.9345 (+-0.0632609) 5.00018 (+-0.000418925)
found 1.28 (+-0.000206417) 24.9341 (+-0.063219) 5.00011 (+-0.000418648)
found -1.12 (+-0.000232502) 19.9478 (+-0.0566002) 4.00018 (+-0.000374817)
found 2.72 (+-0.000230229) 19.9472 (+-0.0565269) 4.00006 (+-0.000374331)
found -8.32 (+-0.000267472) 14.9607 (+-0.0489943) 3.00011 (+-0.000324449)
found -4.96 (+-0.00026706) 14.9607 (+-0.0489862) 3.00011 (+-0.000324395)
found -2.08 (+-0.000268568) 14.9608 (+-0.0490197) 3.00014 (+-0.000324618)
found 1.76 (+-0.000267044) 14.9605 (+-0.0489822) 3.00008 (+-0.000324369)
found 2.24 (+-0.000266766) 14.9605 (+-0.0489753) 3.00007 (+-0.000324324)
found 3.2 (+-0.00026762) 14.9606 (+-0.0489961) 3.0001 (+-0.000324461)
found 6.08 (+-0.000267888) 14.9607 (+-0.0490037) 3.00012 (+-0.000324511)
found 9.44 (+-0.000265065) 14.9607 (+-0.0489479) 3.00011 (+-0.000324142)
found 5.6 (+-0.000265457) 14.9603 (+-0.0489455) 3.00004 (+-0.000324126)
found -7.84 (+-0.000329526) 9.97404 (+-0.0400357) 2.00012 (+-0.000265124)
found 8 (+-0.000327847) 9.97389 (+-0.0400094) 2.00009 (+-0.000264949)
found -4 (+-0.000327572) 9.97383 (+-0.0400044) 2.00008 (+-0.000264916)
found -5.92 (+-0.000474379) 4.98768 (+-0.0283846) 1.00019 (+-0.000187968)
found 5.11999 (+-0.000469257) 4.98722 (+-0.0283378) 1.0001 (+-0.000187658)
found 8.48001 (+-0.000468675) 4.98723 (+-0.0283335) 1.0001 (+-0.00018763)
found -4.48 (+-0.000465493) 4.98697 (+-0.0283043) 1.00005 (+-0.000187436)
#include <iostream>
{
delete gROOT->FindObject(
"h");
<< std::endl;
}
std::cout <<
"the total number of created peaks = " <<
npeaks <<
" with sigma = " <<
sigma << std::endl;
}
void FitAwmi(void)
{
else
for (i = 0; i < nbins; i++)
source[i] =
h->GetBinContent(i + 1);
for (i = 0; i <
nfound; i++) {
Amp[i] =
h->GetBinContent(bin);
}
pfit->SetFitParameters(0, (nbins - 1), 1000, 0.1,
pfit->kFitOptimChiCounts,
pfit->kFitAlphaHalving,
pfit->kFitPower2,
pfit->kFitTaylorOrderFirst);
delete gROOT->FindObject(
"d");
d->SetNameTitle(
"d",
"");
for (i = 0; i < nbins; i++)
d->SetBinContent(i + 1,
source[i]);
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++) {
Pos[i] =
d->GetBinCenter(bin);
Amp[i] =
d->GetBinContent(bin);
}
h->GetListOfFunctions()->Remove(
pm);
}
h->GetListOfFunctions()->Add(
pm);
delete s;
return;
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Advanced 1-dimensional spectra fitting functions.
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()