This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 7.97885 2
created -9.1 35.9048 9
created -8.5 11.9683 3
created -7.9 11.9683 3
created -7.3 11.9683 3
created -6.7 3.98942 1
created -6.1 27.926 7
created -5.5 23.9365 6
created -4.9 3.98942 1
created -4.3 3.98942 1
created -3.7 35.9048 9
created -3.1 27.926 7
created -2.5 19.9471 5
created -1.9 27.926 7
created -1.3 19.9471 5
created -0.7 3.98942 1
created -0.1 11.9683 3
created 0.5 3.98942 1
created 1.1 11.9683 3
created 1.7 27.926 7
created 2.3 39.8942 10
created 2.9 19.9471 5
created 3.5 3.98942 1
created 4.1 3.98942 1
created 4.7 31.9154 8
created 5.3 19.9471 5
created 5.9 31.9154 8
created 6.5 35.9048 9
created 7.1 23.9365 6
created 7.7 39.8942 10
created 8.3 11.9683 3
created 8.9 39.8942 10
created 9.5 3.98942 1
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-1.7803e-05)
fit chi^2 = 8.0465e-07
found 2.3 (+-0.000124458) 39.8941 (+-0.0489616) 10.0002 (+-0.000401803)
found 7.7 (+-0.00012421) 39.8939 (+-0.04895) 10.0001 (+-0.000401708)
found 8.9 (+-0.000123671) 39.8936 (+-0.0489259) 10 (+-0.00040151)
found -9.1 (+-0.000130601) 35.9043 (+-0.0464244) 9.00006 (+-0.000380982)
found -3.7 (+-0.000130769) 35.9045 (+-0.0464325) 9.0001 (+-0.000381048)
found 6.5 (+-0.000131432) 35.9048 (+-0.0464597) 9.00018 (+-0.000381271)
found 4.7 (+-0.000138624) 31.9151 (+-0.0437738) 8.00008 (+-0.000359229)
found 5.9 (+-0.000139507) 31.9155 (+-0.0438068) 8.00018 (+-0.0003595)
found -3.1 (+-0.000149296) 27.9261 (+-0.0409829) 7.00018 (+-0.000336326)
found -6.1 (+-0.000148401) 27.9258 (+-0.0409535) 7.00009 (+-0.000336085)
found -1.9 (+-0.000148945) 27.9259 (+-0.0409706) 7.00013 (+-0.000336225)
found 1.7 (+-0.000149116) 27.9261 (+-0.0409772) 7.00017 (+-0.000336279)
found 7.1 (+-0.000161949) 23.9371 (+-0.0379639) 6.00025 (+-0.000311551)
found -5.5 (+-0.000160539) 23.9365 (+-0.0379229) 6.0001 (+-0.000311214)
found 2.9 (+-0.000176374) 19.9473 (+-0.034632) 5.00014 (+-0.000284207)
found -2.5 (+-0.000177203) 19.9474 (+-0.0346509) 5.00018 (+-0.000284362)
found -1.3 (+-0.000176071) 19.9471 (+-0.0346239) 5.0001 (+-0.000284141)
found 5.3 (+-0.000177426) 19.9476 (+-0.0346566) 5.00021 (+-0.00028441)
found -8.5 (+-0.000229345) 11.9687 (+-0.0268501) 3.00016 (+-0.000220345)
found 8.3 (+-0.000230901) 11.9691 (+-0.0268749) 3.00026 (+-0.000220549)
found -7.9 (+-0.000228104) 11.9683 (+-0.0268303) 3.00008 (+-0.000220182)
found -7.3 (+-0.000227266) 11.9682 (+-0.0268182) 3.00005 (+-0.000220084)
found -0.1 (+-0.000226436) 11.9681 (+-0.0268062) 3.00003 (+-0.000219985)
found 1.1 (+-0.00022817) 11.9685 (+-0.0268326) 3.0001 (+-0.000220202)
found -9.69999 (+-0.000280931) 7.97916 (+-0.021923) 2.00012 (+-0.000179911)
found 9.49998 (+-0.000396644) 3.98992 (+-0.0155063) 1.00014 (+-0.000127253)
found -4.90001 (+-0.000399053) 3.98971 (+-0.0155125) 1.00009 (+-0.000127303)
found -6.69999 (+-0.000401735) 3.98987 (+-0.0155268) 1.00013 (+-0.000127421)
found -0.700004 (+-0.000400742) 3.98976 (+-0.0155209) 1.0001 (+-0.000127372)
found 3.49999 (+-0.000398536) 3.98966 (+-0.0155094) 1.00008 (+-0.000127278)
found -4.29998 (+-0.000400312) 3.98987 (+-0.0155203) 1.00013 (+-0.000127367)
found 0.5 (+-0.000399421) 3.98966 (+-0.0155134) 1.00008 (+-0.000127311)
found 4.10002 (+-0.00039993) 3.98982 (+-0.0155179) 1.00012 (+-0.000127348)
#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()