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 26.5962 4
created -9.1 53.1923 8
created -8.74 26.5962 4
created -8.38 6.64904 1
created -8.02 39.8942 6
created -7.66 46.5433 7
created -7.3 59.8413 9
created -6.94 66.4904 10
created -6.58 13.2981 2
created -6.22 59.8413 9
created -5.86 6.64904 1
created -5.5 53.1923 8
created -5.14 33.2452 5
created -4.78 53.1923 8
created -4.42 19.9471 3
created -4.06 46.5433 7
created -3.7 53.1923 8
created -3.34 59.8413 9
created -2.98 19.9471 3
created -2.62 13.2981 2
created -2.26 46.5433 7
created -1.9 53.1923 8
created -1.54 19.9471 3
created -1.18 26.5962 4
created -0.82 19.9471 3
created -0.46 6.64904 1
created -0.1 6.64904 1
created 0.26 59.8413 9
created 0.62 59.8413 9
created 0.98 13.2981 2
created 1.34 59.8413 9
created 1.7 6.64904 1
created 2.06 6.64904 1
created 2.42 53.1923 8
created 2.78 39.8942 6
created 3.14 59.8413 9
created 3.5 53.1923 8
created 3.86 53.1923 8
created 4.22 13.2981 2
created 4.58 6.64904 1
created 4.94 59.8413 9
created 5.3 53.1923 8
created 5.66 26.5962 4
created 6.02 59.8413 9
created 6.38 6.64904 1
created 6.74 13.2981 2
created 7.1 26.5962 4
created 7.46 13.2981 2
created 7.82 66.4904 10
created 8.18 33.2452 5
created 8.54 66.4904 10
created 8.9 39.8942 6
created 9.26 19.9471 3
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.48993e-05)
fit chi^2 = 3.06264e-06
found -6.94 (+-0.000141996) 66.4904 (+-0.15538) 10.0001 (+-0.000783767)
found 7.82 (+-0.000141705) 66.4902 (+-0.15534) 10 (+-0.000783567)
found 8.54 (+-0.000142134) 66.4904 (+-0.155395) 10.0001 (+-0.000783843)
found -3.34 (+-0.000149857) 59.8414 (+-0.147426) 9.00007 (+-0.000743647)
found 0.62 (+-0.000149775) 59.8414 (+-0.147418) 9.00007 (+-0.000743606)
found -7.3 (+-0.000150399) 59.8417 (+-0.147491) 9.00011 (+-0.000743975)
found -6.22 (+-0.000148872) 59.8411 (+-0.147313) 9.00002 (+-0.000743077)
found 0.260001 (+-0.000149565) 59.8414 (+-0.147396) 9.00007 (+-0.000743495)
found 1.34 (+-0.000148872) 59.8411 (+-0.147313) 9.00002 (+-0.000743077)
found 3.14 (+-0.000150179) 59.8416 (+-0.147463) 9.00009 (+-0.000743837)
found 4.94 (+-0.000149496) 59.8413 (+-0.147387) 9.00006 (+-0.00074345)
found 6.02 (+-0.000149144) 59.8411 (+-0.147344) 9.00003 (+-0.000743233)
found 3.5 (+-0.000159687) 53.1927 (+-0.139074) 8.00011 (+-0.000701517)
found 3.86 (+-0.000158904) 53.1924 (+-0.138991) 8.00007 (+-0.0007011)
found 5.3 (+-0.000159289) 53.1925 (+-0.139031) 8.00009 (+-0.000701301)
found -9.1 (+-0.000158817) 53.1923 (+-0.138979) 8.00005 (+-0.00070104)
found -5.5 (+-0.000158396) 53.1922 (+-0.138938) 8.00004 (+-0.000700835)
found -4.78 (+-0.000158796) 53.1923 (+-0.138977) 8.00005 (+-0.000701031)
found -3.7 (+-0.000159602) 53.1927 (+-0.139064) 8.00011 (+-0.00070147)
found -1.9 (+-0.00015899) 53.1924 (+-0.138999) 8.00007 (+-0.000701138)
found 2.42 (+-0.000158497) 53.1922 (+-0.13895) 8.00005 (+-0.000700891)
found 9.62 (+-0.000157531) 53.1924 (+-0.138863) 8.00007 (+-0.000700457)
found -7.66 (+-0.000170707) 46.5436 (+-0.130091) 7.0001 (+-0.000656208)
found -4.06 (+-0.000170217) 46.5434 (+-0.130045) 7.00007 (+-0.000655976)
found -2.26 (+-0.000170026) 46.5434 (+-0.130028) 7.00007 (+-0.000655891)
found 2.78 (+-0.000184856) 39.8947 (+-0.120481) 6.00011 (+-0.000607732)
found 8.9 (+-0.000184259) 39.8945 (+-0.120433) 6.00009 (+-0.000607488)
found -8.02 (+-0.000183437) 39.8943 (+-0.120368) 6.00005 (+-0.000607161)
found -5.14 (+-0.000202735) 33.2457 (+-0.110001) 5.00011 (+-0.000554866)
found 8.18 (+-0.000203189) 33.2459 (+-0.110034) 5.00013 (+-0.000555034)
found -9.82 (+-0.000201211) 33.2451 (+-0.109885) 5.00003 (+-0.000554284)
found -9.46 (+-0.000226658) 26.5966 (+-0.0983876) 4.00009 (+-0.000496288)
found -8.74 (+-0.000225438) 26.5964 (+-0.0983232) 4.00006 (+-0.000495963)
found 5.66 (+-0.000227315) 26.5967 (+-0.0984258) 4.00011 (+-0.000496481)
found -1.18 (+-0.00022522) 26.5962 (+-0.0983062) 4.00004 (+-0.000495877)
found 7.1 (+-0.000224601) 26.5961 (+-0.0982731) 4.00003 (+-0.00049571)
found -4.42 (+-0.000262947) 19.9477 (+-0.0852602) 3.0001 (+-0.00043007)
found -2.98 (+-0.000261656) 19.9475 (+-0.0852062) 3.00007 (+-0.000429798)
found -1.54 (+-0.000262209) 19.9475 (+-0.085228) 3.00008 (+-0.000429908)
found -0.820001 (+-0.00026) 19.9472 (+-0.0851351) 3.00003 (+-0.000429439)
found 9.26 (+-0.000262729) 19.9476 (+-0.0852505) 3.0001 (+-0.000430022)
found -6.58 (+-0.000324643) 13.2988 (+-0.0696954) 2.00013 (+-0.000351558)
found 0.98 (+-0.000324407) 13.2988 (+-0.0696878) 2.00012 (+-0.00035152)
found 4.22 (+-0.000320719) 13.2984 (+-0.0695805) 2.00006 (+-0.000350979)
found -2.62 (+-0.000321837) 13.2984 (+-0.0696095) 2.00007 (+-0.000351125)
found 7.46 (+-0.000323061) 13.2986 (+-0.0696472) 2.00009 (+-0.000351315)
found 6.74 (+-0.000319436) 13.2982 (+-0.0695405) 2.00003 (+-0.000350777)
found -5.86 (+-0.000463203) 6.64976 (+-0.049349) 1.00012 (+-0.000248927)
found 1.7 (+-0.000457429) 6.64945 (+-0.0492615) 1.00007 (+-0.000248486)
found 6.38 (+-0.000458931) 6.64949 (+-0.0492825) 1.00007 (+-0.000248591)
found -8.38 (+-0.000459358) 6.64944 (+-0.0492862) 1.00007 (+-0.00024861)
found -0.460001 (+-0.000453905) 6.64918 (+-0.0492033) 1.00003 (+-0.000248192)
found -0.0999951 (+-0.000457429) 6.64945 (+-0.0492615) 1.00007 (+-0.000248486)
found 2.06 (+-0.000456991) 6.6494 (+-0.0492539) 1.00006 (+-0.000248447)
found 4.58 (+-0.000458931) 6.64949 (+-0.0492825) 1.00008 (+-0.000248591)
#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()