This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 23.9365 6
created -9.1 11.9683 3
created -8.5 39.8942 10
created -7.9 39.8942 10
created -7.3 39.8942 10
created -6.7 23.9365 6
created -6.1 23.9365 6
created -5.5 35.9048 9
created -4.9 19.9471 5
created -4.3 19.9471 5
created -3.7 27.926 7
created -3.1 3.98942 1
created -2.5 39.8942 10
created -1.9 11.9683 3
created -1.3 7.97885 2
created -0.7 35.9048 9
created -0.1 31.9154 8
created 0.5 15.9577 4
created 1.1 3.98942 1
created 1.7 35.9048 9
created 2.3 27.926 7
created 2.9 7.97885 2
created 3.5 27.926 7
created 4.1 35.9048 9
created 4.7 27.926 7
created 5.3 31.9154 8
created 5.9 31.9154 8
created 6.5 27.926 7
created 7.1 3.98942 1
created 7.7 11.9683 3
created 8.3 39.8942 10
created 8.9 15.9577 4
created 9.5 35.9048 9
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.38615e-05)
fit chi^2 = 6.24528e-06
found -8.5 (+-0.000346693) 39.8941 (+-0.136404) 10.0002 (+-0.0011194)
found -7.9 (+-0.00034807) 39.8945 (+-0.13647) 10.0003 (+-0.00111994)
found -7.3 (+-0.00034741) 39.8943 (+-0.136438) 10.0002 (+-0.00111967)
found -2.5 (+-0.000344541) 39.8937 (+-0.136305) 10 (+-0.00111858)
found 8.3 (+-0.000345604) 39.8938 (+-0.136351) 10.0001 (+-0.00111897)
found -5.5 (+-0.000365549) 35.9047 (+-0.129407) 9.00014 (+-0.00106198)
found -0.699999 (+-0.000365008) 35.9046 (+-0.129386) 9.00013 (+-0.00106181)
found 1.7 (+-0.000364316) 35.9045 (+-0.129359) 9.0001 (+-0.00106158)
found 4.1 (+-0.000366182) 35.9048 (+-0.129435) 9.00018 (+-0.00106221)
found 9.5 (+-0.000362297) 35.9048 (+-0.129287) 9.00016 (+-0.00106099)
found -0.100001 (+-0.000388373) 31.9154 (+-0.122032) 8.00017 (+-0.00100146)
found 5.3 (+-0.000388947) 31.9156 (+-0.122054) 8.00019 (+-0.00100164)
found 5.9 (+-0.000388947) 31.9156 (+-0.122054) 8.00019 (+-0.00100164)
found 2.3 (+-0.000414765) 27.926 (+-0.114138) 7.00014 (+-0.000936675)
found 4.7 (+-0.0004167) 27.9263 (+-0.114203) 7.00022 (+-0.000937206)
found -3.7 (+-0.000413158) 27.9257 (+-0.114085) 7.00008 (+-0.000936234)
found 3.5 (+-0.000414765) 27.926 (+-0.114138) 7.00014 (+-0.000936675)
found 6.5 (+-0.000413913) 27.9259 (+-0.114111) 7.00012 (+-0.000936454)
found -6.7 (+-0.000450379) 23.9369 (+-0.105741) 6.00021 (+-0.000867761)
found -9.7 (+-0.000447184) 23.9362 (+-0.105637) 6.00004 (+-0.000866908)
found -6.1 (+-0.000450153) 23.9369 (+-0.105734) 6.00019 (+-0.000867703)
found -4.9 (+-0.000493552) 19.9475 (+-0.0965328) 5.00018 (+-0.000792195)
found -4.3 (+-0.00049296) 19.9474 (+-0.0965172) 5.00016 (+-0.000792067)
found 0.499996 (+-0.000549653) 15.9579 (+-0.0863019) 4.00012 (+-0.000708235)
found 8.9 (+-0.000554889) 15.9584 (+-0.0864063) 4.00025 (+-0.000709092)
found -9.1 (+-0.000641411) 11.9689 (+-0.0748416) 3.00021 (+-0.000614187)
found -1.90001 (+-0.000638353) 11.9687 (+-0.0747954) 3.00016 (+-0.000613808)
found 7.70001 (+-0.000636968) 11.9686 (+-0.0747763) 3.00014 (+-0.00061365)
found -1.29999 (+-0.000785951) 7.97932 (+-0.0611135) 2.00016 (+-0.000501527)
found 2.9 (+-0.000788327) 7.97942 (+-0.0611382) 2.00018 (+-0.000501729)
found -3.09999 (+-0.00112908) 3.99023 (+-0.0433145) 1.00022 (+-0.00035546)
found 1.10001 (+-0.00112352) 3.99003 (+-0.0432821) 1.00017 (+-0.000355194)
found 7.09999 (+-0.00111921) 3.98987 (+-0.0432569) 1.00013 (+-0.000354987)
#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()