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 7.97885 2
created -8.5 23.9365 6
created -7.9 39.8942 10
created -7.3 19.9471 5
created -6.7 11.9683 3
created -6.1 31.9154 8
created -5.5 23.9365 6
created -4.9 31.9154 8
created -4.3 39.8942 10
created -3.7 31.9154 8
created -3.1 11.9683 3
created -2.5 35.9048 9
created -1.9 31.9154 8
created -1.3 39.8942 10
created -0.7 15.9577 4
created -0.1 11.9683 3
created 0.5 23.9365 6
created 1.1 31.9154 8
created 1.7 31.9154 8
created 2.3 7.97885 2
created 2.9 15.9577 4
created 3.5 19.9471 5
created 4.1 31.9154 8
created 4.7 15.9577 4
created 5.3 27.926 7
created 5.9 23.9365 6
created 6.5 7.97885 2
created 7.1 15.9577 4
created 7.7 3.98942 1
created 8.3 7.97885 2
created 8.9 7.97885 2
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.47378e-05)
fit chi^2 = 3.47809e-06
found -7.9 (+-0.000258617) 39.894 (+-0.101787) 10.0001 (+-0.000835317)
found -4.3 (+-0.0002593) 39.8943 (+-0.101821) 10.0002 (+-0.000835589)
found -1.3 (+-0.000258706) 39.8941 (+-0.101792) 10.0002 (+-0.000835356)
found -2.5 (+-0.00027267) 35.9047 (+-0.0965677) 9.00014 (+-0.000792482)
found -3.7 (+-0.000289711) 31.9154 (+-0.0910649) 8.00017 (+-0.000747323)
found -1.9 (+-0.000290829) 31.9157 (+-0.0911081) 8.00024 (+-0.000747677)
found -6.1 (+-0.00028912) 31.9152 (+-0.091041) 8.00012 (+-0.000747127)
found -4.9 (+-0.000290363) 31.9156 (+-0.0910895) 8.00021 (+-0.000747525)
found 1.1 (+-0.00029009) 31.9155 (+-0.0910784) 8.00018 (+-0.000747434)
found 1.7 (+-0.000289132) 31.9153 (+-0.0910427) 8.00013 (+-0.000747141)
found 4.1 (+-0.000289182) 31.9152 (+-0.091043) 8.00012 (+-0.000747143)
found 5.3 (+-0.000309636) 27.9259 (+-0.0851795) 7.00013 (+-0.000699024)
found -9.7 (+-0.000333325) 23.9362 (+-0.0788223) 6.00003 (+-0.000646855)
found -8.5 (+-0.000334862) 23.9367 (+-0.0788755) 6.00016 (+-0.000647291)
found -5.5 (+-0.000336167) 23.9369 (+-0.0789125) 6.00021 (+-0.000647595)
found 0.500002 (+-0.000334914) 23.9366 (+-0.0788755) 6.00014 (+-0.000647291)
found 5.9 (+-0.000334321) 23.9365 (+-0.0788584) 6.00012 (+-0.000647151)
found -7.3 (+-0.000367815) 19.9474 (+-0.0720273) 5.00017 (+-0.000591092)
found 3.5 (+-0.000367787) 19.9474 (+-0.0720256) 5.00015 (+-0.000591077)
found 9.5 (+-0.000362629) 19.9471 (+-0.071911) 5.00009 (+-0.000590137)
found -0.700004 (+-0.000412046) 15.9581 (+-0.0644402) 4.00017 (+-0.000528828)
found 4.7 (+-0.000413059) 15.9582 (+-0.0644599) 4.00019 (+-0.000528989)
found 2.9 (+-0.000410067) 15.9578 (+-0.0643991) 4.00009 (+-0.000528491)
found 7.1 (+-0.000407884) 15.9575 (+-0.064357) 4.00004 (+-0.000528145)
found -6.7 (+-0.000477591) 11.9687 (+-0.0558343) 3.00017 (+-0.000458203)
found -3.1 (+-0.000479113) 11.9689 (+-0.0558589) 3.00022 (+-0.000458405)
found -0.0999986 (+-0.000476345) 11.9686 (+-0.0558143) 3.00013 (+-0.00045804)
found 2.3 (+-0.000586916) 7.97932 (+-0.0456105) 2.00016 (+-0.000374302)
found -9.1 (+-0.000587195) 7.97932 (+-0.045613) 2.00016 (+-0.000374323)
found 6.5 (+-0.000585868) 7.97921 (+-0.0455986) 2.00013 (+-0.000374205)
found 8.3 (+-0.000579378) 7.97885 (+-0.0455315) 2.00004 (+-0.000373654)
found 8.9 (+-0.000583375) 7.97906 (+-0.0455725) 2.00009 (+-0.00037399)
found 7.7 (+-0.000830024) 3.98966 (+-0.0322515) 1.00008 (+-0.000264671)
#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()