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 39.8942 10
created -8.5 19.9471 5
created -7.9 31.9154 8
created -7.3 15.9577 4
created -6.7 27.926 7
created -6.1 23.9365 6
created -5.5 11.9683 3
created -4.9 35.9048 9
created -4.3 11.9683 3
created -3.7 3.98942 1
created -3.1 31.9154 8
created -2.5 19.9471 5
created -1.9 27.926 7
created -1.3 39.8942 10
created -0.7 23.9365 6
created -0.1 19.9471 5
created 0.5 23.9365 6
created 1.1 19.9471 5
created 1.7 7.97885 2
created 2.3 39.8942 10
created 2.9 7.97885 2
created 3.5 3.98942 1
created 4.1 27.926 7
created 4.7 31.9154 8
created 5.3 27.926 7
created 5.9 39.8942 10
created 6.5 23.9365 6
created 7.1 23.9365 6
created 7.7 19.9471 5
created 8.3 15.9577 4
created 8.9 23.9365 6
created 9.5 3.98942 1
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-1.62435e-05)
fit chi^2 = 7.8543e-07
found -9.1 (+-0.000122897) 39.894 (+-0.0483701) 10.0001 (+-0.000396949)
found -1.3 (+-0.000123035) 39.8941 (+-0.0483768) 10.0002 (+-0.000397004)
found 2.3 (+-0.00012223) 39.8936 (+-0.0483396) 10 (+-0.000396699)
found 5.9 (+-0.000123035) 39.8941 (+-0.0483768) 10.0002 (+-0.000397004)
found -4.9 (+-0.000129162) 35.9044 (+-0.0458719) 9.00007 (+-0.000376447)
found -7.9 (+-0.000137422) 31.9152 (+-0.0432643) 8.00012 (+-0.000355048)
found -3.1 (+-0.000136958) 31.9151 (+-0.0432478) 8.00008 (+-0.000354913)
found 4.7 (+-0.00013786) 31.9155 (+-0.0432814) 8.00018 (+-0.000355188)
found -6.7 (+-0.000147142) 27.9259 (+-0.0404779) 7.00013 (+-0.000332182)
found -1.9 (+-0.000147572) 27.9262 (+-0.0404931) 7.00019 (+-0.000332306)
found 4.1 (+-0.000146787) 27.9259 (+-0.0404675) 7.00012 (+-0.000332096)
found 5.3 (+-0.000147845) 27.9263 (+-0.0405026) 7.00023 (+-0.000332384)
found -0.700002 (+-0.000159604) 23.9368 (+-0.0374956) 6.00019 (+-0.000307708)
found 6.5 (+-0.000159719) 23.9369 (+-0.0374991) 6.00021 (+-0.000307736)
found -9.7 (+-0.00015934) 23.9366 (+-0.037485) 6.00013 (+-0.00030762)
found -6.1 (+-0.000159061) 23.9366 (+-0.0374794) 6.00013 (+-0.000307574)
found 0.5 (+-0.000159127) 23.9366 (+-0.037481) 6.00013 (+-0.000307587)
found 7.1 (+-0.000159242) 23.9366 (+-0.0374844) 6.00014 (+-0.000307616)
found 8.9 (+-0.000158269) 23.9363 (+-0.0374569) 6.00006 (+-0.00030739)
found -8.5 (+-0.000175489) 19.9477 (+-0.0342454) 5.00023 (+-0.000281035)
found -2.5 (+-0.000175184) 19.9475 (+-0.0342374) 5.00019 (+-0.000280969)
found -0.1 (+-0.000174833) 19.9473 (+-0.0342283) 5.00016 (+-0.000280895)
found 1.1 (+-0.000174145) 19.9471 (+-0.0342116) 5.0001 (+-0.000280757)
found 7.7 (+-0.000174547) 19.9472 (+-0.0342212) 5.00013 (+-0.000280836)
found -7.3 (+-0.000196289) 15.9582 (+-0.0306318) 4.00019 (+-0.00025138)
found 8.3 (+-0.000195702) 15.9579 (+-0.0306195) 4.00014 (+-0.000251279)
found -5.5 (+-0.00022732) 11.9688 (+-0.0265388) 3.00019 (+-0.00021779)
found -4.30001 (+-0.000225747) 11.9686 (+-0.0265156) 3.00013 (+-0.0002176)
found 1.70001 (+-0.000279666) 7.97947 (+-0.0216829) 2.0002 (+-0.000177941)
found 2.89999 (+-0.000277716) 7.97927 (+-0.0216634) 2.00014 (+-0.00017778)
found 9.49999 (+-0.000390332) 3.98971 (+-0.0153101) 1.00009 (+-0.000125643)
found -3.69999 (+-0.000397326) 3.98992 (+-0.0153428) 1.00014 (+-0.000125911)
found 3.50001 (+-0.000396001) 3.98982 (+-0.0153354) 1.00012 (+-0.00012585)
#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()