This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 31.9154 8
created -9.1 11.9683 3
created -8.5 15.9577 4
created -7.9 7.97885 2
created -7.3 39.8942 10
created -6.7 31.9154 8
created -6.1 11.9683 3
created -5.5 19.9471 5
created -4.9 35.9048 9
created -4.3 7.97885 2
created -3.7 7.97885 2
created -3.1 31.9154 8
created -2.5 35.9048 9
created -1.9 31.9154 8
created -1.3 7.97885 2
created -0.7 27.926 7
created -0.1 35.9048 9
created 0.5 31.9154 8
created 1.1 35.9048 9
created 1.7 7.97885 2
created 2.3 19.9471 5
created 2.9 39.8942 10
created 3.5 35.9048 9
created 4.1 19.9471 5
created 4.7 7.97885 2
created 5.3 3.98942 1
created 5.9 15.9577 4
created 6.5 31.9154 8
created 7.1 15.9577 4
created 7.7 7.97885 2
created 8.3 35.9048 9
created 8.9 11.9683 3
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.32506e-05)
fit chi^2 = 5.53817e-06
found -7.3 (+-0.000325877) 39.894 (+-0.128422) 10.0001 (+-0.0010539)
found 2.9 (+-0.00032682) 39.8942 (+-0.128466) 10.0002 (+-0.00105425)
found -4.9 (+-0.00034315) 35.9045 (+-0.121816) 9.00009 (+-0.000999682)
found -2.5 (+-0.000345179) 35.905 (+-0.121903) 9.00021 (+-0.00100039)
found -0.0999997 (+-0.000345004) 35.9049 (+-0.121895) 9.00019 (+-0.00100033)
found 1.1 (+-0.000343724) 35.9046 (+-0.121841) 9.00013 (+-0.000999891)
found 3.5 (+-0.000344909) 35.9049 (+-0.121892) 9.00019 (+-0.0010003)
found 8.3 (+-0.000342631) 35.9044 (+-0.121794) 9.00006 (+-0.000999502)
found -6.7 (+-0.000365576) 31.9155 (+-0.114912) 8.00017 (+-0.000943021)
found -1.9 (+-0.000365022) 31.9154 (+-0.114891) 8.00014 (+-0.000942851)
found 0.5 (+-0.00036682) 31.9157 (+-0.114959) 8.00023 (+-0.000943412)
found -9.7 (+-0.000364378) 31.9149 (+-0.114855) 8.00004 (+-0.000942552)
found -3.1 (+-0.000365022) 31.9153 (+-0.114891) 8.00014 (+-0.000942851)
found 6.5 (+-0.000364642) 31.9152 (+-0.114874) 8.0001 (+-0.00094271)
found 9.5 (+-0.00036169) 31.9153 (+-0.114778) 8.00014 (+-0.000941925)
found -0.699998 (+-0.000390579) 27.926 (+-0.107483) 7.00014 (+-0.000882056)
found 4.1 (+-0.000463293) 19.9473 (+-0.0908684) 5.00014 (+-0.00074571)
found -5.5 (+-0.000463886) 19.9474 (+-0.0908822) 5.00016 (+-0.000745823)
found 2.3 (+-0.000463539) 19.9474 (+-0.090875) 5.00016 (+-0.000745764)
found 7.1 (+-0.000518605) 15.9579 (+-0.0812876) 4.00013 (+-0.000667085)
found -8.5 (+-0.000516392) 15.9577 (+-0.0812417) 4.00007 (+-0.000666709)
found 5.9 (+-0.000517601) 15.9579 (+-0.0812694) 4.00012 (+-0.000666937)
found -9.1 (+-0.000602022) 11.9687 (+-0.0704455) 3.00016 (+-0.00057811)
found -6.1 (+-0.000602656) 11.9687 (+-0.0704554) 3.00017 (+-0.000578191)
found 8.9 (+-0.000604576) 11.9689 (+-0.0704864) 3.00022 (+-0.000578445)
found -7.89999 (+-0.000741721) 7.97942 (+-0.0575672) 2.00018 (+-0.000472424)
found -4.30001 (+-0.00073879) 7.97927 (+-0.0575365) 2.00014 (+-0.000472173)
found -1.3 (+-0.000742993) 7.97948 (+-0.0575802) 2.0002 (+-0.000472531)
found 1.7 (+-0.000742086) 7.97943 (+-0.0575706) 2.00018 (+-0.000472452)
found 7.70001 (+-0.000741186) 7.97937 (+-0.0575609) 2.00017 (+-0.000472373)
found -3.69999 (+-0.000738218) 7.97922 (+-0.0575298) 2.00013 (+-0.000472118)
found 4.7 (+-0.000734291) 7.97901 (+-0.0574886) 2.00008 (+-0.000471779)
found 5.3 (+-0.00104738) 3.98966 (+-0.040697) 1.00008 (+-0.00033398)
#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()