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 15.9577 4
created -8.5 3.98942 1
created -7.9 15.9577 4
created -7.3 19.9471 5
created -6.7 39.8942 10
created -6.1 27.926 7
created -5.5 31.9154 8
created -4.9 3.98942 1
created -4.3 23.9365 6
created -3.7 19.9471 5
created -3.1 7.97885 2
created -2.5 23.9365 6
created -1.9 11.9683 3
created -1.3 7.97885 2
created -0.7 19.9471 5
created -0.1 15.9577 4
created 0.5 31.9154 8
created 1.1 23.9365 6
created 1.7 35.9048 9
created 2.3 31.9154 8
created 2.9 3.98942 1
created 3.5 31.9154 8
created 4.1 7.97885 2
created 4.7 39.8942 10
created 5.3 7.97885 2
created 5.9 31.9154 8
created 6.5 39.8942 10
created 7.1 39.8942 10
created 7.7 23.9365 6
created 8.3 27.926 7
created 8.9 23.9365 6
created 9.5 27.926 7
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.06838e-05)
fit chi^2 = 4.87672e-06
found -6.7 (+-0.000306395) 39.8941 (+-0.120536) 10.0002 (+-0.000989177)
found 4.7 (+-0.00030457) 39.8937 (+-0.120452) 10 (+-0.000988487)
found 6.5 (+-0.000307309) 39.8944 (+-0.120581) 10.0002 (+-0.000989543)
found 7.1 (+-0.000306994) 39.8943 (+-0.120565) 10.0002 (+-0.000989417)
found 1.7 (+-0.000323566) 35.9048 (+-0.114376) 9.00018 (+-0.000938629)
found 2.3 (+-0.000342029) 31.9153 (+-0.107795) 8.00013 (+-0.000884616)
found -5.5 (+-0.000341684) 31.9152 (+-0.107781) 8.0001 (+-0.000884501)
found 0.500001 (+-0.000342646) 31.9153 (+-0.107814) 8.00013 (+-0.000884774)
found 3.5 (+-0.000340373) 31.9149 (+-0.107731) 8.00004 (+-0.00088409)
found 5.9 (+-0.000342686) 31.9154 (+-0.107818) 8.00016 (+-0.000884809)
found -6.1 (+-0.000368399) 27.9264 (+-0.100924) 7.00023 (+-0.000828229)
found 8.3 (+-0.000367177) 27.9261 (+-0.10088) 7.00016 (+-0.000827874)
found 9.5 (+-0.000363817) 27.9261 (+-0.100783) 7.00016 (+-0.000827076)
found 7.7 (+-0.000398242) 23.937 (+-0.0934474) 6.00022 (+-0.000766875)
found -9.7 (+-0.000395539) 23.9363 (+-0.0933586) 6.00005 (+-0.000766146)
found -4.3 (+-0.00039469) 23.9364 (+-0.0933441) 6.00008 (+-0.000766027)
found -2.5 (+-0.000394642) 23.9363 (+-0.0933409) 6.00006 (+-0.000766001)
found 1.1 (+-0.000398276) 23.937 (+-0.0934482) 6.00022 (+-0.000766882)
found 8.9 (+-0.000397592) 23.9368 (+-0.0934272) 6.00018 (+-0.000766709)
found -7.3 (+-0.000435985) 19.9475 (+-0.0852995) 5.00018 (+-0.000700009)
found -3.7 (+-0.000433933) 19.9471 (+-0.085248) 5.0001 (+-0.000699587)
found -0.699999 (+-0.000433227) 19.947 (+-0.0852301) 5.00008 (+-0.00069944)
found -9.1 (+-0.000485028) 15.9577 (+-0.0762474) 4.00009 (+-0.000625723)
found -0.0999984 (+-0.000488338) 15.9581 (+-0.0763119) 4.00017 (+-0.000626253)
found -7.9 (+-0.000484631) 15.9577 (+-0.076239) 4.00008 (+-0.000625655)
found -1.9 (+-0.000562479) 11.9685 (+-0.0660672) 3.0001 (+-0.00054218)
found 4.1 (+-0.000698867) 7.97963 (+-0.0540513) 2.00023 (+-0.000443571)
found 5.3 (+-0.000698867) 7.97963 (+-0.0540513) 2.00023 (+-0.000443571)
found -3.1 (+-0.000694574) 7.97926 (+-0.054003) 2.00014 (+-0.000443175)
found -1.3 (+-0.000692019) 7.97911 (+-0.0539756) 2.0001 (+-0.00044295)
found -4.9 (+-0.000994689) 3.99008 (+-0.0382572) 1.00018 (+-0.000313957)
found 2.9 (+-0.000996927) 3.99018 (+-0.0382705) 1.00021 (+-0.000314066)
found -8.5 (+-0.000986853) 3.98976 (+-0.0382114) 1.0001 (+-0.000313582)
#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()