This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 31.9154 8
created -9.1 7.97885 2
created -8.5 19.9471 5
created -7.9 7.97885 2
created -7.3 31.9154 8
created -6.7 39.8942 10
created -6.1 39.8942 10
created -5.5 39.8942 10
created -4.9 23.9365 6
created -4.3 23.9365 6
created -3.7 15.9577 4
created -3.1 35.9048 9
created -2.5 15.9577 4
created -1.9 15.9577 4
created -1.3 7.97885 2
created -0.7 15.9577 4
created -0.1 15.9577 4
created 0.5 3.98942 1
created 1.1 27.926 7
created 1.7 39.8942 10
created 2.3 35.9048 9
created 2.9 11.9683 3
created 3.5 3.98942 1
created 4.1 39.8942 10
created 4.7 35.9048 9
created 5.3 11.9683 3
created 5.9 27.926 7
created 6.5 15.9577 4
created 7.1 7.97885 2
created 7.7 11.9683 3
created 8.3 35.9048 9
created 8.9 3.98942 1
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.61541e-05)
fit chi^2 = 6.24051e-06
found -6.7 (+-0.000347633) 39.8944 (+-0.136403) 10.0002 (+-0.00111939)
found -6.1 (+-0.000347936) 39.8945 (+-0.136418) 10.0003 (+-0.00111951)
found -5.5 (+-0.000347277) 39.8943 (+-0.136386) 10.0002 (+-0.00111925)
found 1.7 (+-0.000347317) 39.8943 (+-0.136387) 10.0002 (+-0.00111926)
found 4.1 (+-0.000345616) 39.894 (+-0.136311) 10.0001 (+-0.00111863)
found -3.1 (+-0.000364672) 35.9045 (+-0.129326) 9.0001 (+-0.00106131)
found 2.3 (+-0.000365568) 35.9048 (+-0.129367) 9.00017 (+-0.00106165)
found 4.7 (+-0.000365568) 35.9048 (+-0.129367) 9.00017 (+-0.00106165)
found 8.3 (+-0.000363204) 35.9043 (+-0.129267) 9.00005 (+-0.00106083)
found 9.50001 (+-0.00036101) 35.9046 (+-0.129191) 9.00012 (+-0.0010602)
found -9.7 (+-0.000386384) 31.9149 (+-0.121905) 8.00003 (+-0.00100041)
found -7.3 (+-0.000387652) 31.9154 (+-0.121966) 8.00015 (+-0.00100091)
found 1.1 (+-0.000414159) 27.926 (+-0.114083) 7.00014 (+-0.000936217)
found 5.9 (+-0.000413782) 27.9258 (+-0.114064) 7.00009 (+-0.000936068)
found -4.9 (+-0.000450206) 23.9369 (+-0.1057) 6.00021 (+-0.000867429)
found -4.3 (+-0.000448495) 23.9366 (+-0.105648) 6.00013 (+-0.000867003)
found -8.5 (+-0.000488956) 19.947 (+-0.096387) 5.00005 (+-0.000790998)
found -3.7 (+-0.00055322) 15.9582 (+-0.0863423) 4.00019 (+-0.000708567)
found -2.5 (+-0.000552234) 15.9581 (+-0.0863222) 4.00017 (+-0.000708402)
found 6.5 (+-0.000550139) 15.9579 (+-0.0862802) 4.00012 (+-0.000708057)
found -1.9 (+-0.000548765) 15.9577 (+-0.0862516) 4.00008 (+-0.000707822)
found -0.699999 (+-0.000548765) 15.9577 (+-0.0862516) 4.00008 (+-0.000707822)
found -0.100002 (+-0.00054771) 15.9577 (+-0.0862323) 4.00006 (+-0.000707665)
found 2.89999 (+-0.000636325) 11.9686 (+-0.0747408) 3.00013 (+-0.00061336)
found 5.3 (+-0.000641287) 11.9689 (+-0.0748146) 3.00021 (+-0.000613965)
found 7.7 (+-0.000637708) 11.9686 (+-0.07476) 3.00014 (+-0.000613517)
found -9.1 (+-0.000787122) 7.97937 (+-0.061105) 2.00017 (+-0.000501458)
found -7.9 (+-0.000787122) 7.97937 (+-0.061105) 2.00017 (+-0.000501458)
found -1.3 (+-0.000782999) 7.97911 (+-0.0610597) 2.0001 (+-0.000501086)
found 7.1 (+-0.000781885) 7.97906 (+-0.061048) 2.00009 (+-0.000500989)
found 8.9 (+-0.00112995) 3.99029 (+-0.0433056) 1.00024 (+-0.000355387)
found 0.500007 (+-0.00112082) 3.98992 (+-0.0432516) 1.00014 (+-0.000354944)
found 3.50002 (+-0.00112204) 3.99003 (+-0.0432605) 1.00017 (+-0.000355017)
#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()