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 31.9154 8
created -8.5 3.98942 1
created -7.9 23.9365 6
created -7.3 3.98942 1
created -6.7 7.97885 2
created -6.1 31.9154 8
created -5.5 15.9577 4
created -4.9 23.9365 6
created -4.3 35.9048 9
created -3.7 15.9577 4
created -3.1 11.9683 3
created -2.5 31.9154 8
created -1.9 3.98942 1
created -1.3 23.9365 6
created -0.7 27.926 7
created -0.1 35.9048 9
created 0.5 23.9365 6
created 1.1 35.9048 9
created 1.7 23.9365 6
created 2.3 39.8942 10
created 2.9 7.97885 2
created 3.5 15.9577 4
created 4.1 7.97885 2
created 4.7 39.8942 10
created 5.3 19.9471 5
created 5.9 11.9683 3
created 6.5 3.98942 1
created 7.1 3.98942 1
created 7.7 23.9365 6
created 8.3 3.98942 1
created 8.9 3.98942 1
created 9.5 35.9048 9
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.95839e-05)
fit chi^2 = 6.24477e-06
found 2.3 (+-0.000345691) 39.8939 (+-0.136352) 10.0001 (+-0.00111897)
found 4.7 (+-0.000345487) 39.8938 (+-0.136342) 10.0001 (+-0.00111889)
found -4.3 (+-0.000365277) 35.9046 (+-0.129391) 9.00013 (+-0.00106185)
found -0.1 (+-0.000365963) 35.9048 (+-0.129421) 9.00017 (+-0.00106209)
found 1.1 (+-0.00036576) 35.9048 (+-0.129412) 9.00015 (+-0.00106202)
found 9.50001 (+-0.000361134) 35.9046 (+-0.129235) 9.00012 (+-0.00106056)
found -9.1 (+-0.000385168) 31.9149 (+-0.121908) 8.00004 (+-0.00100044)
found -6.1 (+-0.000386465) 31.9151 (+-0.121955) 8.00008 (+-0.00100082)
found -2.5 (+-0.000385573) 31.915 (+-0.121923) 8.00005 (+-0.00100056)
found -0.699999 (+-0.000416196) 27.9262 (+-0.114181) 7.00019 (+-0.000937028)
found 0.5 (+-0.000450935) 23.937 (+-0.105754) 6.00023 (+-0.000867869)
found 1.7 (+-0.000451162) 23.9371 (+-0.105761) 6.00025 (+-0.000867927)
found -7.9 (+-0.000444601) 23.9362 (+-0.105572) 6.00002 (+-0.000866372)
found -4.9 (+-0.000449441) 23.9368 (+-0.105709) 6.00017 (+-0.0008675)
found -1.3 (+-0.000447235) 23.9365 (+-0.105647) 6.0001 (+-0.00086699)
found 7.7 (+-0.000444601) 23.9362 (+-0.105572) 6.00002 (+-0.000866372)
found 5.3 (+-0.000492853) 19.9474 (+-0.096513) 5.00017 (+-0.000792032)
found -5.5 (+-0.000553065) 15.9581 (+-0.0863644) 4.00018 (+-0.000708748)
found -3.7 (+-0.000551804) 15.958 (+-0.0863396) 4.00016 (+-0.000708545)
found 3.5 (+-0.000547592) 15.9576 (+-0.0862544) 4.00005 (+-0.000707845)
found 5.9 (+-0.000634554) 11.9684 (+-0.0747335) 3.00008 (+-0.0006133)
found -3.1 (+-0.000639275) 11.9687 (+-0.0748047) 3.00016 (+-0.000613883)
found 2.89999 (+-0.000787618) 7.97942 (+-0.0611294) 2.00018 (+-0.000501658)
found 4.10001 (+-0.000787618) 7.97942 (+-0.0611294) 2.00018 (+-0.000501658)
found -9.69999 (+-0.000782024) 7.97912 (+-0.0610668) 2.00011 (+-0.000501144)
found -6.69999 (+-0.000781919) 7.97917 (+-0.0610709) 2.00012 (+-0.000501177)
found -8.5 (+-0.00112559) 3.99008 (+-0.043292) 1.00018 (+-0.000355275)
found -1.9 (+-0.00112559) 3.99008 (+-0.043292) 1.00018 (+-0.000355275)
found -7.30001 (+-0.00111531) 3.98977 (+-0.0432337) 1.0001 (+-0.000354796)
found 8.29999 (+-0.00111169) 3.98972 (+-0.0432153) 1.00009 (+-0.000354646)
found 6.5 (+-0.00110663) 3.98956 (+-0.0431858) 1.00005 (+-0.000354403)
found 7.10001 (+-0.0011117) 3.98971 (+-0.0432153) 1.00009 (+-0.000354646)
found 8.90002 (+-0.0011152) 3.98988 (+-0.043237) 1.00013 (+-0.000354824)
#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()