This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 46.5433 7
created -9.46 66.4904 10
created -9.1 13.2981 2
created -8.74 26.5962 4
created -8.38 59.8413 9
created -8.02 39.8942 6
created -7.66 39.8942 6
created -7.3 39.8942 6
created -6.94 39.8942 6
created -6.58 26.5962 4
created -6.22 66.4904 10
created -5.86 66.4904 10
created -5.5 13.2981 2
created -5.14 26.5962 4
created -4.78 19.9471 3
created -4.42 39.8942 6
created -4.06 13.2981 2
created -3.7 39.8942 6
created -3.34 6.64904 1
created -2.98 46.5433 7
created -2.62 66.4904 10
created -2.26 53.1923 8
created -1.9 33.2452 5
created -1.54 46.5433 7
created -1.18 53.1923 8
created -0.82 59.8413 9
created -0.46 26.5962 4
created -0.1 19.9471 3
created 0.26 19.9471 3
created 0.62 13.2981 2
created 0.98 46.5433 7
created 1.34 19.9471 3
created 1.7 6.64904 1
created 2.06 6.64904 1
created 2.42 33.2452 5
created 2.78 13.2981 2
created 3.14 39.8942 6
created 3.5 53.1923 8
created 3.86 53.1923 8
created 4.22 33.2452 5
created 4.58 39.8942 6
created 4.94 53.1923 8
created 5.3 66.4904 10
created 5.66 59.8413 9
created 6.02 13.2981 2
created 6.38 33.2452 5
created 6.74 59.8413 9
created 7.1 13.2981 2
created 7.46 53.1923 8
created 7.82 26.5962 4
created 8.18 33.2452 5
created 8.54 26.5962 4
created 8.9 13.2981 2
created 9.26 19.9471 3
created 9.62 39.8942 6
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.29212e-05)
fit chi^2 = 2.29418e-06
found -9.46 (+-0.000122782) 66.4903 (+-0.134465) 10.0001 (+-0.000678269)
found -6.22 (+-0.000123166) 66.4905 (+-0.134515) 10.0001 (+-0.000678521)
found -5.86 (+-0.000122948) 66.4904 (+-0.134488) 10.0001 (+-0.000678385)
found -2.62 (+-0.000123281) 66.4906 (+-0.134529) 10.0001 (+-0.000678593)
found 5.3 (+-0.000123397) 66.4907 (+-0.134545) 10.0001 (+-0.000678673)
found -0.82 (+-0.000129808) 59.8415 (+-0.127609) 9.00008 (+-0.000643686)
found 5.66 (+-0.000129686) 59.8415 (+-0.127597) 9.00008 (+-0.000643625)
found -8.38 (+-0.000129671) 59.8414 (+-0.127592) 9.00007 (+-0.000643601)
found 6.74 (+-0.000129353) 59.8412 (+-0.127556) 9.00005 (+-0.000643417)
found -2.26 (+-0.000138028) 53.1926 (+-0.120349) 8.0001 (+-0.000607064)
found 3.86 (+-0.000137898) 53.1925 (+-0.120334) 8.00009 (+-0.00060699)
found -1.18 (+-0.000138135) 53.1926 (+-0.12036) 8.00011 (+-0.000607121)
found 3.5 (+-0.000137987) 53.1926 (+-0.120344) 8.00009 (+-0.000607038)
found 4.94 (+-0.000138117) 53.1927 (+-0.120358) 8.00011 (+-0.000607112)
found 7.46 (+-0.000137192) 53.1922 (+-0.120259) 8.00004 (+-0.000606613)
found -9.82 (+-0.000147536) 46.5434 (+-0.112565) 7.00007 (+-0.000567802)
found -2.98 (+-0.000147073) 46.5434 (+-0.112535) 7.00007 (+-0.000567649)
found -1.54 (+-0.00014757) 46.5435 (+-0.112577) 7.00009 (+-0.00056786)
found 0.98 (+-0.000146644) 46.5432 (+-0.11249) 7.00003 (+-0.000567424)
found -8.02 (+-0.000159795) 39.8946 (+-0.104259) 6.0001 (+-0.000525906)
found -7.66 (+-0.000159511) 39.8945 (+-0.104235) 6.00008 (+-0.000525784)
found -7.3 (+-0.000159511) 39.8945 (+-0.104235) 6.00008 (+-0.000525784)
found -6.94 (+-0.000159267) 39.8944 (+-0.104215) 6.00007 (+-0.000525683)
found -4.42 (+-0.000158532) 39.8942 (+-0.104156) 6.00003 (+-0.000525387)
found -3.7 (+-0.000158086) 39.8941 (+-0.104123) 6.00002 (+-0.000525217)
found 3.14 (+-0.00015912) 39.8944 (+-0.104205) 6.00007 (+-0.000525633)
found 4.58 (+-0.000159593) 39.8945 (+-0.104242) 6.00009 (+-0.000525821)
found 9.62 (+-0.000157568) 39.8943 (+-0.104095) 6.00006 (+-0.000525075)
found -1.9 (+-0.000175356) 33.2456 (+-0.0951973) 5.0001 (+-0.000480195)
found 4.22 (+-0.000175235) 33.2456 (+-0.0951887) 5.00009 (+-0.000480152)
found 2.42 (+-0.00017333) 33.2451 (+-0.0950603) 5.00002 (+-0.000479504)
found 6.38 (+-0.000174644) 33.2455 (+-0.0951496) 5.00007 (+-0.000479955)
found 8.18 (+-0.000174431) 33.2453 (+-0.0951322) 5.00005 (+-0.000479867)
found -6.58 (+-0.000196573) 26.5967 (+-0.0851778) 4.00011 (+-0.000429655)
found -0.460001 (+-0.000195888) 26.5965 (+-0.0851391) 4.00008 (+-0.00042946)
found 7.82 (+-0.000196172) 26.5965 (+-0.0851542) 4.00009 (+-0.000429536)
found 8.54 (+-0.000195057) 26.5963 (+-0.0850918) 4.00005 (+-0.000429221)
found -8.74 (+-0.000195616) 26.5965 (+-0.0851248) 4.00007 (+-0.000429387)
found -5.14 (+-0.000194659) 26.5962 (+-0.0850694) 4.00003 (+-0.000429108)
found -4.78 (+-0.000226586) 19.9474 (+-0.0737485) 3.00007 (+-0.000372003)
found -0.1 (+-0.000225861) 19.9473 (+-0.0737172) 3.00005 (+-0.000371845)
found 1.34 (+-0.000225651) 19.9473 (+-0.073712) 3.00005 (+-0.000371819)
found 0.26 (+-0.000225237) 19.9472 (+-0.0736912) 3.00003 (+-0.000371714)
found 9.26 (+-0.000225956) 19.9473 (+-0.0737225) 3.00005 (+-0.000371872)
found -9.1 (+-0.000279608) 13.2986 (+-0.0602795) 2.00009 (+-0.000304062)
found -5.5 (+-0.000279608) 13.2986 (+-0.0602795) 2.00009 (+-0.000304062)
found 6.02 (+-0.000279747) 13.2986 (+-0.060283) 2.00009 (+-0.00030408)
found 7.1 (+-0.000280552) 13.2987 (+-0.0603077) 2.00011 (+-0.000304205)
found -4.06 (+-0.000279322) 13.2985 (+-0.0602694) 2.00008 (+-0.000304011)
found 0.620001 (+-0.000278549) 13.2984 (+-0.0602469) 2.00007 (+-0.000303898)
found 2.78 (+-0.000279026) 13.2985 (+-0.0602604) 2.00007 (+-0.000303966)
found 8.9 (+-0.000277661) 13.2983 (+-0.0602197) 2.00005 (+-0.000303761)
found -3.34 (+-0.000399178) 6.64958 (+-0.0426829) 1.00009 (+-0.000215301)
found 1.7 (+-0.000392853) 6.64917 (+-0.0425853) 1.00003 (+-0.000214809)
found 2.06 (+-0.000394142) 6.64926 (+-0.0426059) 1.00004 (+-0.000214913)
#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()