This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 9.97356 2
created -9.28 24.9339 5
created -8.8 39.8942 8
created -8.32 29.9207 6
created -7.84 49.8678 10
created -7.36 49.8678 10
created -6.88 29.9207 6
created -6.4 49.8678 10
created -5.92 19.9471 4
created -5.44 49.8678 10
created -4.96 9.97356 2
created -4.48 29.9207 6
created -4 34.9074 7
created -3.52 29.9207 6
created -3.04 4.98678 1
created -2.56 9.97356 2
created -2.08 49.8678 10
created -1.6 49.8678 10
created -1.12 24.9339 5
created -0.64 14.9603 3
created -0.16 4.98678 1
created 0.32 24.9339 5
created 0.8 44.881 9
created 1.28 14.9603 3
created 1.76 19.9471 4
created 2.24 14.9603 3
created 2.72 44.881 9
created 3.2 9.97356 2
created 3.68 24.9339 5
created 4.16 29.9207 6
created 4.64 49.8678 10
created 5.12 49.8678 10
created 5.6 14.9603 3
created 6.08 34.9074 7
created 6.56 9.97356 2
created 7.04 49.8678 10
created 7.52 44.881 9
created 8 9.97356 2
created 8.48 14.9603 3
created 8.96 44.881 9
created 9.44 44.881 9
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.87904e-05)
fit chi^2 = 5.07211e-06
found -7.84 (+-0.00024831) 49.8679 (+-0.152373) 10.0002 (+-0.00100904)
found -7.36 (+-0.00024831) 49.8679 (+-0.152373) 10.0002 (+-0.00100904)
found -6.4 (+-0.000247527) 49.8676 (+-0.152314) 10.0001 (+-0.00100865)
found -5.44 (+-0.00024678) 49.8674 (+-0.15226) 10.0001 (+-0.0010083)
found -2.08 (+-0.000247557) 49.8677 (+-0.15232) 10.0001 (+-0.00100869)
found -1.6 (+-0.000248162) 49.8679 (+-0.152362) 10.0002 (+-0.00100897)
found 4.64 (+-0.00024831) 49.8679 (+-0.152373) 10.0002 (+-0.00100904)
found 5.12 (+-0.000247798) 49.8678 (+-0.152336) 10.0001 (+-0.0010088)
found 7.04 (+-0.000247454) 49.8677 (+-0.152311) 10.0001 (+-0.00100863)
found 0.8 (+-0.000260717) 44.8808 (+-0.144485) 9.00008 (+-0.000956803)
found 2.72 (+-0.000260059) 44.8807 (+-0.144442) 9.00005 (+-0.000956522)
found 7.52 (+-0.000261123) 44.881 (+-0.144515) 9.00012 (+-0.000957004)
found 8.96 (+-0.000261275) 44.881 (+-0.144523) 9.00012 (+-0.00095706)
found 9.44 (+-0.000259678) 44.8813 (+-0.144438) 9.00018 (+-0.000956493)
found -8.8 (+-0.000277351) 39.8943 (+-0.13627) 8.00011 (+-0.000902404)
found -4 (+-0.000296989) 34.9076 (+-0.127495) 7.00012 (+-0.000844295)
found 6.08 (+-0.000295267) 34.9072 (+-0.127405) 7.00005 (+-0.000843701)
found -8.32 (+-0.000322307) 29.9212 (+-0.11811) 6.00018 (+-0.000782146)
found -6.88 (+-0.000322645) 29.9213 (+-0.118127) 6.0002 (+-0.000782255)
found -3.52 (+-0.000319674) 29.9207 (+-0.117991) 6.00008 (+-0.000781358)
found -4.48 (+-0.000320201) 29.9207 (+-0.118013) 6.00009 (+-0.000781501)
found 4.16 (+-0.000321676) 29.921 (+-0.11808) 6.00015 (+-0.00078195)
found -1.12 (+-0.000352281) 24.9342 (+-0.10779) 5.00013 (+-0.000713804)
found -9.28 (+-0.000351442) 24.9341 (+-0.107757) 5.0001 (+-0.000713587)
found 0.320002 (+-0.00035102) 24.9341 (+-0.107744) 5.0001 (+-0.0007135)
found 3.68 (+-0.000350984) 24.934 (+-0.107738) 5.00008 (+-0.000713463)
found -5.92 (+-0.00039684) 19.9479 (+-0.0965061) 4.0002 (+-0.000639081)
found 1.76 (+-0.000392486) 19.9472 (+-0.0963651) 4.00006 (+-0.000638147)
found 1.28 (+-0.000457255) 14.9608 (+-0.0835532) 3.00013 (+-0.000553304)
found 5.6 (+-0.000458831) 14.961 (+-0.0835924) 3.00017 (+-0.000553564)
found -0.640002 (+-0.000453566) 14.9604 (+-0.0834656) 3.00006 (+-0.000552724)
found 2.24 (+-0.000457255) 14.9608 (+-0.0835532) 3.00013 (+-0.000553304)
found 8.48 (+-0.000455977) 14.9607 (+-0.0835237) 3.00011 (+-0.000553109)
found -4.96 (+-0.000564265) 9.97424 (+-0.0682935) 2.00016 (+-0.000452252)
found 3.2 (+-0.000563257) 9.97414 (+-0.0682759) 2.00014 (+-0.000452136)
found 8 (+-0.000561764) 9.97404 (+-0.0682514) 2.00012 (+-0.000451973)
found 6.56 (+-0.0005648) 9.97429 (+-0.0683028) 2.00017 (+-0.000452313)
found -9.76 (+-0.000557384) 9.97368 (+-0.0681738) 2.00005 (+-0.000451459)
found -2.55999 (+-0.000559733) 9.97399 (+-0.0682218) 2.00011 (+-0.000451777)
found -3.04001 (+-0.000797214) 4.98712 (+-0.0482852) 1.00008 (+-0.000319753)
found -0.159997 (+-0.00079799) 4.98712 (+-0.0482908) 1.00008 (+-0.00031979)
#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++) {
}
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++) {
}
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()