This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 11.9683 3
created -9.1 7.97885 2
created -8.5 27.926 7
created -7.9 19.9471 5
created -7.3 7.97885 2
created -6.7 31.9154 8
created -6.1 31.9154 8
created -5.5 19.9471 5
created -4.9 19.9471 5
created -4.3 23.9365 6
created -3.7 11.9683 3
created -3.1 3.98942 1
created -2.5 27.926 7
created -1.9 11.9683 3
created -1.3 39.8942 10
created -0.7 19.9471 5
created -0.1 7.97885 2
created 0.5 19.9471 5
created 1.1 3.98942 1
created 1.7 11.9683 3
created 2.3 35.9048 9
created 2.9 39.8942 10
created 3.5 11.9683 3
created 4.1 11.9683 3
created 4.7 39.8942 10
created 5.3 3.98942 1
created 5.9 11.9683 3
created 6.5 35.9048 9
created 7.1 35.9048 9
created 7.7 3.98942 1
created 8.3 35.9048 9
created 8.9 35.9048 9
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.60727e-05)
fit chi^2 = 3.52907e-06
found -1.3 (+-0.000259971) 39.8939 (+-0.102506) 10.0001 (+-0.000841213)
found 2.9 (+-0.000260506) 39.8941 (+-0.102532) 10.0002 (+-0.000841428)
found 4.7 (+-0.000258997) 39.8937 (+-0.102463) 10 (+-0.000840858)
found 2.3 (+-0.000274909) 35.9048 (+-0.0972842) 9.00017 (+-0.000798362)
found 6.5 (+-0.000274789) 35.9047 (+-0.0972787) 9.00015 (+-0.000798317)
found 7.1 (+-0.000274127) 35.9046 (+-0.097253) 9.00013 (+-0.000798106)
found 8.3 (+-0.000274127) 35.9046 (+-0.097253) 9.00013 (+-0.000798106)
found 8.9 (+-0.000275209) 35.9048 (+-0.0972963) 9.00018 (+-0.000798461)
found -6.7 (+-0.000291243) 31.9153 (+-0.0917076) 8.00013 (+-0.000752598)
found -6.1 (+-0.000292019) 31.9154 (+-0.0917362) 8.00017 (+-0.000752832)
found -8.5 (+-0.000311057) 27.9258 (+-0.0857739) 7.00009 (+-0.000703903)
found -2.5 (+-0.000310063) 27.9256 (+-0.085742) 7.00005 (+-0.000703641)
found -4.3 (+-0.000336706) 23.9365 (+-0.0794316) 6.0001 (+-0.000651854)
found -0.700003 (+-0.000370027) 19.9474 (+-0.0725423) 5.00016 (+-0.000595318)
found 9.5 (+-0.000367369) 19.9474 (+-0.0724897) 5.00018 (+-0.000594886)
found -7.9 (+-0.00036939) 19.9472 (+-0.0725253) 5.00012 (+-0.000595178)
found -5.5 (+-0.000370798) 19.9474 (+-0.0725596) 5.00017 (+-0.00059546)
found -4.9 (+-0.000370312) 19.9473 (+-0.072547) 5.00014 (+-0.000595356)
found 0.5 (+-0.000367052) 19.9469 (+-0.0724689) 5.00004 (+-0.000594715)
found -3.7 (+-0.000477457) 11.9684 (+-0.0561877) 3.00009 (+-0.000461104)
found -1.9 (+-0.000482558) 11.9689 (+-0.0562661) 3.00022 (+-0.000461747)
found 3.5 (+-0.000480607) 11.9687 (+-0.0562358) 3.00017 (+-0.000461498)
found -9.7 (+-0.000475851) 11.9681 (+-0.0561572) 3.00003 (+-0.000460853)
found 1.70001 (+-0.000478519) 11.9686 (+-0.0562054) 3.00013 (+-0.000461249)
found 4.1 (+-0.000480607) 11.9687 (+-0.0562358) 3.00017 (+-0.000461498)
found 5.90001 (+-0.000478519) 11.9686 (+-0.0562054) 3.00013 (+-0.000461249)
found -7.3 (+-0.000591919) 7.97937 (+-0.0459512) 2.00017 (+-0.000377098)
found -9.1 (+-0.000589854) 7.97921 (+-0.045929) 2.00013 (+-0.000376916)
found -0.1 (+-0.000590238) 7.97921 (+-0.0459325) 2.00013 (+-0.000376944)
found 5.29998 (+-0.000843779) 3.99003 (+-0.0325321) 1.00017 (+-0.000266974)
found 7.7 (+-0.000849725) 3.99028 (+-0.032566) 1.00023 (+-0.000267253)
found -3.09999 (+-0.00084133) 3.98987 (+-0.0325169) 1.00013 (+-0.00026685)
found 1.1 (+-0.00083925) 3.98976 (+-0.0325046) 1.0001 (+-0.000266748)
#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()