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 6.64904 1
created -9.1 19.9471 3
created -8.74 6.64904 1
created -8.38 53.1923 8
created -8.02 26.5962 4
created -7.66 53.1923 8
created -7.3 39.8942 6
created -6.94 19.9471 3
created -6.58 33.2452 5
created -6.22 26.5962 4
created -5.86 46.5433 7
created -5.5 19.9471 3
created -5.14 59.8413 9
created -4.78 39.8942 6
created -4.42 26.5962 4
created -4.06 53.1923 8
created -3.7 53.1923 8
created -3.34 39.8942 6
created -2.98 6.64904 1
created -2.62 66.4904 10
created -2.26 59.8413 9
created -1.9 19.9471 3
created -1.54 46.5433 7
created -1.18 26.5962 4
created -0.82 26.5962 4
created -0.46 66.4904 10
created -0.1 33.2452 5
created 0.26 59.8413 9
created 0.62 19.9471 3
created 0.98 26.5962 4
created 1.34 6.64904 1
created 1.7 39.8942 6
created 2.06 13.2981 2
created 2.42 26.5962 4
created 2.78 53.1923 8
created 3.14 53.1923 8
created 3.5 26.5962 4
created 3.86 59.8413 9
created 4.22 33.2452 5
created 4.58 26.5962 4
created 4.94 66.4904 10
created 5.3 6.64904 1
created 5.66 33.2452 5
created 6.02 13.2981 2
created 6.38 39.8942 6
created 6.74 33.2452 5
created 7.1 19.9471 3
created 7.46 39.8942 6
created 7.82 59.8413 9
created 8.18 19.9471 3
created 8.54 6.64904 1
created 8.9 19.9471 3
created 9.26 39.8942 6
created 9.62 6.64904 1
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-5.65532e-06)
fit chi^2 = 4.14489e-07
found -2.62 (+-5.21678e-05) 66.4904 (+-0.0571532) 10.0001 (+-0.000288293)
found -0.46 (+-5.22225e-05) 66.4903 (+-0.0571582) 10.0001 (+-0.000288318)
found 4.94 (+-5.20263e-05) 66.4901 (+-0.0571341) 10 (+-0.000288197)
found -2.26 (+-5.51795e-05) 59.8415 (+-0.0542416) 9.00009 (+-0.000273606)
found -5.14 (+-5.50716e-05) 59.8413 (+-0.0542281) 9.00006 (+-0.000273538)
found 0.26 (+-5.50378e-05) 59.8413 (+-0.054224) 9.00005 (+-0.000273518)
found 3.86 (+-5.5083e-05) 59.8413 (+-0.0542292) 9.00006 (+-0.000273544)
found 7.82 (+-5.50716e-05) 59.8413 (+-0.0542281) 9.00006 (+-0.000273538)
found -3.7 (+-5.86519e-05) 53.1926 (+-0.0511523) 8.00009 (+-0.000258023)
found 3.14 (+-5.85709e-05) 53.1925 (+-0.0511437) 8.00008 (+-0.00025798)
found -8.38 (+-5.82287e-05) 53.1921 (+-0.0511084) 8.00003 (+-0.000257802)
found -7.66 (+-5.85062e-05) 53.1924 (+-0.0511366) 8.00007 (+-0.000257944)
found -4.06 (+-5.85709e-05) 53.1925 (+-0.0511437) 8.00008 (+-0.00025798)
found 2.78 (+-5.85709e-05) 53.1925 (+-0.0511437) 8.00008 (+-0.00025798)
found -9.82 (+-6.22639e-05) 46.543 (+-0.0478048) 7.00001 (+-0.000241137)
found -5.86 (+-6.24572e-05) 46.5432 (+-0.0478256) 7.00005 (+-0.000241243)
found -1.54 (+-6.24572e-05) 46.5432 (+-0.0478256) 7.00005 (+-0.000241243)
found -7.3 (+-6.77149e-05) 39.8944 (+-0.0442989) 6.00007 (+-0.000223453)
found -4.78 (+-6.78166e-05) 39.8945 (+-0.0443072) 6.00009 (+-0.000223495)
found -3.34 (+-6.75226e-05) 39.8944 (+-0.0442846) 6.00006 (+-0.000223381)
found 1.7 (+-6.7195e-05) 39.8941 (+-0.0442577) 6.00002 (+-0.000223245)
found 6.38 (+-6.75034e-05) 39.8943 (+-0.0442816) 6.00005 (+-0.000223366)
found 7.46 (+-6.77514e-05) 39.8945 (+-0.044302) 6.00008 (+-0.000223469)
found 9.26 (+-6.72741e-05) 39.8941 (+-0.0442638) 6.00003 (+-0.000223276)
found -0.1 (+-7.47093e-05) 33.2458 (+-0.0404765) 5.00013 (+-0.000204172)
found 4.22 (+-7.44044e-05) 33.2455 (+-0.0404549) 5.00009 (+-0.000204063)
found -6.58 (+-7.40668e-05) 33.2453 (+-0.0404311) 5.00005 (+-0.000203943)
found 5.66 (+-7.36743e-05) 33.2451 (+-0.0404057) 5.00002 (+-0.000203815)
found 6.74 (+-7.41878e-05) 33.2454 (+-0.0404396) 5.00006 (+-0.000203986)
found -8.02 (+-8.35726e-05) 26.5967 (+-0.036206) 4.00011 (+-0.000182631)
found -6.22 (+-8.33271e-05) 26.5965 (+-0.0361917) 4.00008 (+-0.000182559)
found -4.42 (+-8.34532e-05) 26.5966 (+-0.036199) 4.00009 (+-0.000182595)
found -1.18 (+-8.3248e-05) 26.5965 (+-0.0361873) 4.00007 (+-0.000182536)
found -0.819999 (+-8.34044e-05) 26.5966 (+-0.0361966) 4.00009 (+-0.000182584)
found 3.5 (+-8.3625e-05) 26.5967 (+-0.0362091) 4.00011 (+-0.000182646)
found 4.58 (+-8.34839e-05) 26.5966 (+-0.0362011) 4.0001 (+-0.000182606)
found 0.98 (+-8.25812e-05) 26.5961 (+-0.0361509) 4.00003 (+-0.000182353)
found 2.42 (+-8.30956e-05) 26.5964 (+-0.0361794) 4.00007 (+-0.000182497)
found -6.94 (+-9.64124e-05) 19.9475 (+-0.0313514) 3.00007 (+-0.000158143)
found -5.5 (+-9.68001e-05) 19.9477 (+-0.0313688) 3.00011 (+-0.000158231)
found -1.9 (+-9.68e-05) 19.9477 (+-0.0313688) 3.00011 (+-0.000158231)
found 0.619999 (+-9.65282e-05) 19.9476 (+-0.0313569) 3.00009 (+-0.000158171)
found 7.1 (+-9.64124e-05) 19.9475 (+-0.0313514) 3.00007 (+-0.000158143)
found 8.18 (+-9.60498e-05) 19.9474 (+-0.0313378) 3.00007 (+-0.000158075)
found -9.1 (+-9.51837e-05) 19.9471 (+-0.0313006) 3.00001 (+-0.000157887)
found 8.9 (+-9.58358e-05) 19.9473 (+-0.0313279) 3.00005 (+-0.000158025)
found 2.06 (+-0.000118457) 13.2984 (+-0.0256096) 2.00007 (+-0.00012918)
found 6.02 (+-0.000118601) 13.2985 (+-0.0256139) 2.00007 (+-0.000129202)
found 5.3 (+-0.000169946) 6.64967 (+-0.0181473) 1.0001 (+-9.15388e-05)
found -9.46 (+-0.00016888) 6.64944 (+-0.0181301) 1.00007 (+-9.14519e-05)
found -2.98 (+-0.000170173) 6.64971 (+-0.0181509) 1.00011 (+-9.15571e-05)
found -8.74 (+-0.000169059) 6.64949 (+-0.0181331) 1.00007 (+-9.14671e-05)
found 9.62 (+-0.000166078) 6.64931 (+-0.0180945) 1.00005 (+-9.12723e-05)
found 1.34 (+-0.00016899) 6.64944 (+-0.0181315) 1.00007 (+-9.14592e-05)
found 8.54 (+-0.000167905) 6.64926 (+-0.0181144) 1.00004 (+-9.1373e-05)
#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()