This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 66.4904 10
created -9.46 26.5962 4
created -9.1 46.5433 7
created -8.74 26.5962 4
created -8.38 13.2981 2
created -8.02 33.2452 5
created -7.66 66.4904 10
created -7.3 19.9471 3
created -6.94 33.2452 5
created -6.58 66.4904 10
created -6.22 59.8413 9
created -5.86 46.5433 7
created -5.5 6.64904 1
created -5.14 19.9471 3
created -4.78 53.1923 8
created -4.42 33.2452 5
created -4.06 46.5433 7
created -3.7 13.2981 2
created -3.34 19.9471 3
created -2.98 19.9471 3
created -2.62 6.64904 1
created -2.26 13.2981 2
created -1.9 39.8942 6
created -1.54 66.4904 10
created -1.18 6.64904 1
created -0.82 13.2981 2
created -0.46 13.2981 2
created -0.1 59.8413 9
created 0.26 66.4904 10
created 0.62 13.2981 2
created 0.98 13.2981 2
created 1.34 59.8413 9
created 1.7 26.5962 4
created 2.06 13.2981 2
created 2.42 19.9471 3
created 2.78 46.5433 7
created 3.14 26.5962 4
created 3.5 19.9471 3
created 3.86 59.8413 9
created 4.22 46.5433 7
created 4.58 53.1923 8
created 4.94 59.8413 9
created 5.3 13.2981 2
created 5.66 13.2981 2
created 6.02 66.4904 10
created 6.38 46.5433 7
created 6.74 26.5962 4
created 7.1 19.9471 3
created 7.46 19.9471 3
created 7.82 66.4904 10
created 8.18 19.9471 3
created 8.54 33.2452 5
created 8.9 53.1923 8
created 9.26 59.8413 9
created 9.62 53.1923 8
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.50305e-05)
fit chi^2 = 3.05148e-06
found -9.82 (+-0.000141694) 66.4901 (+-0.155075) 10 (+-0.000782229)
found -7.66 (+-0.000141584) 66.4903 (+-0.155074) 10.0001 (+-0.000782224)
found -6.58 (+-0.000142084) 66.4905 (+-0.15514) 10.0001 (+-0.000782557)
found -1.54 (+-0.000141341) 66.4902 (+-0.155046) 10 (+-0.000782084)
found 0.26 (+-0.000141737) 66.4904 (+-0.155096) 10.0001 (+-0.000782338)
found 6.02 (+-0.000141605) 66.4903 (+-0.155078) 10.0001 (+-0.000782246)
found 7.82 (+-0.000141378) 66.4902 (+-0.155047) 10 (+-0.00078209)
found -6.22 (+-0.000150125) 59.8417 (+-0.147222) 9.00011 (+-0.000742618)
found 4.94 (+-0.000149432) 59.8414 (+-0.14714) 9.00007 (+-0.000742206)
found 9.26 (+-0.000150065) 59.8417 (+-0.147214) 9.00011 (+-0.00074258)
found -0.0999995 (+-0.000149566) 59.8415 (+-0.147157) 9.00008 (+-0.000742292)
found 1.34 (+-0.000149079) 59.8412 (+-0.147097) 9.00004 (+-0.00074199)
found 3.86 (+-0.000149509) 59.8414 (+-0.147148) 9.00007 (+-0.000742244)
found 9.62 (+-0.000157837) 53.1927 (+-0.138676) 8.00011 (+-0.00069951)
found -4.78 (+-0.000158507) 53.1923 (+-0.138724) 8.00005 (+-0.000699753)
found 4.58 (+-0.000159311) 53.1927 (+-0.138811) 8.00011 (+-0.000700191)
found 8.9 (+-0.000159115) 53.1926 (+-0.13879) 8.00009 (+-0.000700084)
found -5.86 (+-0.000169539) 46.5434 (+-0.129778) 7.00007 (+-0.000654628)
found 4.22 (+-0.000170595) 46.5437 (+-0.129874) 7.00011 (+-0.00065511)
found 6.38 (+-0.000170229) 46.5436 (+-0.129839) 7.00009 (+-0.000654936)
found -9.1 (+-0.000169619) 46.5433 (+-0.12978) 7.00005 (+-0.000654636)
found -4.06 (+-0.000169406) 46.5433 (+-0.129761) 7.00005 (+-0.000654542)
found 2.78 (+-0.000169466) 46.5433 (+-0.129766) 7.00005 (+-0.000654565)
found -1.9 (+-0.000183703) 39.8945 (+-0.120196) 6.00008 (+-0.000606296)
found -4.42 (+-0.000202238) 33.2456 (+-0.109791) 5.0001 (+-0.000553808)
found -8.02 (+-0.000201524) 33.2455 (+-0.109744) 5.00008 (+-0.000553572)
found -6.94 (+-0.000201782) 33.2455 (+-0.109761) 5.00009 (+-0.000553656)
found 8.54 (+-0.000201558) 33.2455 (+-0.109744) 5.00007 (+-0.000553572)
found -9.46 (+-0.000226877) 26.5967 (+-0.0982452) 4.00011 (+-0.00049557)
found -8.74 (+-0.000225312) 26.5964 (+-0.0981568) 4.00006 (+-0.000495124)
found 1.7 (+-0.000225603) 26.5965 (+-0.0981743) 4.00007 (+-0.000495212)
found 3.14 (+-0.000225625) 26.5964 (+-0.0981733) 4.00007 (+-0.000495207)
found 6.74 (+-0.000225625) 26.5964 (+-0.0981733) 4.00007 (+-0.000495207)
found -7.3 (+-0.000262355) 19.9477 (+-0.0851005) 3.0001 (+-0.000429265)
found 3.5 (+-0.00026191) 19.9476 (+-0.0850809) 3.00009 (+-0.000429166)
found 7.1 (+-0.000260485) 19.9473 (+-0.0850179) 3.00005 (+-0.000428848)
found 8.18 (+-0.000262355) 19.9477 (+-0.0851005) 3.0001 (+-0.000429265)
found -5.14 (+-0.000260436) 19.9474 (+-0.0850208) 3.00006 (+-0.000428863)
found -3.34 (+-0.000259766) 19.9472 (+-0.0849879) 3.00003 (+-0.000428697)
found -2.98 (+-0.000259208) 19.9472 (+-0.0849662) 3.00003 (+-0.000428588)
found 2.42 (+-0.000260807) 19.9474 (+-0.0850337) 3.00006 (+-0.000428928)
found 7.46 (+-0.00026175) 19.9476 (+-0.085075) 3.00009 (+-0.000429136)
found 0.619998 (+-0.000321425) 13.2985 (+-0.0694907) 2.00008 (+-0.000350526)
found 5.3 (+-0.000321194) 13.2985 (+-0.0694831) 2.00007 (+-0.000350488)
found -3.7 (+-0.00032125) 13.2984 (+-0.0694826) 2.00007 (+-0.000350485)
found -8.38 (+-0.000321072) 13.2984 (+-0.0694763) 2.00006 (+-0.000350453)
found -0.459998 (+-0.000321194) 13.2985 (+-0.0694831) 2.00007 (+-0.000350488)
found 0.980002 (+-0.000321194) 13.2985 (+-0.0694831) 2.00007 (+-0.000350488)
found 2.06 (+-0.000320226) 13.2983 (+-0.0694513) 2.00005 (+-0.000350327)
found 5.66 (+-0.000321425) 13.2985 (+-0.0694907) 2.00008 (+-0.000350526)
found -2.26 (+-0.000319568) 13.2983 (+-0.0694356) 2.00005 (+-0.000350248)
found -0.82 (+-0.000317842) 13.2981 (+-0.0693843) 2.00002 (+-0.000349989)
found -1.18 (+-0.000458503) 6.64954 (+-0.0491998) 1.00008 (+-0.000248174)
found -5.5 (+-0.000458224) 6.64944 (+-0.0491925) 1.00007 (+-0.000248137)
found -2.62 (+-0.000454543) 6.64922 (+-0.0491345) 1.00003 (+-0.000247845)
#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;
}
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
double Double_t
Double 8 bytes.
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()