This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 33.2452 5
created -9.46 39.8942 6
created -9.1 6.64904 1
created -8.74 46.5433 7
created -8.38 13.2981 2
created -8.02 39.8942 6
created -7.66 6.64904 1
created -7.3 59.8413 9
created -6.94 66.4904 10
created -6.58 53.1923 8
created -6.22 53.1923 8
created -5.86 46.5433 7
created -5.5 26.5962 4
created -5.14 13.2981 2
created -4.78 39.8942 6
created -4.42 33.2452 5
created -4.06 46.5433 7
created -3.7 6.64904 1
created -3.34 66.4904 10
created -2.98 26.5962 4
created -2.62 46.5433 7
created -2.26 19.9471 3
created -1.9 46.5433 7
created -1.54 46.5433 7
created -1.18 19.9471 3
created -0.82 46.5433 7
created -0.46 6.64904 1
created -0.1 26.5962 4
created 0.26 33.2452 5
created 0.62 19.9471 3
created 0.98 66.4904 10
created 1.34 6.64904 1
created 1.7 59.8413 9
created 2.06 53.1923 8
created 2.42 59.8413 9
created 2.78 39.8942 6
created 3.14 6.64904 1
created 3.5 6.64904 1
created 3.86 39.8942 6
created 4.22 19.9471 3
created 4.58 33.2452 5
created 4.94 46.5433 7
created 5.3 59.8413 9
created 5.66 53.1923 8
created 6.02 66.4904 10
created 6.38 46.5433 7
created 6.74 46.5433 7
created 7.1 39.8942 6
created 7.46 46.5433 7
created 7.82 46.5433 7
created 8.18 26.5962 4
created 8.54 33.2452 5
created 8.9 66.4904 10
created 9.26 46.5433 7
created 9.62 66.4904 10
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.61264e-05)
fit chi^2 = 3.81487e-06
found -6.94 (+-0.000159123) 66.4907 (+-0.173498) 10.0001 (+-0.000875159)
found -3.34 (+-0.000157836) 66.4901 (+-0.173332) 10 (+-0.000874323)
found 0.98 (+-0.000157713) 66.4901 (+-0.173316) 10 (+-0.000874243)
found 6.02 (+-0.000158973) 66.4906 (+-0.173477) 10.0001 (+-0.000875056)
found 8.9 (+-0.000158716) 66.4905 (+-0.173443) 10.0001 (+-0.000874882)
found 9.62 (+-0.000157562) 66.4907 (+-0.173316) 10.0001 (+-0.000874242)
found 2.42 (+-0.000167611) 59.8416 (+-0.16458) 9.00009 (+-0.000830175)
found -7.3 (+-0.000166998) 59.8414 (+-0.164513) 9.00007 (+-0.00082984)
found 1.7 (+-0.000166848) 59.8413 (+-0.164494) 9.00006 (+-0.000829744)
found 5.3 (+-0.000167704) 59.8416 (+-0.164591) 9.0001 (+-0.000830232)
found -6.58 (+-0.000178303) 53.1927 (+-0.155225) 8.00012 (+-0.00078299)
found -6.22 (+-0.00017804) 53.1926 (+-0.155196) 8.0001 (+-0.000782841)
found 2.06 (+-0.000178309) 53.1927 (+-0.155226) 8.00012 (+-0.000782993)
found 5.66 (+-0.00017839) 53.1928 (+-0.155235) 8.00013 (+-0.000783039)
found -5.86 (+-0.000190147) 46.5435 (+-0.145155) 7.00008 (+-0.000732195)
found 6.38 (+-0.000190729) 46.5437 (+-0.145212) 7.00011 (+-0.000732478)
found 9.26 (+-0.000191025) 46.5438 (+-0.145241) 7.00014 (+-0.000732626)
found -8.74 (+-0.000188599) 46.5431 (+-0.145014) 7.00002 (+-0.000731483)
found -4.06 (+-0.000189122) 46.5432 (+-0.145062) 7.00004 (+-0.000731726)
found -2.62 (+-0.000189481) 46.5433 (+-0.145092) 7.00005 (+-0.000731875)
found -1.9 (+-0.00018987) 46.5434 (+-0.145129) 7.00007 (+-0.000732063)
found -1.54 (+-0.00018987) 46.5434 (+-0.145129) 7.00007 (+-0.000732063)
found -0.82 (+-0.000188808) 46.5431 (+-0.145033) 7.00003 (+-0.000731578)
found 4.94 (+-0.000190392) 46.5436 (+-0.145179) 7.00009 (+-0.000732313)
found 6.74 (+-0.000190318) 46.5435 (+-0.145171) 7.00009 (+-0.000732274)
found 7.46 (+-0.000190318) 46.5435 (+-0.145171) 7.00009 (+-0.000732274)
found 7.82 (+-0.000190042) 46.5434 (+-0.145145) 7.00007 (+-0.000732142)
found 2.78 (+-0.000204958) 39.8944 (+-0.134359) 6.00007 (+-0.000677735)
found -9.46 (+-0.000204453) 39.8942 (+-0.134316) 6.00004 (+-0.000677517)
found -8.02 (+-0.000203854) 39.8941 (+-0.134268) 6.00002 (+-0.000677275)
found -4.78 (+-0.00020479) 39.8943 (+-0.13434) 6.00005 (+-0.000677641)
found 3.86 (+-0.000204095) 39.8941 (+-0.134286) 6.00003 (+-0.000677369)
found 7.1 (+-0.000205958) 39.8946 (+-0.134435) 6.00009 (+-0.000678119)
found -9.82 (+-0.000224932) 33.2452 (+-0.122665) 5.00004 (+-0.000618749)
found -4.42 (+-0.000225826) 33.2455 (+-0.122737) 5.00009 (+-0.000619111)
found 0.26 (+-0.000224702) 33.2453 (+-0.122659) 5.00005 (+-0.000618717)
found 4.58 (+-0.000225223) 33.2454 (+-0.122696) 5.00007 (+-0.000618903)
found 8.54 (+-0.000225847) 33.2456 (+-0.12274) 5.00009 (+-0.000619126)
found -5.5 (+-0.000251923) 26.5964 (+-0.10975) 4.00006 (+-0.000553603)
found -2.98 (+-0.000253674) 26.5967 (+-0.109849) 4.00011 (+-0.000554101)
found 8.18 (+-0.000252795) 26.5965 (+-0.109797) 4.00008 (+-0.000553841)
found -0.0999994 (+-0.000251044) 26.5962 (+-0.109703) 4.00004 (+-0.000553363)
found -2.26 (+-0.000293247) 19.9476 (+-0.0951465) 3.00009 (+-0.000479939)
found -1.18 (+-0.000293247) 19.9476 (+-0.0951465) 3.00009 (+-0.000479939)
found 0.620001 (+-0.000293341) 19.9476 (+-0.0951517) 3.0001 (+-0.000479965)
found 4.22 (+-0.000292493) 19.9475 (+-0.095113) 3.00007 (+-0.00047977)
found -8.38 (+-0.00036053) 13.2986 (+-0.0777287) 2.00009 (+-0.00039208)
found -5.14 (+-0.000359372) 13.2984 (+-0.0776937) 2.00007 (+-0.000391903)
found 1.34 (+-0.000517947) 6.64985 (+-0.0550935) 1.00013 (+-0.000277903)
found -3.7 (+-0.00051688) 6.64976 (+-0.0550758) 1.00012 (+-0.000277814)
found -9.1 (+-0.000514746) 6.64958 (+-0.0550402) 1.00009 (+-0.000277634)
found -7.66 (+-0.0005158) 6.64967 (+-0.0550578) 1.0001 (+-0.000277723)
found -0.460002 (+-0.000513278) 6.64949 (+-0.0550169) 1.00007 (+-0.000277517)
found 3.14 (+-0.000508912) 6.64931 (+-0.0549518) 1.00005 (+-0.000277189)
found 3.5 (+-0.000508912) 6.64931 (+-0.0549518) 1.00005 (+-0.000277189)
#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()