This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 24.9339 5
created -9.28 44.881 9
created -8.8 39.8942 8
created -8.32 19.9471 4
created -7.84 24.9339 5
created -7.36 29.9207 6
created -6.88 34.9074 7
created -6.4 39.8942 8
created -5.92 34.9074 7
created -5.44 39.8942 8
created -4.96 34.9074 7
created -4.48 49.8678 10
created -4 39.8942 8
created -3.52 39.8942 8
created -3.04 14.9603 3
created -2.56 44.881 9
created -2.08 14.9603 3
created -1.6 9.97356 2
created -1.12 14.9603 3
created -0.64 4.98678 1
created -0.16 19.9471 4
created 0.32 44.881 9
created 0.8 9.97356 2
created 1.28 14.9603 3
created 1.76 49.8678 10
created 2.24 14.9603 3
created 2.72 44.881 9
created 3.2 19.9471 4
created 3.68 9.97356 2
created 4.16 19.9471 4
created 4.64 19.9471 4
created 5.12 44.881 9
created 5.6 19.9471 4
created 6.08 24.9339 5
created 6.56 29.9207 6
created 7.04 9.97356 2
created 7.52 34.9074 7
created 8 24.9339 5
created 8.48 39.8942 8
created 8.96 39.8942 8
created 9.44 34.9074 7
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.58301e-05)
fit chi^2 = 3.9456e-06
found -4.48 (+-0.000218934) 49.8679 (+-0.134385) 10.0002 (+-0.000889924)
found 1.76 (+-0.000217697) 49.8674 (+-0.134294) 10.0001 (+-0.00088932)
found -9.28 (+-0.000230686) 44.8811 (+-0.127483) 9.00013 (+-0.000844217)
found -2.56 (+-0.000229601) 44.8807 (+-0.127411) 9.00006 (+-0.000843737)
found 0.32 (+-0.000229556) 44.8807 (+-0.127408) 9.00006 (+-0.000843721)
found 2.72 (+-0.000229788) 44.8808 (+-0.127423) 9.00007 (+-0.000843818)
found 5.12 (+-0.000229977) 44.8808 (+-0.127435) 9.00008 (+-0.000843899)
found -8.8 (+-0.00024483) 39.8944 (+-0.120202) 8.00013 (+-0.000796)
found -6.4 (+-0.000245062) 39.8944 (+-0.120216) 8.00014 (+-0.000796089)
found -5.44 (+-0.000245062) 39.8944 (+-0.120216) 8.00014 (+-0.000796089)
found -4 (+-0.000245554) 39.8946 (+-0.120246) 8.00018 (+-0.000796294)
found -3.52 (+-0.0002445) 39.8943 (+-0.120182) 8.00011 (+-0.000795869)
found 8.48 (+-0.000244891) 39.8944 (+-0.120205) 8.00013 (+-0.000796021)
found 8.96 (+-0.000245192) 39.8945 (+-0.120224) 8.00015 (+-0.000796143)
found -6.88 (+-0.000262246) 34.9077 (+-0.112466) 7.00014 (+-0.000744769)
found -5.92 (+-0.000262553) 34.9078 (+-0.112483) 7.00016 (+-0.00074488)
found -4.96 (+-0.000262813) 34.9079 (+-0.112497) 7.00018 (+-0.000744977)
found 7.52 (+-0.000260856) 34.9073 (+-0.112393) 7.00007 (+-0.000744284)
found 9.44 (+-0.00025984) 34.9077 (+-0.112357) 7.00015 (+-0.000744052)
found -7.36 (+-0.000283253) 29.9209 (+-0.104123) 6.00012 (+-0.000689521)
found 6.56 (+-0.000282031) 29.9206 (+-0.104068) 6.00007 (+-0.000689154)
found 8 (+-0.000311411) 24.9343 (+-0.0950955) 5.00015 (+-0.00062974)
found -9.76 (+-0.000310383) 24.934 (+-0.0950486) 5.00009 (+-0.000629429)
found -7.84 (+-0.000310278) 24.9341 (+-0.0950505) 5.0001 (+-0.000629441)
found 6.08 (+-0.000310278) 24.9341 (+-0.0950505) 5.0001 (+-0.000629441)
found -8.32 (+-0.000348377) 19.9475 (+-0.0850632) 4.00013 (+-0.000563304)
found 3.2 (+-0.000347388) 19.9474 (+-0.0850337) 4.00011 (+-0.000563109)
found 5.6 (+-0.000348594) 19.9476 (+-0.0850705) 4.00014 (+-0.000563352)
found -0.159997 (+-0.000346715) 19.9474 (+-0.0850148) 4.0001 (+-0.000562983)
found 4.16 (+-0.000346074) 19.9472 (+-0.0849904) 4.00006 (+-0.000562822)
found 4.64 (+-0.000348263) 19.9475 (+-0.08506) 4.00013 (+-0.000563283)
found -2.08 (+-0.000402166) 14.9607 (+-0.0736668) 3.00011 (+-0.000487835)
found 2.24 (+-0.000405267) 14.9611 (+-0.0737424) 3.00019 (+-0.000488335)
found -3.04 (+-0.000404729) 14.961 (+-0.0737284) 3.00017 (+-0.000488243)
found -1.12 (+-0.000398529) 14.9603 (+-0.0735794) 3.00003 (+-0.000487256)
found 1.28 (+-0.00040242) 14.9608 (+-0.0736736) 3.00012 (+-0.00048788)
found 0.799996 (+-0.000495469) 9.97404 (+-0.0601969) 2.00012 (+-0.000398635)
found -1.6 (+-0.000492391) 9.97373 (+-0.0601438) 2.00006 (+-0.000398283)
found 3.68 (+-0.000493794) 9.97383 (+-0.0601669) 2.00008 (+-0.000398436)
found 7.04 (+-0.000496499) 9.97409 (+-0.060213) 2.00013 (+-0.000398741)
found -0.639999 (+-0.000702756) 4.98707 (+-0.0425823) 1.00007 (+-0.000281988)
#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()