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 23.9365 6
created -8.5 27.926 7
created -7.9 31.9154 8
created -7.3 3.98942 1
created -6.7 3.98942 1
created -6.1 27.926 7
created -5.5 11.9683 3
created -4.9 35.9048 9
created -4.3 35.9048 9
created -3.7 23.9365 6
created -3.1 15.9577 4
created -2.5 7.97885 2
created -1.9 35.9048 9
created -1.3 7.97885 2
created -0.7 19.9471 5
created -0.1 23.9365 6
created 0.5 27.926 7
created 1.1 11.9683 3
created 1.7 19.9471 5
created 2.3 7.97885 2
created 2.9 3.98942 1
created 3.5 3.98942 1
created 4.1 15.9577 4
created 4.7 23.9365 6
created 5.3 15.9577 4
created 5.9 15.9577 4
created 6.5 11.9683 3
created 7.1 35.9048 9
created 7.7 7.97885 2
created 8.3 19.9471 5
created 8.9 15.9577 4
created 9.5 11.9683 3
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.98173e-05)
fit chi^2 = 2.1294e-06
found -4.9 (+-0.000213451) 35.9047 (+-0.0755642) 9.00015 (+-0.000620117)
found -4.3 (+-0.00021391) 35.9049 (+-0.0755835) 9.00019 (+-0.000620276)
found -1.9 (+-0.000212244) 35.9043 (+-0.0755131) 9.00005 (+-0.000619697)
found 7.1 (+-0.000212458) 35.9044 (+-0.0755217) 9.00006 (+-0.000619768)
found -7.9 (+-0.000225782) 31.9152 (+-0.0712206) 8.0001 (+-0.000584471)
found -8.5 (+-0.00024291) 27.9261 (+-0.0666709) 7.00018 (+-0.000547134)
found -6.1 (+-0.000240851) 27.9256 (+-0.0666027) 7.00005 (+-0.000546574)
found 0.499999 (+-0.000242057) 27.9259 (+-0.0666417) 7.00012 (+-0.000546895)
found -3.7 (+-0.000262448) 23.9367 (+-0.061728) 6.00017 (+-0.00050657)
found -9.1 (+-0.000262153) 23.9366 (+-0.0617188) 6.00014 (+-0.000506495)
found -0.0999993 (+-0.000262368) 23.9367 (+-0.0617251) 6.00015 (+-0.000506547)
found 4.7 (+-0.000261584) 23.9365 (+-0.0617018) 6.0001 (+-0.000506355)
found -0.699998 (+-0.000286739) 19.9471 (+-0.0563312) 5.0001 (+-0.000462281)
found 1.7 (+-0.000285981) 19.947 (+-0.0563122) 5.00006 (+-0.000462126)
found 8.3 (+-0.000286273) 19.947 (+-0.0563194) 5.00008 (+-0.000462184)
found -3.1 (+-0.000321123) 15.9578 (+-0.0503948) 4.0001 (+-0.000413565)
found 5.3 (+-0.000321927) 15.9579 (+-0.0504104) 4.00013 (+-0.000413693)
found 8.9 (+-0.000321303) 15.9578 (+-0.0503978) 4.0001 (+-0.000413589)
found -9.7 (+-0.000321166) 15.9577 (+-0.0503915) 4.00008 (+-0.000413537)
found 4.1 (+-0.000320503) 15.9577 (+-0.0503836) 4.00009 (+-0.000413473)
found 5.9 (+-0.000321) 15.9577 (+-0.0503917) 4.00009 (+-0.000413539)
found -5.5 (+-0.000374603) 11.9689 (+-0.0437024) 3.00021 (+-0.000358643)
found 1.1 (+-0.000373415) 11.9687 (+-0.0436831) 3.00016 (+-0.000358485)
found 6.5 (+-0.000373555) 11.9687 (+-0.0436859) 3.00017 (+-0.000358508)
found 9.5 (+-0.000367891) 11.9684 (+-0.0436081) 3.00009 (+-0.00035787)
found -2.49999 (+-0.000459592) 7.97937 (+-0.0356922) 2.00017 (+-0.000292908)
found -1.3 (+-0.00046015) 7.97942 (+-0.0356981) 2.00018 (+-0.000292957)
found 7.7 (+-0.00046015) 7.97942 (+-0.0356981) 2.00018 (+-0.000292957)
found 2.3 (+-0.000455317) 7.979 (+-0.0356473) 2.00008 (+-0.000292539)
found -7.30002 (+-0.000650593) 3.98982 (+-0.025244) 1.00012 (+-0.000207165)
found -6.69999 (+-0.000649915) 3.98977 (+-0.0252398) 1.00011 (+-0.00020713)
found 2.9 (+-0.000644766) 3.9895 (+-0.0252101) 1.00004 (+-0.000206886)
found 3.50001 (+-0.000647359) 3.98961 (+-0.0252246) 1.00007 (+-0.000207005)
#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()