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 11.9683 3
created -8.5 11.9683 3
created -7.9 39.8942 10
created -7.3 7.97885 2
created -6.7 35.9048 9
created -6.1 19.9471 5
created -5.5 35.9048 9
created -4.9 7.97885 2
created -4.3 7.97885 2
created -3.7 23.9365 6
created -3.1 27.926 7
created -2.5 35.9048 9
created -1.9 11.9683 3
created -1.3 39.8942 10
created -0.7 31.9154 8
created -0.1 3.98942 1
created 0.5 19.9471 5
created 1.1 3.98942 1
created 1.7 39.8942 10
created 2.3 11.9683 3
created 2.9 23.9365 6
created 3.5 35.9048 9
created 4.1 11.9683 3
created 4.7 31.9154 8
created 5.3 15.9577 4
created 5.9 19.9471 5
created 6.5 35.9048 9
created 7.1 31.9154 8
created 7.7 39.8942 10
created 8.3 27.926 7
created 8.9 35.9048 9
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.07568e-05)
fit chi^2 = 2.8501e-06
found -7.9 (+-0.000233062) 39.8937 (+-0.092093) 10.0001 (+-0.000755761)
found -1.3 (+-0.000234004) 39.894 (+-0.0921371) 10.0001 (+-0.000756122)
found 1.7 (+-0.000232753) 39.8936 (+-0.0920799) 10 (+-0.000755653)
found 7.7 (+-0.000234612) 39.8942 (+-0.0921655) 10.0002 (+-0.000756356)
found -6.7 (+-0.000246168) 35.9045 (+-0.0873879) 9.00009 (+-0.000717148)
found -5.5 (+-0.000246168) 35.9045 (+-0.0873879) 9.00009 (+-0.000717148)
found -2.5 (+-0.000246705) 35.9046 (+-0.0874106) 9.00013 (+-0.000717334)
found 3.5 (+-0.000246569) 35.9046 (+-0.0874045) 9.00011 (+-0.000717284)
found 6.5 (+-0.000247207) 35.9048 (+-0.0874319) 9.00017 (+-0.000717509)
found 8.9 (+-0.000246908) 35.9047 (+-0.0874189) 9.00014 (+-0.000717403)
found -0.700002 (+-0.000261592) 31.9153 (+-0.0824117) 8.00014 (+-0.000676311)
found 7.1 (+-0.000263268) 31.9157 (+-0.0824739) 8.00025 (+-0.000676822)
found 4.7 (+-0.000261361) 31.9151 (+-0.0823993) 8.00009 (+-0.000676209)
found 8.3 (+-0.000281778) 27.9264 (+-0.0771592) 7.00025 (+-0.000633207)
found -3.1 (+-0.00028117) 27.9262 (+-0.0771377) 7.00019 (+-0.00063303)
found -3.7 (+-0.000302638) 23.9365 (+-0.0713852) 6.00012 (+-0.000585822)
found 2.9 (+-0.000303338) 23.9367 (+-0.0714057) 6.00016 (+-0.000585991)
found -6.1 (+-0.000334307) 19.9477 (+-0.065235) 5.00023 (+-0.000535351)
found 0.5 (+-0.000329282) 19.9468 (+-0.0651125) 5.00003 (+-0.000534345)
found 5.9 (+-0.000333124) 19.9474 (+-0.0652049) 5.00017 (+-0.000535104)
found 5.3 (+-0.000373324) 15.9581 (+-0.0583389) 4.00017 (+-0.000478758)
found 9.5 (+-0.000369529) 15.958 (+-0.058276) 4.00017 (+-0.000478242)
found -1.9 (+-0.000434284) 11.969 (+-0.0505748) 3.00025 (+-0.000415041)
found 2.3 (+-0.000433301) 11.9689 (+-0.0505588) 3.00021 (+-0.00041491)
found 4.1 (+-0.000433708) 11.9689 (+-0.0505652) 3.00022 (+-0.000414963)
found -9.1 (+-0.000427721) 11.9682 (+-0.0504727) 3.00005 (+-0.000414204)
found -8.5 (+-0.000431907) 11.9687 (+-0.0505373) 3.00017 (+-0.000414734)
found -7.3 (+-0.000534691) 7.97968 (+-0.0413259) 2.00025 (+-0.000339141)
found -4.90001 (+-0.000529991) 7.97926 (+-0.0412753) 2.00014 (+-0.000338725)
found -4.3 (+-0.000528641) 7.97911 (+-0.0412598) 2.0001 (+-0.000338598)
found -0.100007 (+-0.000759411) 3.99002 (+-0.029241) 1.00017 (+-0.000239966)
found 1.10001 (+-0.000760829) 3.99013 (+-0.0292497) 1.0002 (+-0.000240038)
found -9.69999 (+-0.00074583) 3.9895 (+-0.0291641) 1.00004 (+-0.000239335)
#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()