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 6.64904 1
created -9.1 53.1923 8
created -8.74 26.5962 4
created -8.38 66.4904 10
created -8.02 66.4904 10
created -7.66 33.2452 5
created -7.3 46.5433 7
created -6.94 6.64904 1
created -6.58 39.8942 6
created -6.22 59.8413 9
created -5.86 53.1923 8
created -5.5 66.4904 10
created -5.14 46.5433 7
created -4.78 6.64904 1
created -4.42 6.64904 1
created -4.06 39.8942 6
created -3.7 33.2452 5
created -3.34 6.64904 1
created -2.98 66.4904 10
created -2.62 53.1923 8
created -2.26 66.4904 10
created -1.9 6.64904 1
created -1.54 46.5433 7
created -1.18 26.5962 4
created -0.82 13.2981 2
created -0.46 33.2452 5
created -0.1 59.8413 9
created 0.26 13.2981 2
created 0.62 46.5433 7
created 0.98 6.64904 1
created 1.34 33.2452 5
created 1.7 13.2981 2
created 2.06 19.9471 3
created 2.42 6.64904 1
created 2.78 6.64904 1
created 3.14 39.8942 6
created 3.5 13.2981 2
created 3.86 13.2981 2
created 4.22 59.8413 9
created 4.58 13.2981 2
created 4.94 13.2981 2
created 5.3 66.4904 10
created 5.66 39.8942 6
created 6.02 26.5962 4
created 6.38 39.8942 6
created 6.74 39.8942 6
created 7.1 59.8413 9
created 7.46 13.2981 2
created 7.82 66.4904 10
created 8.18 39.8942 6
created 8.54 53.1923 8
created 8.9 33.2452 5
created 9.26 59.8413 9
created 9.62 46.5433 7
the total number of created peaks = 55 with sigma = 0.06
the total number of found peaks = 55 with sigma = 0.0600004 (+-1.40939e-05)
fit chi^2 = 2.68563e-06
found -8.38 (+-0.00013326) 66.4905 (+-0.145539) 10.0001 (+-0.000734129)
found -8.02 (+-0.00013335) 66.4906 (+-0.145551) 10.0001 (+-0.000734188)
found -5.5 (+-0.000133385) 66.4906 (+-0.145555) 10.0001 (+-0.000734208)
found -2.98 (+-0.000132732) 66.4903 (+-0.145473) 10.0001 (+-0.000733797)
found -2.26 (+-0.000132732) 66.4903 (+-0.145473) 10.0001 (+-0.000733797)
found 5.3 (+-0.000132775) 66.4903 (+-0.145475) 10.0001 (+-0.000733808)
found 7.82 (+-0.000132775) 66.4903 (+-0.145475) 10.0001 (+-0.000733808)
found -6.22 (+-0.000140632) 59.8416 (+-0.138089) 9.00009 (+-0.000696551)
found -0.1 (+-0.000139955) 59.8412 (+-0.138009) 9.00005 (+-0.000696148)
found 4.22 (+-0.000139602) 59.8411 (+-0.137969) 9.00002 (+-0.000695944)
found 7.1 (+-0.00014004) 59.8413 (+-0.13802) 9.00005 (+-0.000696201)
found 9.26 (+-0.000140474) 59.8415 (+-0.13807) 9.00008 (+-0.000696454)
found -5.86 (+-0.000149677) 53.1928 (+-0.130249) 8.00013 (+-0.000657002)
found -2.62 (+-0.000149745) 53.1928 (+-0.130256) 8.00013 (+-0.000657041)
found -9.1 (+-0.000148219) 53.1922 (+-0.130095) 8.00003 (+-0.000656224)
found 8.54 (+-0.000149034) 53.1924 (+-0.130178) 8.00007 (+-0.000656644)
found -5.14 (+-0.000159127) 46.5434 (+-0.121758) 7.00007 (+-0.000614171)
found 9.62 (+-0.000158387) 46.5437 (+-0.121704) 7.00011 (+-0.000613901)
found -7.3 (+-0.000158681) 46.5432 (+-0.121713) 7.00004 (+-0.000613948)
found -1.54 (+-0.00015856) 46.5432 (+-0.121702) 7.00003 (+-0.00061389)
found 0.62 (+-0.000158242) 46.5431 (+-0.121673) 7.00002 (+-0.000613744)
found 5.66 (+-0.000172711) 39.8946 (+-0.11279) 6.00009 (+-0.000568936)
found 8.18 (+-0.000173192) 39.8948 (+-0.11283) 6.00012 (+-0.000569137)
found -6.58 (+-0.000171968) 39.8944 (+-0.112733) 6.00007 (+-0.000568648)
found -4.06 (+-0.000171545) 39.8942 (+-0.112696) 6.00004 (+-0.000568464)
found 3.14 (+-0.000171042) 39.8941 (+-0.112656) 6.00002 (+-0.000568262)
found 6.38 (+-0.000172319) 39.8944 (+-0.112756) 6.00007 (+-0.000568765)
found 6.74 (+-0.000172891) 39.8946 (+-0.112804) 6.0001 (+-0.000569007)
found -7.66 (+-0.000189939) 33.2457 (+-0.103015) 5.00011 (+-0.000519628)
found 8.9 (+-0.000189957) 33.2457 (+-0.103016) 5.00011 (+-0.000519634)
found -9.82 (+-0.000187658) 33.245 (+-0.10285) 5.00001 (+-0.000518799)
found -3.7 (+-0.000188268) 33.2453 (+-0.102901) 5.00005 (+-0.000519055)
found -0.459999 (+-0.000188957) 33.2455 (+-0.102948) 5.00007 (+-0.00051929)
found 1.34 (+-0.000187535) 33.2451 (+-0.102851) 5.00002 (+-0.000518802)
found -8.74 (+-0.000212988) 26.5968 (+-0.0921763) 4.00012 (+-0.000464957)
found -1.18 (+-0.000211374) 26.5964 (+-0.0920848) 4.00006 (+-0.000464495)
found 6.02 (+-0.000212124) 26.5965 (+-0.0921254) 4.00008 (+-0.0004647)
found 2.06 (+-0.000242804) 19.9471 (+-0.0796949) 3.00002 (+-0.000401998)
found 0.259999 (+-0.000303284) 13.2987 (+-0.0652421) 2.00011 (+-0.000329095)
found 4.58 (+-0.000301325) 13.2985 (+-0.0651849) 2.00007 (+-0.000328806)
found 7.46 (+-0.000304006) 13.2988 (+-0.0652648) 2.00013 (+-0.00032921)
found 3.5 (+-0.000300556) 13.2983 (+-0.0651605) 2.00005 (+-0.000328683)
found -0.82 (+-0.00030121) 13.2984 (+-0.0651785) 2.00006 (+-0.000328774)
found 1.7 (+-0.000300779) 13.2983 (+-0.0651659) 2.00005 (+-0.000328711)
found 3.86 (+-0.000301325) 13.2985 (+-0.0651849) 2.00007 (+-0.000328806)
found 4.94 (+-0.000301541) 13.2985 (+-0.065192) 2.00008 (+-0.000328842)
found -1.9 (+-0.000433684) 6.64976 (+-0.0462108) 1.00012 (+-0.000233097)
found -9.46 (+-0.000431779) 6.64958 (+-0.0461794) 1.00009 (+-0.000232939)
found -6.94 (+-0.000431893) 6.64958 (+-0.046181) 1.00009 (+-0.000232947)
found -4.78 (+-0.000427492) 6.64936 (+-0.0461152) 1.00005 (+-0.000232615)
found -3.34 (+-0.00043259) 6.64967 (+-0.0461933) 1.0001 (+-0.000233009)
found 0.979999 (+-0.00043132) 6.64953 (+-0.0461718) 1.00008 (+-0.0002329)
found 2.42 (+-0.00042505) 6.64917 (+-0.0460754) 1.00003 (+-0.000232414)
found -4.42 (+-0.000426998) 6.64931 (+-0.0461069) 1.00005 (+-0.000232573)
found 2.78 (+-0.000426998) 6.64931 (+-0.0461069) 1.00005 (+-0.000232573)
#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()