This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 39.8942 10
created -9.1 27.926 7
created -8.5 31.9154 8
created -7.9 39.8942 10
created -7.3 7.97885 2
created -6.7 11.9683 3
created -6.1 15.9577 4
created -5.5 15.9577 4
created -4.9 7.97885 2
created -4.3 27.926 7
created -3.7 11.9683 3
created -3.1 23.9365 6
created -2.5 35.9048 9
created -1.9 3.98942 1
created -1.3 31.9154 8
created -0.7 3.98942 1
created -0.1 19.9471 5
created 0.5 19.9471 5
created 1.1 3.98942 1
created 1.7 35.9048 9
created 2.3 35.9048 9
created 2.9 7.97885 2
created 3.5 23.9365 6
created 4.1 39.8942 10
created 4.7 19.9471 5
created 5.3 3.98942 1
created 5.9 15.9577 4
created 6.5 23.9365 6
created 7.1 35.9048 9
created 7.7 3.98942 1
created 8.3 7.97885 2
created 8.9 35.9048 9
created 9.5 7.97885 2
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.36707e-05)
fit chi^2 = 1.50791e-06
found -9.7 (+-0.000170398) 39.8938 (+-0.0670212) 10.0001 (+-0.000550008)
found -7.9 (+-0.000170043) 39.894 (+-0.0670109) 10.0001 (+-0.000549924)
found 4.1 (+-0.000170284) 39.894 (+-0.0670212) 10.0001 (+-0.000550009)
found -2.5 (+-0.000178917) 35.9045 (+-0.0635591) 9.00009 (+-0.000521597)
found 1.7 (+-0.000179188) 35.9046 (+-0.0635713) 9.00013 (+-0.000521697)
found 2.3 (+-0.000179439) 35.9047 (+-0.0635808) 9.00014 (+-0.000521775)
found 7.1 (+-0.000178917) 35.9045 (+-0.0635591) 9.00009 (+-0.000521597)
found 8.9 (+-0.000178605) 35.9043 (+-0.0635451) 9.00005 (+-0.000521482)
found -8.5 (+-0.000191299) 31.9157 (+-0.0599816) 8.00022 (+-0.000492238)
found -1.3 (+-0.000188995) 31.9149 (+-0.0598956) 8.00002 (+-0.000491532)
found -9.1 (+-0.000204853) 27.9264 (+-0.0561199) 7.00023 (+-0.000460548)
found -4.3 (+-0.00020299) 27.9257 (+-0.0560564) 7.00006 (+-0.000460026)
found -3.1 (+-0.00022064) 23.9367 (+-0.0519387) 6.00016 (+-0.000426235)
found 3.5 (+-0.000220487) 23.9367 (+-0.051935) 6.00016 (+-0.000426204)
found 6.5 (+-0.000220853) 23.9367 (+-0.0519448) 6.00017 (+-0.000426284)
found 4.7 (+-0.000241446) 19.9473 (+-0.0474092) 5.00014 (+-0.000389063)
found -0.0999984 (+-0.000240685) 19.947 (+-0.0473891) 5.00008 (+-0.000388898)
found 0.499998 (+-0.000240685) 19.947 (+-0.0473891) 5.00008 (+-0.000388898)
found -6.1 (+-0.000270125) 15.9577 (+-0.0424051) 4.00009 (+-0.000347997)
found -5.5 (+-0.000269752) 15.9577 (+-0.042398) 4.00008 (+-0.000347938)
found 5.9 (+-0.000269706) 15.9578 (+-0.0423983) 4.00009 (+-0.000347942)
found -3.7 (+-0.000314522) 11.9687 (+-0.0367644) 3.00017 (+-0.000301707)
found -6.7 (+-0.000312165) 11.9684 (+-0.0367279) 3.00008 (+-0.000301407)
found -7.30001 (+-0.000386474) 7.97937 (+-0.0300328) 2.00017 (+-0.000246464)
found 2.9 (+-0.000387632) 7.97947 (+-0.0300448) 2.0002 (+-0.000246563)
found 9.5 (+-0.000381678) 7.97926 (+-0.0299913) 2.00014 (+-0.000246123)
found -4.9 (+-0.000386122) 7.97926 (+-0.0300281) 2.00014 (+-0.000246426)
found 8.30001 (+-0.000384526) 7.97922 (+-0.0300133) 2.00013 (+-0.000246304)
found -1.9 (+-0.000554896) 3.99023 (+-0.0212841) 1.00022 (+-0.000174668)
found -0.700007 (+-0.000552376) 3.99002 (+-0.0212692) 1.00017 (+-0.000174545)
found 7.69998 (+-0.000549797) 3.98992 (+-0.0212554) 1.00014 (+-0.000174432)
found 1.10001 (+-0.000552912) 3.99008 (+-0.0212724) 1.00018 (+-0.000174572)
found 5.3 (+-0.000549583) 3.98982 (+-0.0212527) 1.00012 (+-0.00017441)
#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()