This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 7.97885 2
created -9.1 19.9471 5
created -8.5 3.98942 1
created -7.9 7.97885 2
created -7.3 31.9154 8
created -6.7 19.9471 5
created -6.1 15.9577 4
created -5.5 35.9048 9
created -4.9 7.97885 2
created -4.3 15.9577 4
created -3.7 31.9154 8
created -3.1 39.8942 10
created -2.5 31.9154 8
created -1.9 7.97885 2
created -1.3 7.97885 2
created -0.7 31.9154 8
created -0.1 7.97885 2
created 0.5 11.9683 3
created 1.1 7.97885 2
created 1.7 35.9048 9
created 2.3 27.926 7
created 2.9 7.97885 2
created 3.5 31.9154 8
created 4.1 11.9683 3
created 4.7 3.98942 1
created 5.3 15.9577 4
created 5.9 11.9683 3
created 6.5 35.9048 9
created 7.1 11.9683 3
created 7.7 3.98942 1
created 8.3 39.8942 10
created 8.9 31.9154 8
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.35975e-05)
fit chi^2 = 2.83045e-06
found -3.1 (+-0.000233917) 39.8943 (+-0.091853) 10.0002 (+-0.00075379)
found 8.3 (+-0.000232658) 39.8939 (+-0.091796) 10.0001 (+-0.000753323)
found -5.5 (+-0.000245147) 35.9044 (+-0.0870789) 9.00008 (+-0.000714612)
found 1.7 (+-0.000245604) 35.9046 (+-0.0870988) 9.00011 (+-0.000714776)
found 6.5 (+-0.000245194) 35.9044 (+-0.0870805) 9.00007 (+-0.000714626)
found -2.5 (+-0.000261072) 31.9154 (+-0.0821403) 8.00015 (+-0.000674083)
found 8.9 (+-0.000261576) 31.9155 (+-0.0821586) 8.00018 (+-0.000674234)
found -7.3 (+-0.000260373) 31.9151 (+-0.0821122) 8.00009 (+-0.000673853)
found -3.7 (+-0.000261576) 31.9155 (+-0.0821586) 8.00018 (+-0.000674234)
found -0.7 (+-0.000259687) 31.915 (+-0.0820866) 8.00005 (+-0.000673643)
found 3.5 (+-0.000259961) 31.915 (+-0.0820965) 8.00006 (+-0.000673725)
found 2.3 (+-0.000279225) 27.926 (+-0.0768393) 7.00014 (+-0.000630581)
found -9.1 (+-0.000328719) 19.9469 (+-0.0649007) 5.00004 (+-0.000532607)
found -6.7 (+-0.000331783) 19.9474 (+-0.0649748) 5.00016 (+-0.000533215)
found -6.1 (+-0.000372267) 15.9581 (+-0.0581425) 4.00018 (+-0.000477146)
found 9.5 (+-0.000368029) 15.958 (+-0.0580698) 4.00015 (+-0.00047655)
found -4.3 (+-0.000370751) 15.9579 (+-0.0581124) 4.00013 (+-0.000476899)
found 5.3 (+-0.00036846) 15.9576 (+-0.0580667) 4.00005 (+-0.000476524)
found 4.1 (+-0.000428256) 11.9685 (+-0.0503308) 3.00012 (+-0.000413039)
found 7.09999 (+-0.000428546) 11.9686 (+-0.0503357) 3.00013 (+-0.000413079)
found 0.5 (+-0.000426507) 11.9682 (+-0.0503017) 3.00005 (+-0.0004128)
found 5.9 (+-0.000430679) 11.9687 (+-0.0503664) 3.00017 (+-0.000413331)
found 2.9 (+-0.000531165) 7.97947 (+-0.0411641) 2.0002 (+-0.000337813)
found -4.90001 (+-0.000529873) 7.97937 (+-0.0411503) 2.00017 (+-0.000337699)
found -1.90001 (+-0.000527752) 7.97922 (+-0.041128) 2.00013 (+-0.000337517)
found -0.100005 (+-0.000528701) 7.97926 (+-0.0411376) 2.00014 (+-0.000337595)
found 1.10001 (+-0.000529112) 7.97932 (+-0.0411424) 2.00016 (+-0.000337634)
found -7.89999 (+-0.000526419) 7.97916 (+-0.0411153) 2.00012 (+-0.000337412)
found -1.29999 (+-0.000527752) 7.97921 (+-0.041128) 2.00013 (+-0.000337517)
found -9.69999 (+-0.000525015) 7.97895 (+-0.0410958) 2.00007 (+-0.000337252)
found -8.50001 (+-0.000749895) 3.98971 (+-0.0291008) 1.00009 (+-0.000238815)
found 4.7 (+-0.000750472) 3.98971 (+-0.0291035) 1.00009 (+-0.000238837)
found 7.70002 (+-0.00075566) 3.99003 (+-0.0291346) 1.00017 (+-0.000239093)
#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()