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 35.9048 9
created -8.5 15.9577 4
created -7.9 3.98942 1
created -7.3 15.9577 4
created -6.7 35.9048 9
created -6.1 31.9154 8
created -5.5 31.9154 8
created -4.9 31.9154 8
created -4.3 27.926 7
created -3.7 7.97885 2
created -3.1 7.97885 2
created -2.5 3.98942 1
created -1.9 31.9154 8
created -1.3 19.9471 5
created -0.7 31.9154 8
created -0.1 19.9471 5
created 0.5 23.9365 6
created 1.1 19.9471 5
created 1.7 15.9577 4
created 2.3 11.9683 3
created 2.9 23.9365 6
created 3.5 7.97885 2
created 4.1 35.9048 9
created 4.7 3.98942 1
created 5.3 7.97885 2
created 5.9 39.8942 10
created 6.5 3.98942 1
created 7.1 7.97885 2
created 7.7 3.98942 1
created 8.3 15.9577 4
created 8.9 7.97885 2
created 9.5 15.9577 4
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.34116e-05)
fit chi^2 = 2.8278e-06
found -9.7 (+-0.000233565) 39.8939 (+-0.0917909) 10.0001 (+-0.000753281)
found 5.9 (+-0.000231617) 39.8936 (+-0.0917091) 10 (+-0.00075261)
found -9.1 (+-0.000246286) 35.9048 (+-0.087092) 9.00018 (+-0.000714719)
found -6.7 (+-0.000246065) 35.9047 (+-0.0870819) 9.00015 (+-0.000714637)
found 4.1 (+-0.000244247) 35.9043 (+-0.0870068) 9.00003 (+-0.00071402)
found -6.1 (+-0.000261988) 31.9157 (+-0.0821406) 8.00022 (+-0.000674086)
found -5.5 (+-0.00026186) 31.9156 (+-0.0821355) 8.00021 (+-0.000674044)
found -4.9 (+-0.000261721) 31.9156 (+-0.0821299) 8.00019 (+-0.000673998)
found -1.9 (+-0.000259871) 31.9151 (+-0.0820607) 8.00008 (+-0.00067343)
found -0.7 (+-0.000260942) 31.9153 (+-0.0820993) 8.00013 (+-0.000673747)
found -4.3 (+-0.000278952) 27.9259 (+-0.0767982) 7.00013 (+-0.000630243)
found 0.5 (+-0.000301937) 23.9366 (+-0.0711184) 6.00013 (+-0.000583632)
found 2.9 (+-0.000300514) 23.9363 (+-0.0710775) 6.00006 (+-0.000583297)
found -1.3 (+-0.000332612) 19.9476 (+-0.0649692) 5.00021 (+-0.000533169)
found -0.100001 (+-0.000332174) 19.9475 (+-0.0649579) 5.00018 (+-0.000533077)
found 1.1 (+-0.000331194) 19.9473 (+-0.064933) 5.00013 (+-0.000532872)
found -8.5 (+-0.000370087) 15.9579 (+-0.0580772) 4.00013 (+-0.00047661)
found 1.7 (+-0.000370263) 15.9578 (+-0.0580775) 4.0001 (+-0.000476612)
found -7.3 (+-0.000370087) 15.9579 (+-0.0580772) 4.00013 (+-0.00047661)
found 8.3 (+-0.000367783) 15.9575 (+-0.0580297) 4.00004 (+-0.00047622)
found 9.5 (+-0.000365813) 15.9577 (+-0.0580002) 4.00008 (+-0.000475978)
found 2.3 (+-0.000429512) 11.9686 (+-0.0503269) 3.00013 (+-0.000413007)
found -3.70001 (+-0.00052706) 7.97916 (+-0.0411037) 2.00012 (+-0.000337317)
found 3.5 (+-0.000530831) 7.97947 (+-0.041144) 2.00019 (+-0.000337648)
found 5.30001 (+-0.000526953) 7.97927 (+-0.0411053) 2.00014 (+-0.00033733)
found 8.9 (+-0.000527079) 7.97911 (+-0.0411026) 2.0001 (+-0.000337308)
found -3.1 (+-0.000522415) 7.97886 (+-0.041055) 2.00004 (+-0.000336918)
found 7.1 (+-0.00052112) 7.9788 (+-0.0410424) 2.00003 (+-0.000336814)
found 6.49998 (+-0.00075357) 3.98998 (+-0.0291118) 1.00016 (+-0.000238905)
found 4.69998 (+-0.000752903) 3.98992 (+-0.0291076) 1.00014 (+-0.000238871)
found -7.9 (+-0.000751472) 3.98977 (+-0.0290974) 1.0001 (+-0.000238787)
found -2.49999 (+-0.000752181) 3.98987 (+-0.0291031) 1.00013 (+-0.000238834)
found 7.7 (+-0.000748419) 3.98966 (+-0.0290806) 1.00008 (+-0.00023865)
#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()