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 35.9048 9
created -8.5 27.926 7
created -7.9 3.98942 1
created -7.3 19.9471 5
created -6.7 23.9365 6
created -6.1 23.9365 6
created -5.5 15.9577 4
created -4.9 19.9471 5
created -4.3 7.97885 2
created -3.7 7.97885 2
created -3.1 15.9577 4
created -2.5 19.9471 5
created -1.9 15.9577 4
created -1.3 35.9048 9
created -0.7 31.9154 8
created -0.1 15.9577 4
created 0.5 3.98942 1
created 1.1 39.8942 10
created 1.7 19.9471 5
created 2.3 23.9365 6
created 2.9 11.9683 3
created 3.5 31.9154 8
created 4.1 11.9683 3
created 4.7 3.98942 1
created 5.3 7.97885 2
created 5.9 19.9471 5
created 6.5 31.9154 8
created 7.1 11.9683 3
created 7.7 35.9048 9
created 8.3 39.8942 10
created 8.9 35.9048 9
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.60123e-05)
fit chi^2 = 3.49688e-06
found 1.1 (+-0.000258187) 39.8938 (+-0.102012) 10.0001 (+-0.000837157)
found 8.3 (+-0.000260235) 39.8944 (+-0.102107) 10.0002 (+-0.000837939)
found -9.1 (+-0.000272991) 35.9046 (+-0.0968109) 9.00011 (+-0.000794478)
found -1.3 (+-0.000273631) 35.9047 (+-0.0968375) 9.00015 (+-0.000794696)
found 7.7 (+-0.000273652) 35.9048 (+-0.0968394) 9.00017 (+-0.000794712)
found 8.9 (+-0.00027407) 35.9049 (+-0.0968569) 9.00019 (+-0.000794855)
found -0.700001 (+-0.000290612) 31.9154 (+-0.0913144) 8.00017 (+-0.000749371)
found 3.5 (+-0.000289254) 31.9151 (+-0.0912619) 8.00008 (+-0.00074894)
found 6.5 (+-0.000289714) 31.9152 (+-0.0912793) 8.0001 (+-0.000749083)
found -8.5 (+-0.00030988) 27.9259 (+-0.085393) 7.00013 (+-0.000700776)
found -6.7 (+-0.000336003) 23.9366 (+-0.0790929) 6.00014 (+-0.000649075)
found -6.1 (+-0.000335728) 23.9366 (+-0.0790848) 6.00013 (+-0.000649009)
found 2.3 (+-0.000335167) 23.9365 (+-0.0790684) 6.0001 (+-0.000648874)
found 1.7 (+-0.000369797) 19.9476 (+-0.072246) 5.00021 (+-0.000592886)
found 9.5 (+-0.000365689) 19.9474 (+-0.0721583) 5.00018 (+-0.000592166)
found -7.3 (+-0.000366801) 19.9471 (+-0.0721728) 5.00009 (+-0.000592285)
found -4.9 (+-0.000366853) 19.947 (+-0.0721721) 5.00008 (+-0.00059228)
found -2.5 (+-0.000367695) 19.9471 (+-0.0721922) 5.0001 (+-0.000592445)
found 5.9 (+-0.00036793) 19.9472 (+-0.0721998) 5.00013 (+-0.000592507)
found -5.5 (+-0.000412934) 15.958 (+-0.0646078) 4.00014 (+-0.000530204)
found -1.9 (+-0.000413777) 15.9581 (+-0.0646258) 4.00018 (+-0.000530351)
found -0.100004 (+-0.000411294) 15.9579 (+-0.064578) 4.00012 (+-0.000529958)
found -3.1 (+-0.000411173) 15.9577 (+-0.0645729) 4.00009 (+-0.000529917)
found 2.9 (+-0.000479321) 11.9688 (+-0.0559919) 3.00018 (+-0.000459497)
found 4.1 (+-0.00047601) 11.9685 (+-0.055943) 3.00012 (+-0.000459096)
found 7.1 (+-0.000480406) 11.9689 (+-0.0560096) 3.00022 (+-0.000459642)
found -9.69999 (+-0.000585649) 7.97917 (+-0.0457022) 2.00012 (+-0.000375055)
found -4.3 (+-0.000584949) 7.97906 (+-0.0456954) 2.00009 (+-0.000374999)
found -3.7 (+-0.00058425) 7.979 (+-0.0456878) 2.00008 (+-0.000374937)
found 5.3 (+-0.000583479) 7.97901 (+-0.0456813) 2.00008 (+-0.000374883)
found -7.9 (+-0.000840285) 3.98997 (+-0.032384) 1.00016 (+-0.000265759)
found 0.500013 (+-0.000841455) 3.99008 (+-0.0323918) 1.00018 (+-0.000265823)
found 4.7 (+-0.000830777) 3.98961 (+-0.0323301) 1.00007 (+-0.000265316)
#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()