This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 14.9603 3
created -9.28 24.9339 5
created -8.8 9.97356 2
created -8.32 24.9339 5
created -7.84 34.9074 7
created -7.36 39.8942 8
created -6.88 9.97356 2
created -6.4 44.881 9
created -5.92 44.881 9
created -5.44 49.8678 10
created -4.96 49.8678 10
created -4.48 29.9207 6
created -4 14.9603 3
created -3.52 19.9471 4
created -3.04 4.98678 1
created -2.56 14.9603 3
created -2.08 24.9339 5
created -1.6 19.9471 4
created -1.12 24.9339 5
created -0.64 49.8678 10
created -0.16 4.98678 1
created 0.32 29.9207 6
created 0.8 29.9207 6
created 1.28 39.8942 8
created 1.76 44.881 9
created 2.24 24.9339 5
created 2.72 4.98678 1
created 3.2 39.8942 8
created 3.68 34.9074 7
created 4.16 14.9603 3
created 4.64 24.9339 5
created 5.12 9.97356 2
created 5.6 19.9471 4
created 6.08 34.9074 7
created 6.56 39.8942 8
created 7.04 24.9339 5
created 7.52 19.9471 4
created 8 4.98678 1
created 8.48 49.8678 10
created 8.96 44.881 9
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.76595e-05)
fit chi^2 = 1.74335e-06
found -5.44 (+-0.000145793) 49.8681 (+-0.0893484) 10.0002 (+-0.000591681)
found -4.96 (+-0.000145577) 49.8679 (+-0.089332) 10.0002 (+-0.000591573)
found -0.640001 (+-0.000144584) 49.8674 (+-0.0892603) 10.0001 (+-0.000591098)
found 8.48 (+-0.000144881) 49.8676 (+-0.0892831) 10.0001 (+-0.000591249)
found -6.4 (+-0.000153023) 44.881 (+-0.0847202) 9.00011 (+-0.000561032)
found -5.92 (+-0.000153811) 44.8814 (+-0.0847726) 9.00019 (+-0.00056138)
found 1.76 (+-0.000153341) 44.8811 (+-0.0847401) 9.00013 (+-0.000561164)
found 8.96 (+-0.000153245) 44.8811 (+-0.0847346) 9.00013 (+-0.000561128)
found -7.36 (+-0.000162265) 39.8941 (+-0.079872) 8.00009 (+-0.000528927)
found 1.28 (+-0.000162968) 39.8944 (+-0.0799137) 8.00015 (+-0.000529203)
found 3.2 (+-0.000162027) 39.8941 (+-0.0798593) 8.00008 (+-0.000528843)
found 6.56 (+-0.000162697) 39.8943 (+-0.0798969) 8.00012 (+-0.000529092)
found -7.84 (+-0.000174201) 34.9076 (+-0.0747514) 7.00013 (+-0.000495018)
found 3.68 (+-0.000173908) 34.9075 (+-0.0747363) 7.00011 (+-0.000494917)
found 6.08 (+-0.000174066) 34.9076 (+-0.0747444) 7.00012 (+-0.000494971)
found -4.48 (+-0.000188253) 29.9209 (+-0.069212) 6.00013 (+-0.000458334)
found 0.8 (+-0.000188529) 29.921 (+-0.0692238) 6.00014 (+-0.000458412)
found 0.320001 (+-0.000187296) 29.9206 (+-0.069169) 6.00007 (+-0.00045805)
found 2.24 (+-0.000205793) 24.9341 (+-0.0631672) 5.0001 (+-0.000418304)
found 7.04 (+-0.000206517) 24.9342 (+-0.0631925) 5.00012 (+-0.000418472)
found -9.28 (+-0.000205228) 24.9338 (+-0.0631427) 5.00005 (+-0.000418142)
found -8.32 (+-0.000205913) 24.934 (+-0.0631696) 5.00009 (+-0.000418321)
found -2.08 (+-0.000205698) 24.9339 (+-0.0631603) 5.00007 (+-0.000418259)
found -1.12 (+-0.000206746) 24.9343 (+-0.063202) 5.00014 (+-0.000418535)
found 4.64 (+-0.000205228) 24.9338 (+-0.0631427) 5.00005 (+-0.000418142)
found -3.52 (+-0.000229345) 19.947 (+-0.0564739) 4.00004 (+-0.000373981)
found -1.6 (+-0.000231052) 19.9474 (+-0.0565257) 4.0001 (+-0.000374324)
found 5.6 (+-0.000230617) 19.9473 (+-0.0565132) 4.00009 (+-0.000374241)
found 7.52 (+-0.000229813) 19.9472 (+-0.0564888) 4.00006 (+-0.000374079)
found 9.44 (+-0.000265098) 14.9607 (+-0.0489259) 3.00012 (+-0.000323996)
found -4 (+-0.000267474) 14.9606 (+-0.0489694) 3.0001 (+-0.000324284)
found 4.16 (+-0.000267975) 14.9607 (+-0.0489817) 3.00012 (+-0.000324366)
found -9.76 (+-0.000266253) 14.9604 (+-0.0489367) 3.00005 (+-0.000324068)
found -2.56 (+-0.000265912) 14.9604 (+-0.0489334) 3.00006 (+-0.000324046)
found -8.8 (+-0.000329025) 9.97393 (+-0.0400072) 2.0001 (+-0.000264935)
found -6.88 (+-0.000331169) 9.97429 (+-0.0400446) 2.00017 (+-0.000265182)
found 5.12 (+-0.000328628) 9.97388 (+-0.0400005) 2.00009 (+-0.000264891)
found -0.160005 (+-0.000472585) 4.98753 (+-0.0283549) 1.00016 (+-0.000187771)
found 2.72 (+-0.000471072) 4.98738 (+-0.0283407) 1.00013 (+-0.000187677)
found 8.00001 (+-0.00047123) 4.98743 (+-0.0283428) 1.00014 (+-0.000187691)
found -3.04 (+-0.000467133) 4.98707 (+-0.0283051) 1.00007 (+-0.000187442)
#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()