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 9.97356 2
created -8.8 14.9603 3
created -8.32 44.881 9
created -7.84 34.9074 7
created -7.36 29.9207 6
created -6.88 49.8678 10
created -6.4 49.8678 10
created -5.92 29.9207 6
created -5.44 44.881 9
created -4.96 9.97356 2
created -4.48 44.881 9
created -4 24.9339 5
created -3.52 44.881 9
created -3.04 49.8678 10
created -2.56 4.98678 1
created -2.08 49.8678 10
created -1.6 19.9471 4
created -1.12 34.9074 7
created -0.64 34.9074 7
created -0.16 39.8942 8
created 0.32 34.9074 7
created 0.8 39.8942 8
created 1.28 19.9471 4
created 1.76 49.8678 10
created 2.24 4.98678 1
created 2.72 9.97356 2
created 3.2 4.98678 1
created 3.68 9.97356 2
created 4.16 24.9339 5
created 4.64 44.881 9
created 5.12 39.8942 8
created 5.6 34.9074 7
created 6.08 39.8942 8
created 6.56 44.881 9
created 7.04 9.97356 2
created 7.52 9.97356 2
created 8 39.8942 8
created 8.48 14.9603 3
created 8.96 44.881 9
created 9.44 24.9339 5
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.15411e-05)
fit chi^2 = 2.86239e-06
found -6.88 (+-0.000186537) 49.8679 (+-0.114467) 10.0002 (+-0.000758018)
found -6.4 (+-0.000186537) 49.8679 (+-0.114467) 10.0002 (+-0.000758018)
found -3.04 (+-0.000185645) 49.8676 (+-0.114404) 10.0001 (+-0.000757604)
found -2.08 (+-0.000185141) 49.8674 (+-0.114366) 10 (+-0.00075735)
found 1.76 (+-0.000185141) 49.8674 (+-0.114366) 10 (+-0.00075735)
found -8.32 (+-0.000196086) 44.8809 (+-0.108556) 9.0001 (+-0.000718879)
found -5.44 (+-0.000195779) 44.8808 (+-0.108536) 9.00008 (+-0.000718747)
found -4.48 (+-0.000195659) 44.8808 (+-0.108528) 9.00007 (+-0.000718693)
found -3.52 (+-0.000196662) 44.8812 (+-0.108595) 9.00015 (+-0.000719138)
found 4.64 (+-0.000196485) 44.8811 (+-0.108583) 9.00013 (+-0.000719054)
found 6.56 (+-0.000195986) 44.8809 (+-0.108551) 9.0001 (+-0.000718842)
found 8.96 (+-0.000195857) 44.8808 (+-0.10854) 9.00008 (+-0.000718775)
found -0.16 (+-0.00020873) 39.8944 (+-0.102392) 8.00014 (+-0.000678062)
found 0.8 (+-0.00020832) 39.8942 (+-0.102368) 8.00011 (+-0.000677898)
found 5.12 (+-0.000208942) 39.8945 (+-0.102406) 8.00016 (+-0.00067815)
found 6.08 (+-0.000208942) 39.8945 (+-0.102406) 8.00016 (+-0.00067815)
found 8 (+-0.000207338) 39.8939 (+-0.10231) 8.00005 (+-0.000677514)
found -7.84 (+-0.00022348) 34.9077 (+-0.0957982) 7.00015 (+-0.000634393)
found -1.12 (+-0.000222918) 34.9075 (+-0.0957677) 7.00011 (+-0.000634191)
found -0.64 (+-0.000223503) 34.9077 (+-0.0957992) 7.00015 (+-0.0006344)
found 0.32 (+-0.000223627) 34.9078 (+-0.0958061) 7.00016 (+-0.000634445)
found 5.6 (+-0.000223627) 34.9078 (+-0.0958061) 7.00016 (+-0.000634445)
found -7.36 (+-0.000241982) 29.9211 (+-0.0887204) 6.00017 (+-0.000587523)
found -5.92 (+-0.000242257) 29.9212 (+-0.0887336) 6.00019 (+-0.00058761)
found -4 (+-0.000265715) 24.9345 (+-0.0810161) 5.00018 (+-0.000536504)
found 9.44 (+-0.000262404) 24.9343 (+-0.0809033) 5.00014 (+-0.000535757)
found 4.16 (+-0.000264164) 24.9341 (+-0.0809562) 5.00011 (+-0.000536107)
found -1.6 (+-0.000297554) 19.9477 (+-0.072479) 4.00017 (+-0.000479969)
found 1.28 (+-0.000297757) 19.9478 (+-0.0724857) 4.00018 (+-0.000480014)
found 8.48 (+-0.000344724) 14.961 (+-0.0627975) 3.00017 (+-0.000415857)
found -8.8 (+-0.000342542) 14.9607 (+-0.0627451) 3.00011 (+-0.000415509)
found -4.96 (+-0.000424682) 9.97434 (+-0.0513175) 2.00018 (+-0.000339834)
found 7.04 (+-0.000421252) 9.97399 (+-0.0512603) 2.00011 (+-0.000339455)
found -9.76 (+-0.000416897) 9.97353 (+-0.0511836) 2.00002 (+-0.000338947)
found -9.28 (+-0.000418644) 9.97368 (+-0.051215) 2.00005 (+-0.000339155)
found 2.72 (+-0.000415827) 9.97353 (+-0.0511715) 2.00002 (+-0.000338867)
found 3.68 (+-0.000418684) 9.97373 (+-0.0512176) 2.00006 (+-0.000339172)
found 7.52 (+-0.000420925) 9.97394 (+-0.0512543) 2.0001 (+-0.000339415)
found -2.56 (+-0.000608071) 4.98773 (+-0.0363564) 1.00021 (+-0.000240758)
found 2.23999 (+-0.000601327) 4.98733 (+-0.0362965) 1.00012 (+-0.000240362)
found 3.2 (+-0.000594797) 4.98692 (+-0.0362368) 1.00004 (+-0.000239967)
#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()