This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 15.9577 4
created -9.1 7.97885 2
created -8.5 39.8942 10
created -7.9 3.98942 1
created -7.3 27.926 7
created -6.7 11.9683 3
created -6.1 39.8942 10
created -5.5 3.98942 1
created -4.9 3.98942 1
created -4.3 35.9048 9
created -3.7 35.9048 9
created -3.1 19.9471 5
created -2.5 11.9683 3
created -1.9 23.9365 6
created -1.3 39.8942 10
created -0.7 35.9048 9
created -0.1 39.8942 10
created 0.5 39.8942 10
created 1.1 23.9365 6
created 1.7 31.9154 8
created 2.3 19.9471 5
created 2.9 35.9048 9
created 3.5 7.97885 2
created 4.1 7.97885 2
created 4.7 19.9471 5
created 5.3 23.9365 6
created 5.9 31.9154 8
created 6.5 39.8942 10
created 7.1 23.9365 6
created 7.7 7.97885 2
created 8.3 23.9365 6
created 8.9 3.98942 1
created 9.5 23.9365 6
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.7328e-05)
fit chi^2 = 4.2175e-06
found -8.5 (+-0.000282862) 39.8936 (+-0.111999) 10 (+-0.000919122)
found -6.1 (+-0.000283134) 39.8937 (+-0.112012) 10 (+-0.000919221)
found -1.3 (+-0.000285372) 39.8942 (+-0.112115) 10.0002 (+-0.000920068)
found -0.0999998 (+-0.000285914) 39.8944 (+-0.112141) 10.0002 (+-0.000920286)
found 0.499999 (+-0.000285492) 39.8943 (+-0.112121) 10.0002 (+-0.000920117)
found 6.5 (+-0.000285244) 39.8942 (+-0.112108) 10.0002 (+-0.000920015)
found -4.3 (+-0.000299674) 35.9046 (+-0.106316) 9.00013 (+-0.000872485)
found -3.7 (+-0.000300857) 35.9048 (+-0.106364) 9.00018 (+-0.000872873)
found -0.7 (+-0.00030177) 35.9052 (+-0.106404) 9.00026 (+-0.000873205)
found 2.9 (+-0.000299453) 35.9045 (+-0.106304) 9.00009 (+-0.000872381)
found 1.7 (+-0.00031888) 31.9153 (+-0.100271) 8.00014 (+-0.000822876)
found 5.9 (+-0.000319741) 31.9156 (+-0.100306) 8.00021 (+-0.000823158)
found -7.3 (+-0.000338959) 27.9256 (+-0.0937326) 7.00005 (+-0.000769216)
found 1.1 (+-0.000370567) 23.937 (+-0.0869089) 6.00023 (+-0.000713217)
found 7.1 (+-0.000368742) 23.9367 (+-0.0868559) 6.00016 (+-0.000712782)
found -1.9 (+-0.000369183) 23.9368 (+-0.0868681) 6.00017 (+-0.000712882)
found 5.3 (+-0.000369457) 23.9368 (+-0.0868749) 6.00017 (+-0.000712938)
found 8.3 (+-0.000365971) 23.9362 (+-0.0867752) 6.00004 (+-0.00071212)
found 9.50001 (+-0.000363756) 23.9364 (+-0.0867238) 6.00009 (+-0.000711698)
found -3.1 (+-0.000404814) 19.9474 (+-0.0793091) 5.00016 (+-0.000650849)
found 2.3 (+-0.000406435) 19.9476 (+-0.0793496) 5.00022 (+-0.000651182)
found 4.7 (+-0.00040354) 19.9471 (+-0.0792771) 5.0001 (+-0.000650587)
found -9.7 (+-0.000450074) 15.9575 (+-0.0708796) 4.00003 (+-0.000581673)
found -6.7 (+-0.000527529) 11.9689 (+-0.0615097) 3.00022 (+-0.000504779)
found -2.5 (+-0.000525091) 11.9686 (+-0.0614701) 3.00014 (+-0.000504453)
found -9.09999 (+-0.000647269) 7.97942 (+-0.0502365) 2.00018 (+-0.000412265)
found 3.49999 (+-0.000644712) 7.97927 (+-0.0502097) 2.00014 (+-0.000412046)
found 7.7 (+-0.000646606) 7.97932 (+-0.050228) 2.00016 (+-0.000412196)
found 4.1 (+-0.0006424) 7.97906 (+-0.0501834) 2.00009 (+-0.00041183)
found -7.90001 (+-0.000927849) 3.99023 (+-0.0355947) 1.00022 (+-0.000292107)
found -5.50002 (+-0.000917285) 3.98993 (+-0.0355375) 1.00015 (+-0.000291638)
found 8.9 (+-0.000922951) 3.98997 (+-0.0355652) 1.00016 (+-0.000291866)
found -4.89998 (+-0.000916478) 3.98988 (+-0.0355324) 1.00013 (+-0.000291596)
#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()