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 9.97356 2
created -8.8 14.9603 3
created -8.32 24.9339 5
created -7.84 9.97356 2
created -7.36 34.9074 7
created -6.88 39.8942 8
created -6.4 34.9074 7
created -5.92 39.8942 8
created -5.44 49.8678 10
created -4.96 39.8942 8
created -4.48 49.8678 10
created -4 14.9603 3
created -3.52 49.8678 10
created -3.04 29.9207 6
created -2.56 4.98678 1
created -2.08 24.9339 5
created -1.6 29.9207 6
created -1.12 49.8678 10
created -0.64 4.98678 1
created -0.16 9.97356 2
created 0.32 49.8678 10
created 0.8 44.881 9
created 1.28 29.9207 6
created 1.76 49.8678 10
created 2.24 4.98678 1
created 2.72 29.9207 6
created 3.2 49.8678 10
created 3.68 14.9603 3
created 4.16 49.8678 10
created 4.64 9.97356 2
created 5.12 24.9339 5
created 5.6 39.8942 8
created 6.08 4.98678 1
created 6.56 4.98678 1
created 7.04 19.9471 4
created 7.52 9.97356 2
created 8 24.9339 5
created 8.48 9.97356 2
created 8.96 29.9207 6
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.080001 (+-3.1088e-05)
fit chi^2 = 5.6419e-06
found -5.44 (+-0.000261927) 49.8679 (+-0.160707) 10.0002 (+-0.00106423)
found -4.48 (+-0.00026112) 49.8677 (+-0.160647) 10.0001 (+-0.00106384)
found -3.52 (+-0.000260855) 49.8676 (+-0.160627) 10.0001 (+-0.0010637)
found -1.12 (+-0.000260254) 49.8675 (+-0.160587) 10.0001 (+-0.00106343)
found 0.320001 (+-0.000260983) 49.8677 (+-0.160639) 10.0001 (+-0.00106378)
found 1.76 (+-0.000260254) 49.8675 (+-0.160587) 10.0001 (+-0.00106343)
found 3.2 (+-0.000260855) 49.8676 (+-0.160627) 10.0001 (+-0.0010637)
found 4.16 (+-0.000260069) 49.8674 (+-0.160571) 10 (+-0.00106333)
found 9.44 (+-0.000259338) 49.8679 (+-0.160537) 10.0002 (+-0.0010631)
found 0.799999 (+-0.000276273) 44.8812 (+-0.152473) 9.00016 (+-0.0010097)
found -9.76 (+-0.000291364) 39.8938 (+-0.143641) 8.00002 (+-0.000951217)
found -6.88 (+-0.000293044) 39.8944 (+-0.143753) 8.00014 (+-0.000951957)
found -5.92 (+-0.000293476) 39.8946 (+-0.14378) 8.00017 (+-0.000952138)
found -4.96 (+-0.00029391) 39.8947 (+-0.143807) 8.0002 (+-0.000952319)
found 5.6 (+-0.000291126) 39.894 (+-0.143641) 8.00006 (+-0.000951219)
found -7.36 (+-0.000312502) 34.9075 (+-0.13443) 7.0001 (+-0.000890218)
found -6.4 (+-0.000313959) 34.9078 (+-0.134506) 7.00016 (+-0.000890723)
found -3.04 (+-0.000337696) 29.9208 (+-0.124469) 6.00011 (+-0.000824257)
found 1.28 (+-0.000340114) 29.9212 (+-0.124577) 6.00019 (+-0.000824969)
found -1.6 (+-0.000339264) 29.921 (+-0.124536) 6.00015 (+-0.000824702)
found 2.72 (+-0.000337696) 29.9208 (+-0.124469) 6.00011 (+-0.000824257)
found 8.96 (+-0.000338255) 29.9209 (+-0.124492) 6.00012 (+-0.000824408)
found -8.32 (+-0.000369195) 24.9338 (+-0.113591) 5.00005 (+-0.000752219)
found -2.08 (+-0.00036952) 24.9339 (+-0.113606) 5.00007 (+-0.000752321)
found 5.12 (+-0.000370657) 24.9341 (+-0.113649) 5.0001 (+-0.000752602)
found 8 (+-0.000368728) 24.9338 (+-0.113574) 5.00004 (+-0.000752105)
found 7.04 (+-0.000412016) 19.947 (+-0.101577) 4.00003 (+-0.00067266)
found -4 (+-0.000484925) 14.9612 (+-0.0881887) 3.0002 (+-0.000584001)
found 3.68 (+-0.000484925) 14.9612 (+-0.0881887) 3.0002 (+-0.000584001)
found -8.8 (+-0.000479398) 14.9605 (+-0.0880516) 3.00007 (+-0.000583093)
found 4.64 (+-0.000594483) 9.97419 (+-0.0720167) 2.00015 (+-0.000476908)
found -9.28 (+-0.000592017) 9.97399 (+-0.0719747) 2.00011 (+-0.000476629)
found -7.84 (+-0.000593082) 9.97404 (+-0.0719916) 2.00012 (+-0.000476741)
found 7.52 (+-0.000591187) 9.97388 (+-0.0719591) 2.00009 (+-0.000476526)
found 8.48 (+-0.000592525) 9.97399 (+-0.0719819) 2.00011 (+-0.000476677)
found -0.159994 (+-0.000590336) 9.974 (+-0.0719518) 2.00011 (+-0.000476478)
found -0.640011 (+-0.000844225) 4.98733 (+-0.0509581) 1.00012 (+-0.000337453)
found 2.23999 (+-0.000850158) 4.98753 (+-0.0510091) 1.00016 (+-0.000337792)
found 6.07999 (+-0.000839917) 4.98718 (+-0.0509212) 1.00009 (+-0.000337209)
found -2.56 (+-0.000845542) 4.98728 (+-0.050966) 1.00011 (+-0.000337506)
found 6.56 (+-0.000835734) 4.98697 (+-0.050882) 1.00005 (+-0.00033695)
#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()