This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 24.9339 5
created -9.28 4.98678 1
created -8.8 9.97356 2
created -8.32 49.8678 10
created -7.84 4.98678 1
created -7.36 39.8942 8
created -6.88 19.9471 4
created -6.4 34.9074 7
created -5.92 39.8942 8
created -5.44 29.9207 6
created -4.96 34.9074 7
created -4.48 14.9603 3
created -4 14.9603 3
created -3.52 24.9339 5
created -3.04 29.9207 6
created -2.56 14.9603 3
created -2.08 34.9074 7
created -1.6 39.8942 8
created -1.12 14.9603 3
created -0.64 9.97356 2
created -0.16 14.9603 3
created 0.32 34.9074 7
created 0.8 29.9207 6
created 1.28 24.9339 5
created 1.76 9.97356 2
created 2.24 24.9339 5
created 2.72 49.8678 10
created 3.2 34.9074 7
created 3.68 39.8942 8
created 4.16 4.98678 1
created 4.64 39.8942 8
created 5.12 29.9207 6
created 5.6 34.9074 7
created 6.08 39.8942 8
created 6.56 14.9603 3
created 7.04 39.8942 8
created 7.52 29.9207 6
created 8 44.881 9
created 8.48 34.9074 7
created 8.96 44.881 9
created 9.44 14.9603 3
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-1.75066e-05)
fit chi^2 = 1.74332e-06
found -8.32 (+-0.000144235) 49.8672 (+-0.0892346) 10 (+-0.000590928)
found 2.72 (+-0.000145292) 49.8677 (+-0.0893095) 10.0001 (+-0.000591424)
found 8 (+-0.000153357) 44.8811 (+-0.0847403) 9.00013 (+-0.000561166)
found 8.96 (+-0.000153028) 44.8809 (+-0.0847187) 9.0001 (+-0.000561022)
found -7.36 (+-0.000161712) 39.8939 (+-0.0798394) 8.00005 (+-0.000528711)
found -5.92 (+-0.000162801) 39.8943 (+-0.0799026) 8.00013 (+-0.00052913)
found -1.6 (+-0.000162436) 39.8942 (+-0.079881) 8.0001 (+-0.000528987)
found 3.68 (+-0.000162026) 39.8941 (+-0.0798587) 8.00008 (+-0.000528839)
found 4.64 (+-0.000161933) 39.894 (+-0.0798528) 8.00007 (+-0.0005288)
found 6.08 (+-0.000162436) 39.8942 (+-0.079881) 8.0001 (+-0.000528987)
found 7.04 (+-0.000162342) 39.8941 (+-0.0798752) 8.00009 (+-0.000528948)
found -6.4 (+-0.000174065) 34.9076 (+-0.0747437) 7.00012 (+-0.000494967)
found -4.96 (+-0.000173705) 34.9074 (+-0.0747245) 7.00009 (+-0.000494839)
found -2.08 (+-0.000173907) 34.9075 (+-0.0747356) 7.00011 (+-0.000494913)
found 0.320001 (+-0.000173705) 34.9074 (+-0.0747245) 7.00009 (+-0.000494839)
found 3.2 (+-0.000174695) 34.9079 (+-0.074778) 7.00018 (+-0.000495194)
found 5.6 (+-0.000174318) 34.9077 (+-0.0747572) 7.00014 (+-0.000495055)
found 8.48 (+-0.000174701) 34.9079 (+-0.0747783) 7.00018 (+-0.000495196)
found -5.44 (+-0.000188649) 29.921 (+-0.0692289) 6.00015 (+-0.000458447)
found 0.8 (+-0.000188281) 29.9209 (+-0.0692115) 6.00012 (+-0.000458331)
found 5.12 (+-0.000188649) 29.921 (+-0.0692289) 6.00015 (+-0.000458447)
found 7.52 (+-0.000188862) 29.9211 (+-0.0692392) 6.00017 (+-0.000458515)
found -3.04 (+-0.000187692) 29.9207 (+-0.0691844) 6.00008 (+-0.000458152)
found 1.28 (+-0.00020577) 24.934 (+-0.0631634) 5.00008 (+-0.000418279)
found -9.76 (+-0.000204762) 24.9336 (+-0.0631204) 5.00001 (+-0.000417995)
found -3.52 (+-0.000206033) 24.934 (+-0.063173) 5.00009 (+-0.000418343)
found 2.24 (+-0.000206266) 24.9342 (+-0.0631839) 5.00012 (+-0.000418415)
found -6.88 (+-0.000231936) 19.9476 (+-0.0565542) 4.00015 (+-0.000374512)
found 9.44 (+-0.000265095) 14.9607 (+-0.0489255) 3.00012 (+-0.000323993)
found -4.48 (+-0.000267358) 14.9606 (+-0.0489666) 3.0001 (+-0.000324266)
found -4 (+-0.000266896) 14.9605 (+-0.048955) 3.00008 (+-0.000324189)
found -2.56 (+-0.000268219) 14.9608 (+-0.0489874) 3.00013 (+-0.000324404)
found -1.12 (+-0.000267142) 14.9606 (+-0.0489623) 3.0001 (+-0.000324237)
found 6.56 (+-0.000268842) 14.9609 (+-0.0490032) 3.00016 (+-0.000324508)
found -0.159998 (+-0.000266945) 14.9606 (+-0.0489572) 3.00009 (+-0.000324203)
found -0.64 (+-0.000327297) 9.97373 (+-0.0399782) 2.00006 (+-0.000264743)
found 1.76 (+-0.000329022) 9.97393 (+-0.0400069) 2.0001 (+-0.000264933)
found -8.79999 (+-0.000328153) 9.97399 (+-0.0399961) 2.00011 (+-0.000264862)
found -7.84 (+-0.000473651) 4.98763 (+-0.0283645) 1.00018 (+-0.000187835)
found 4.16 (+-0.000472759) 4.98753 (+-0.028356) 1.00016 (+-0.000187779)
found -9.28 (+-0.000466769) 4.98707 (+-0.0283023) 1.00007 (+-0.000187423)
#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()