This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 35.9048 9
created -9.1 15.9577 4
created -8.5 23.9365 6
created -7.9 19.9471 5
created -7.3 15.9577 4
created -6.7 31.9154 8
created -6.1 3.98942 1
created -5.5 7.97885 2
created -4.9 23.9365 6
created -4.3 19.9471 5
created -3.7 39.8942 10
created -3.1 23.9365 6
created -2.5 39.8942 10
created -1.9 7.97885 2
created -1.3 27.926 7
created -0.7 31.9154 8
created -0.1 15.9577 4
created 0.5 11.9683 3
created 1.1 27.926 7
created 1.7 23.9365 6
created 2.3 3.98942 1
created 2.9 11.9683 3
created 3.5 39.8942 10
created 4.1 11.9683 3
created 4.7 39.8942 10
created 5.3 19.9471 5
created 5.9 23.9365 6
created 6.5 31.9154 8
created 7.1 3.98942 1
created 7.7 39.8942 10
created 8.3 39.8942 10
created 8.9 23.9365 6
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.50822e-05)
fit chi^2 = 6.24093e-06
found -3.7 (+-0.000346427) 39.894 (+-0.136348) 10.0001 (+-0.00111894)
found -2.5 (+-0.000345585) 39.8939 (+-0.13631) 10.0001 (+-0.00111862)
found 3.5 (+-0.000345213) 39.8938 (+-0.136292) 10.0001 (+-0.00111847)
found 4.7 (+-0.000345716) 39.8939 (+-0.136315) 10.0001 (+-0.00111867)
found 7.7 (+-0.000345771) 39.894 (+-0.136323) 10.0001 (+-0.00111873)
found 8.3 (+-0.000347289) 39.8943 (+-0.13639) 10.0002 (+-0.00111928)
found -9.7 (+-0.000364865) 35.9043 (+-0.129328) 9.00005 (+-0.00106133)
found 9.5 (+-0.000362641) 35.9049 (+-0.129262) 9.00019 (+-0.00106079)
found -6.7 (+-0.000385783) 31.915 (+-0.121898) 8.00006 (+-0.00100036)
found -0.700001 (+-0.000387844) 31.9153 (+-0.121974) 8.00014 (+-0.00100098)
found 6.5 (+-0.00038631) 31.9151 (+-0.121919) 8.00009 (+-0.00100052)
found -1.3 (+-0.00041441) 27.926 (+-0.114091) 7.00013 (+-0.000936286)
found 1.1 (+-0.000414394) 27.9259 (+-0.114089) 7.00012 (+-0.000936268)
found -3.1 (+-0.000451251) 23.9371 (+-0.105736) 6.00026 (+-0.000867719)
found 8.9 (+-0.000451024) 23.9371 (+-0.105729) 6.00025 (+-0.00086766)
found -8.5 (+-0.000448189) 23.9366 (+-0.105642) 6.00012 (+-0.000866953)
found -4.9 (+-0.000447229) 23.9364 (+-0.105615) 6.00009 (+-0.000866732)
found 1.7 (+-0.000447098) 23.9365 (+-0.105615) 6.0001 (+-0.000866724)
found 5.9 (+-0.000449429) 23.9368 (+-0.10568) 6.00017 (+-0.000867259)
found 5.3 (+-0.000494024) 19.9476 (+-0.0965158) 5.00021 (+-0.000792055)
found -7.9 (+-0.00049202) 19.9473 (+-0.0964642) 5.00013 (+-0.000791632)
found -4.3 (+-0.000494024) 19.9476 (+-0.0965158) 5.00021 (+-0.000792055)
found -9.1 (+-0.000553239) 15.9582 (+-0.0863452) 4.00019 (+-0.000708591)
found -7.3 (+-0.000552435) 15.9581 (+-0.0863284) 4.00017 (+-0.000708452)
found -0.100003 (+-0.000551293) 15.958 (+-0.0863056) 4.00014 (+-0.000708266)
found 4.1 (+-0.000643052) 11.9691 (+-0.074846) 3.00026 (+-0.000614223)
found 0.500002 (+-0.000638603) 11.9686 (+-0.0747738) 3.00014 (+-0.000613631)
found 2.90001 (+-0.000636746) 11.9686 (+-0.0747502) 3.00014 (+-0.000613437)
found -1.9 (+-0.000789918) 7.97958 (+-0.0611382) 2.00022 (+-0.00050173)
found -5.49999 (+-0.000780298) 7.97906 (+-0.0610362) 2.00009 (+-0.000500893)
found 7.1 (+-0.0011299) 3.99029 (+-0.0433067) 1.00023 (+-0.000355396)
found -6.10001 (+-0.00111744) 3.98987 (+-0.0432354) 1.00013 (+-0.000354811)
found 2.29999 (+-0.00111752) 3.98982 (+-0.043234) 1.00012 (+-0.000354799)
#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()