This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.82 53.1923 8
created -9.46 33.2452 5
created -9.1 59.8413 9
created -8.74 33.2452 5
created -8.38 59.8413 9
created -8.02 66.4904 10
created -7.66 26.5962 4
created -7.3 19.9471 3
created -6.94 46.5433 7
created -6.58 46.5433 7
created -6.22 26.5962 4
created -5.86 66.4904 10
created -5.5 33.2452 5
created -5.14 59.8413 9
created -4.78 33.2452 5
created -4.42 26.5962 4
created -4.06 19.9471 3
created -3.7 26.5962 4
created -3.34 46.5433 7
created -2.98 39.8942 6
created -2.62 33.2452 5
created -2.26 53.1923 8
created -1.9 46.5433 7
created -1.54 39.8942 6
created -1.18 59.8413 9
created -0.82 53.1923 8
created -0.46 6.64904 1
created -0.1 53.1923 8
created 0.26 13.2981 2
created 0.62 33.2452 5
created 0.98 26.5962 4
created 1.34 66.4904 10
created 1.7 53.1923 8
created 2.06 66.4904 10
created 2.42 59.8413 9
created 2.78 59.8413 9
created 3.14 59.8413 9
created 3.5 39.8942 6
created 3.86 19.9471 3
created 4.22 19.9471 3
created 4.58 66.4904 10
created 4.94 19.9471 3
created 5.3 19.9471 3
created 5.66 13.2981 2
created 6.02 19.9471 3
created 6.38 46.5433 7
created 6.74 19.9471 3
created 7.1 59.8413 9
created 7.46 33.2452 5
created 7.82 26.5962 4
created 8.18 13.2981 2
created 8.54 19.9471 3
created 8.9 59.8413 9
created 9.26 33.2452 5
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.41794e-05)
fit chi^2 = 3.04895e-06
found -8.02 (+-0.000141929) 66.4905 (+-0.155063) 10.0001 (+-0.00078217)
found -5.86 (+-0.000141637) 66.4903 (+-0.155023) 10.0001 (+-0.000781971)
found 1.34 (+-0.000141865) 66.4905 (+-0.155054) 10.0001 (+-0.000782126)
found 2.06 (+-0.000142255) 66.4907 (+-0.155106) 10.0001 (+-0.000782388)
found 4.58 (+-0.000141319) 66.4902 (+-0.154983) 10 (+-0.000781766)
found 2.42 (+-0.000150209) 59.8418 (+-0.147179) 9.00013 (+-0.000742402)
found 2.78 (+-0.000150144) 59.8417 (+-0.147171) 9.00012 (+-0.00074236)
found 3.14 (+-0.000149914) 59.8416 (+-0.147142) 9.0001 (+-0.000742217)
found -9.1 (+-0.0001495) 59.8414 (+-0.147092) 9.00007 (+-0.000741962)
found -8.38 (+-0.000149886) 59.8416 (+-0.14714) 9.0001 (+-0.000742203)
found -5.14 (+-0.0001495) 59.8414 (+-0.147092) 9.00007 (+-0.000741962)
found -1.18 (+-0.000149843) 59.8416 (+-0.147134) 9.00009 (+-0.000742173)
found 7.1 (+-0.000149272) 59.8413 (+-0.147065) 9.00005 (+-0.000741829)
found 8.9 (+-0.000149272) 59.8413 (+-0.147065) 9.00005 (+-0.000741829)
found -0.820001 (+-0.000158393) 53.1924 (+-0.138667) 8.00007 (+-0.000699465)
found 1.7 (+-0.000159553) 53.1928 (+-0.138788) 8.00013 (+-0.000700075)
found -9.82 (+-0.000158575) 53.1922 (+-0.138669) 8.00003 (+-0.000699474)
found -2.26 (+-0.000158888) 53.1925 (+-0.138714) 8.00008 (+-0.000699703)
found -0.0999999 (+-0.000157626) 53.1921 (+-0.138584) 8.00002 (+-0.000699049)
found 9.62 (+-0.000157424) 53.1925 (+-0.138579) 8.00009 (+-0.000699022)
found -1.9 (+-0.000170238) 46.5436 (+-0.129792) 7.00009 (+-0.000654696)
found -6.94 (+-0.000169743) 46.5434 (+-0.129745) 7.00007 (+-0.000654461)
found -6.58 (+-0.000169896) 46.5434 (+-0.129759) 7.00007 (+-0.000654532)
found -3.34 (+-0.000169793) 46.5434 (+-0.129749) 7.00007 (+-0.000654481)
found 6.38 (+-0.000169243) 46.5432 (+-0.129698) 7.00004 (+-0.000654223)
found 3.5 (+-0.000183754) 39.8945 (+-0.120155) 6.00008 (+-0.000606088)
found -2.98 (+-0.000183874) 39.8945 (+-0.120163) 6.00008 (+-0.00060613)
found -1.54 (+-0.000184334) 39.8947 (+-0.120202) 6.00011 (+-0.000606326)
found -9.46 (+-0.000202398) 33.2457 (+-0.109763) 5.00011 (+-0.000553668)
found -8.74 (+-0.000202516) 33.2458 (+-0.109772) 5.00012 (+-0.000553711)
found -5.5 (+-0.000202625) 33.2458 (+-0.10978) 5.00013 (+-0.000553752)
found -4.78 (+-0.000201798) 33.2455 (+-0.109721) 5.00009 (+-0.000553456)
found 7.46 (+-0.000201798) 33.2455 (+-0.109721) 5.00009 (+-0.000553456)
found 9.26 (+-0.000202398) 33.2457 (+-0.109763) 5.00012 (+-0.000553668)
found -2.62 (+-0.000202014) 33.2456 (+-0.109735) 5.00009 (+-0.000553529)
found 0.62 (+-0.000200627) 33.2452 (+-0.10964) 5.00004 (+-0.000553047)
found -7.66 (+-0.000225954) 26.5966 (+-0.098158) 4.00009 (+-0.00049513)
found -6.22 (+-0.000226783) 26.5967 (+-0.0982045) 4.00011 (+-0.000495364)
found -4.42 (+-0.000225178) 26.5963 (+-0.098112) 4.00005 (+-0.000494898)
found 0.980001 (+-0.000226423) 26.5966 (+-0.0981839) 4.0001 (+-0.00049526)
found 7.82 (+-0.000224866) 26.5963 (+-0.0980955) 4.00005 (+-0.000494815)
found -3.7 (+-0.000225531) 26.5964 (+-0.0981326) 4.00007 (+-0.000495002)
found -7.3 (+-0.000261427) 19.9475 (+-0.0850284) 3.00007 (+-0.000428901)
found -4.06 (+-0.000260699) 19.9473 (+-0.0849963) 3.00005 (+-0.000428739)
found 3.86 (+-0.000260889) 19.9474 (+-0.0850051) 3.00006 (+-0.000428784)
found 4.94 (+-0.000261641) 19.9476 (+-0.0850397) 3.00009 (+-0.000428958)
found 6.74 (+-0.000262539) 19.9477 (+-0.0850777) 3.00011 (+-0.00042915)
found 4.22 (+-0.000261641) 19.9476 (+-0.0850397) 3.00009 (+-0.000428958)
found 5.3 (+-0.000259658) 19.9472 (+-0.0849527) 3.00003 (+-0.000428519)
found 6.02 (+-0.000260699) 19.9474 (+-0.0849984) 3.00006 (+-0.00042875)
found 8.54 (+-0.000261071) 19.9475 (+-0.0850155) 3.00007 (+-0.000428836)
found 0.259999 (+-0.000322245) 13.2986 (+-0.0694874) 2.00009 (+-0.000350509)
found 5.66 (+-0.000319637) 13.2983 (+-0.0694092) 2.00004 (+-0.000350114)
found 8.18 (+-0.000320093) 13.2983 (+-0.0694225) 2.00005 (+-0.000350182)
found -0.46 (+-0.000461713) 6.64971 (+-0.049231) 1.00011 (+-0.000248331)
#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()