This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 3.98942 1
created -9.1 31.9154 8
created -8.5 11.9683 3
created -7.9 31.9154 8
created -7.3 35.9048 9
created -6.7 11.9683 3
created -6.1 11.9683 3
created -5.5 23.9365 6
created -4.9 11.9683 3
created -4.3 35.9048 9
created -3.7 31.9154 8
created -3.1 15.9577 4
created -2.5 31.9154 8
created -1.9 23.9365 6
created -1.3 15.9577 4
created -0.7 11.9683 3
created -0.1 27.926 7
created 0.5 27.926 7
created 1.1 27.926 7
created 1.7 3.98942 1
created 2.3 27.926 7
created 2.9 7.97885 2
created 3.5 27.926 7
created 4.1 19.9471 5
created 4.7 11.9683 3
created 5.3 19.9471 5
created 5.9 23.9365 6
created 6.5 23.9365 6
created 7.1 27.926 7
created 7.7 35.9048 9
created 8.3 19.9471 5
created 8.9 35.9048 9
created 9.5 31.9154 8
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.33153e-05)
fit chi^2 = 5.53415e-06
found -7.3 (+-0.000343948) 35.9047 (+-0.121811) 9.00014 (+-0.000999642)
found -4.3 (+-0.000343948) 35.9047 (+-0.121811) 9.00014 (+-0.000999642)
found 7.7 (+-0.000344299) 35.9047 (+-0.121825) 9.00015 (+-0.000999758)
found 8.9 (+-0.000344473) 35.9048 (+-0.121833) 9.00017 (+-0.000999822)
found -3.7 (+-0.000365593) 31.9154 (+-0.114875) 8.00017 (+-0.000942718)
found 9.5 (+-0.000362924) 31.9156 (+-0.114791) 8.00022 (+-0.000942028)
found -9.1 (+-0.000362972) 31.915 (+-0.114777) 8.00005 (+-0.000941913)
found -7.9 (+-0.000365278) 31.9154 (+-0.114863) 8.00015 (+-0.000942623)
found -2.5 (+-0.000365012) 31.9153 (+-0.114851) 8.00013 (+-0.000942527)
found -0.0999988 (+-0.000390461) 27.9259 (+-0.107443) 7.00013 (+-0.000881727)
found 0.5 (+-0.000391621) 27.9261 (+-0.107482) 7.00018 (+-0.000882049)
found 1.1 (+-0.000389421) 27.9258 (+-0.107411) 7.0001 (+-0.000881464)
found 2.3 (+-0.00038785) 27.9256 (+-0.107357) 7.00004 (+-0.000881028)
found 3.5 (+-0.000389525) 27.9258 (+-0.107411) 7.00009 (+-0.00088147)
found 7.1 (+-0.0003918) 27.9262 (+-0.107489) 7.00019 (+-0.000882103)
found -5.5 (+-0.0004209) 23.9364 (+-0.0994474) 6.00008 (+-0.000816114)
found -1.9 (+-0.000422869) 23.9367 (+-0.0995057) 6.00015 (+-0.000816592)
found 5.9 (+-0.000422696) 23.9366 (+-0.0994999) 6.00014 (+-0.000816545)
found 6.5 (+-0.000423272) 23.9368 (+-0.0995172) 6.00017 (+-0.000816687)
found 8.3 (+-0.000465843) 19.9477 (+-0.0909026) 5.00023 (+-0.000745991)
found 4.1 (+-0.000463163) 19.9472 (+-0.0908345) 5.00013 (+-0.000745432)
found 5.3 (+-0.000462847) 19.9472 (+-0.0908263) 5.00012 (+-0.000745365)
found -3.1 (+-0.000521389) 15.9582 (+-0.0813177) 4.00021 (+-0.000667332)
found -1.3 (+-0.000518406) 15.9579 (+-0.0812561) 4.00012 (+-0.000666828)
found -8.5 (+-0.000603941) 11.9689 (+-0.0704539) 3.00021 (+-0.000578179)
found -6.7 (+-0.000601465) 11.9687 (+-0.0704155) 3.00016 (+-0.000577864)
found -4.9 (+-0.000603406) 11.9688 (+-0.0704454) 3.00019 (+-0.000578109)
found 4.7 (+-0.000600944) 11.9686 (+-0.0704056) 3.00013 (+-0.000577783)
found -6.1 (+-0.00060012) 11.9685 (+-0.0703933) 3.00012 (+-0.000577682)
found -0.699998 (+-0.000601356) 11.9686 (+-0.0704125) 3.00014 (+-0.00057784)
found 2.9 (+-0.000742089) 7.97942 (+-0.0575521) 2.00018 (+-0.000472301)
found 1.7 (+-0.00105974) 3.99007 (+-0.040755) 1.00018 (+-0.000334455)
found -9.69998 (+-0.0010463) 3.98977 (+-0.040681) 1.00011 (+-0.000333848)
#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()