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 46.5433 7
created -9.1 19.9471 3
created -8.74 13.2981 2
created -8.38 59.8413 9
created -8.02 59.8413 9
created -7.66 53.1923 8
created -7.3 33.2452 5
created -6.94 59.8413 9
created -6.58 59.8413 9
created -6.22 39.8942 6
created -5.86 26.5962 4
created -5.5 59.8413 9
created -5.14 33.2452 5
created -4.78 59.8413 9
created -4.42 6.64904 1
created -4.06 19.9471 3
created -3.7 13.2981 2
created -3.34 53.1923 8
created -2.98 33.2452 5
created -2.62 53.1923 8
created -2.26 46.5433 7
created -1.9 53.1923 8
created -1.54 66.4904 10
created -1.18 59.8413 9
created -0.82 39.8942 6
created -0.46 46.5433 7
created -0.1 39.8942 6
created 0.26 6.64904 1
created 0.62 59.8413 9
created 0.98 66.4904 10
created 1.34 46.5433 7
created 1.7 53.1923 8
created 2.06 6.64904 1
created 2.42 39.8942 6
created 2.78 33.2452 5
created 3.14 59.8413 9
created 3.5 46.5433 7
created 3.86 19.9471 3
created 4.22 13.2981 2
created 4.58 33.2452 5
created 4.94 13.2981 2
created 5.3 46.5433 7
created 5.66 66.4904 10
created 6.02 46.5433 7
created 6.38 53.1923 8
created 6.74 39.8942 6
created 7.1 6.64904 1
created 7.46 39.8942 6
created 7.82 19.9471 3
created 8.18 33.2452 5
created 8.54 46.5433 7
created 8.9 19.9471 3
created 9.26 13.2981 2
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.58225e-05)
fit chi^2 = 3.8091e-06
found -1.54 (+-0.000159002) 66.4907 (+-0.173366) 10.0001 (+-0.000874496)
found 0.98 (+-0.000158924) 66.4906 (+-0.173356) 10.0001 (+-0.000874443)
found 5.66 (+-0.000158775) 66.4905 (+-0.173335) 10.0001 (+-0.00087434)
found 9.62 (+-0.000156891) 66.4904 (+-0.173113) 10.0001 (+-0.000873217)
found -8.02 (+-0.000167741) 59.8417 (+-0.164487) 9.00011 (+-0.000829707)
found -6.58 (+-0.000167562) 59.8416 (+-0.164465) 9.0001 (+-0.000829596)
found -1.18 (+-0.000167635) 59.8416 (+-0.164474) 9.00011 (+-0.000829643)
found -8.38 (+-0.000167033) 59.8414 (+-0.164404) 9.00007 (+-0.00082929)
found -6.94 (+-0.000167459) 59.8416 (+-0.164453) 9.00009 (+-0.000829534)
found -5.5 (+-0.000166983) 59.8413 (+-0.164395) 9.00006 (+-0.000829242)
found -4.78 (+-0.000166445) 59.8412 (+-0.164336) 9.00004 (+-0.000828943)
found 0.620001 (+-0.000166871) 59.8414 (+-0.164389) 9.00007 (+-0.000829212)
found 3.14 (+-0.000167296) 59.8415 (+-0.164432) 9.00008 (+-0.000829431)
found -7.66 (+-0.000177774) 53.1926 (+-0.155065) 8.00009 (+-0.000782179)
found -3.34 (+-0.000176906) 53.1922 (+-0.154973) 8.00005 (+-0.000781714)
found -2.62 (+-0.000177593) 53.1925 (+-0.155044) 8.00008 (+-0.000782077)
found -1.9 (+-0.000178073) 53.1927 (+-0.155098) 8.00011 (+-0.000782345)
found 1.7 (+-0.000176862) 53.1923 (+-0.154972) 8.00005 (+-0.000781709)
found 6.38 (+-0.000177708) 53.1925 (+-0.155057) 8.00009 (+-0.000782139)
found -2.26 (+-0.000190502) 46.5437 (+-0.145093) 7.00011 (+-0.000731881)
found 1.34 (+-0.000190691) 46.5437 (+-0.145112) 7.00012 (+-0.000731976)
found 3.5 (+-0.000189928) 46.5435 (+-0.14504) 7.00008 (+-0.000731611)
found 6.02 (+-0.000190691) 46.5438 (+-0.145112) 7.00012 (+-0.000731976)
found -9.82 (+-0.000189813) 46.5433 (+-0.145015) 7.00005 (+-0.000731488)
found -9.46 (+-0.000189726) 46.5434 (+-0.14502) 7.00007 (+-0.000731509)
found -0.46 (+-0.000190058) 46.5435 (+-0.14505) 7.00008 (+-0.000731663)
found 5.3 (+-0.000189804) 46.5435 (+-0.14503) 7.00008 (+-0.000731562)
found 8.54 (+-0.000189483) 46.5433 (+-0.144996) 7.00005 (+-0.000731391)
found -6.22 (+-0.000205585) 39.8945 (+-0.134316) 6.00009 (+-0.00067752)
found -0.82 (+-0.000206035) 39.8947 (+-0.134353) 6.00011 (+-0.000677707)
found 6.74 (+-0.000204693) 39.8944 (+-0.134248) 6.00006 (+-0.000677174)
found -0.100001 (+-0.000204574) 39.8943 (+-0.134237) 6.00005 (+-0.000677122)
found 2.42 (+-0.000204299) 39.8942 (+-0.134214) 6.00004 (+-0.000677004)
found 7.46 (+-0.00020394) 39.8941 (+-0.134185) 6.00003 (+-0.000676857)
found -7.3 (+-0.000226226) 33.2457 (+-0.122685) 5.00011 (+-0.00061885)
found -5.14 (+-0.000226357) 33.2458 (+-0.122695) 5.00012 (+-0.000618898)
found -2.98 (+-0.000226095) 33.2457 (+-0.122676) 5.00011 (+-0.000618802)
found 2.78 (+-0.000225927) 33.2456 (+-0.122664) 5.0001 (+-0.000618742)
found 4.58 (+-0.000223735) 33.2451 (+-0.122513) 5.00003 (+-0.000617983)
found 8.18 (+-0.000225053) 33.2454 (+-0.122603) 5.00007 (+-0.000618434)
found -5.86 (+-0.000253145) 26.5966 (+-0.109746) 4.0001 (+-0.000553582)
found -9.1 (+-0.000291391) 19.9474 (+-0.095005) 3.00006 (+-0.000479225)
found 3.86 (+-0.000291391) 19.9474 (+-0.095005) 3.00006 (+-0.000479225)
found 7.82 (+-0.000292272) 19.9475 (+-0.095041) 3.00007 (+-0.000479407)
found 8.9 (+-0.000291391) 19.9474 (+-0.095005) 3.00006 (+-0.000479225)
found -4.06 (+-0.000289163) 19.9471 (+-0.0949114) 3.00002 (+-0.000478753)
found -8.74 (+-0.000359506) 13.2985 (+-0.077649) 2.00008 (+-0.000391678)
found -3.7 (+-0.000359226) 13.2985 (+-0.0776401) 2.00007 (+-0.000391633)
found 4.22 (+-0.000358208) 13.2983 (+-0.0776084) 2.00005 (+-0.000391473)
found 4.94 (+-0.000359875) 13.2985 (+-0.0776583) 2.00008 (+-0.000391725)
found 9.26 (+-0.000359765) 13.2986 (+-0.0776575) 2.00009 (+-0.000391721)
found -4.42 (+-0.000512995) 6.64953 (+-0.0549786) 1.00008 (+-0.000277323)
found 2.06 (+-0.000514906) 6.64962 (+-0.0550077) 1.00009 (+-0.00027747)
found 0.260002 (+-0.000515409) 6.64967 (+-0.0550162) 1.0001 (+-0.000277513)
found 7.1 (+-0.00051375) 6.64953 (+-0.0549886) 1.00008 (+-0.000277374)
#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()