This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 39.8942 10
created -9.1 3.98942 1
created -8.5 35.9048 9
created -7.9 39.8942 10
created -7.3 15.9577 4
created -6.7 35.9048 9
created -6.1 3.98942 1
created -5.5 7.97885 2
created -4.9 27.926 7
created -4.3 11.9683 3
created -3.7 19.9471 5
created -3.1 23.9365 6
created -2.5 35.9048 9
created -1.9 31.9154 8
created -1.3 3.98942 1
created -0.7 19.9471 5
created -0.1 15.9577 4
created 0.5 3.98942 1
created 1.1 3.98942 1
created 1.7 23.9365 6
created 2.3 15.9577 4
created 2.9 39.8942 10
created 3.5 31.9154 8
created 4.1 3.98942 1
created 4.7 27.926 7
created 5.3 11.9683 3
created 5.9 7.97885 2
created 6.5 39.8942 10
created 7.1 11.9683 3
created 7.7 11.9683 3
created 8.3 39.8942 10
created 8.9 27.926 7
created 9.5 31.9154 8
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.46455e-05)
fit chi^2 = 5.58579e-06
found -9.7 (+-0.000326358) 39.8935 (+-0.128921) 10 (+-0.00105799)
found -7.9 (+-0.000328) 39.8942 (+-0.129006) 10.0002 (+-0.00105869)
found 2.9 (+-0.000327853) 39.8941 (+-0.128999) 10.0002 (+-0.00105863)
found 6.5 (+-0.000326275) 39.8937 (+-0.128926) 10.0001 (+-0.00105803)
found 8.3 (+-0.000327435) 39.894 (+-0.12898) 10.0001 (+-0.00105847)
found -8.5 (+-0.000345025) 35.9047 (+-0.12236) 9.00014 (+-0.00100415)
found -6.7 (+-0.000343904) 35.9044 (+-0.12231) 9.00006 (+-0.00100374)
found -2.5 (+-0.000346291) 35.9049 (+-0.12241) 9.00018 (+-0.00100455)
found -1.9 (+-0.000366051) 31.9153 (+-0.115366) 8.00013 (+-0.000946745)
found 3.5 (+-0.000366215) 31.9154 (+-0.115372) 8.00014 (+-0.000946802)
found 9.5 (+-0.000364249) 31.9156 (+-0.11531) 8.00019 (+-0.00094629)
found 8.9 (+-0.000394272) 27.9264 (+-0.108012) 7.00023 (+-0.000886398)
found -4.9 (+-0.000390688) 27.9257 (+-0.10789) 7.00006 (+-0.000885394)
found 4.7 (+-0.000390087) 27.9256 (+-0.107871) 7.00005 (+-0.000885244)
found -3.1 (+-0.000425415) 23.9368 (+-0.0999863) 6.00018 (+-0.000820536)
found 1.7 (+-0.000422069) 23.9363 (+-0.0998899) 6.00006 (+-0.000819745)
found -3.7 (+-0.000465001) 19.9472 (+-0.0912491) 5.00012 (+-0.000748835)
found -0.699999 (+-0.000462837) 19.947 (+-0.0911979) 5.00006 (+-0.000748414)
found -7.3 (+-0.000524774) 15.9584 (+-0.0817169) 4.00025 (+-0.000670609)
found -0.100002 (+-0.000518668) 15.9577 (+-0.0815935) 4.00008 (+-0.000669596)
found 2.3 (+-0.000523698) 15.9582 (+-0.0816942) 4.00021 (+-0.000670422)
found -4.3 (+-0.000604791) 11.9687 (+-0.0707502) 3.00016 (+-0.000580611)
found 5.3 (+-0.000602474) 11.9685 (+-0.0707154) 3.00012 (+-0.000580325)
found 7.1 (+-0.000604647) 11.9687 (+-0.0707498) 3.00017 (+-0.000580607)
found 7.7 (+-0.000604647) 11.9687 (+-0.0707498) 3.00017 (+-0.000580607)
found 5.90001 (+-0.000743831) 7.97938 (+-0.0578031) 2.00017 (+-0.00047436)
found -5.49999 (+-0.000738891) 7.97912 (+-0.0577516) 2.00011 (+-0.000473938)
found -9.1 (+-0.00107) 3.99034 (+-0.040977) 1.00025 (+-0.000336277)
found -1.30001 (+-0.00106314) 3.99003 (+-0.0409359) 1.00017 (+-0.00033594)
found 4.1 (+-0.00106581) 3.99013 (+-0.0409515) 1.0002 (+-0.000336068)
found -6.10002 (+-0.00105817) 3.98993 (+-0.0409095) 1.00014 (+-0.000335723)
found 0.499994 (+-0.00104848) 3.98961 (+-0.0408543) 1.00007 (+-0.00033527)
found 1.10001 (+-0.0010514) 3.98972 (+-0.0408716) 1.00009 (+-0.000335412)
#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()