This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 4.98678 1
created -9.28 24.9339 5
created -8.8 9.97356 2
created -8.32 9.97356 2
created -7.84 19.9471 4
created -7.36 24.9339 5
created -6.88 4.98678 1
created -6.4 39.8942 8
created -5.92 19.9471 4
created -5.44 24.9339 5
created -4.96 29.9207 6
created -4.48 49.8678 10
created -4 34.9074 7
created -3.52 4.98678 1
created -3.04 24.9339 5
created -2.56 9.97356 2
created -2.08 29.9207 6
created -1.6 14.9603 3
created -1.12 34.9074 7
created -0.64 24.9339 5
created -0.16 14.9603 3
created 0.32 34.9074 7
created 0.8 14.9603 3
created 1.28 39.8942 8
created 1.76 9.97356 2
created 2.24 9.97356 2
created 2.72 4.98678 1
created 3.2 34.9074 7
created 3.68 34.9074 7
created 4.16 29.9207 6
created 4.64 29.9207 6
created 5.12 14.9603 3
created 5.6 49.8678 10
created 6.08 9.97356 2
created 6.56 44.881 9
created 7.04 9.97356 2
created 7.52 24.9339 5
created 8 29.9207 6
created 8.48 9.97356 2
created 8.96 44.881 9
created 9.44 34.9074 7
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.8383e-05)
fit chi^2 = 3.96103e-06
found -4.48 (+-0.000219137) 49.8678 (+-0.134631) 10.0001 (+-0.000891548)
found 5.6 (+-0.000217911) 49.8674 (+-0.134542) 10 (+-0.00089096)
found 6.56 (+-0.000229585) 44.8806 (+-0.12763) 9.00004 (+-0.000845191)
found 8.96 (+-0.000230434) 44.8809 (+-0.127686) 9.00009 (+-0.000845562)
found -6.4 (+-0.000243757) 39.8939 (+-0.120346) 8.00005 (+-0.000796954)
found 1.28 (+-0.000243904) 39.8939 (+-0.120353) 8.00005 (+-0.000797)
found -4 (+-0.000261696) 34.9075 (+-0.112634) 7.00011 (+-0.000745883)
found -1.12 (+-0.000261658) 34.9074 (+-0.112627) 7.00008 (+-0.000745834)
found 0.32 (+-0.000261222) 34.9073 (+-0.112604) 7.00006 (+-0.000745683)
found 3.2 (+-0.000261296) 34.9074 (+-0.112611) 7.00008 (+-0.000745732)
found 3.68 (+-0.000262612) 34.9076 (+-0.112677) 7.00013 (+-0.00074617)
found 9.44 (+-0.000260478) 34.9078 (+-0.112584) 7.00016 (+-0.000745554)
found 4.16 (+-0.00028401) 29.9209 (+-0.104336) 6.00013 (+-0.00069093)
found 4.64 (+-0.00028312) 29.9207 (+-0.104295) 6.00009 (+-0.000690659)
found -4.96 (+-0.000284268) 29.921 (+-0.104349) 6.00015 (+-0.000691017)
found -2.08 (+-0.000282084) 29.9205 (+-0.104248) 6.00005 (+-0.00069035)
found 8 (+-0.000282582) 29.9206 (+-0.104271) 6.00007 (+-0.0006905)
found -0.640001 (+-0.000310777) 24.9341 (+-0.0952326) 5.0001 (+-0.000630647)
found -9.28 (+-0.000308415) 24.9337 (+-0.0951441) 5.00003 (+-0.000630061)
found -7.36 (+-0.000309118) 24.9338 (+-0.0951705) 5.00005 (+-0.000630236)
found -5.44 (+-0.000310883) 24.9341 (+-0.0952361) 5.0001 (+-0.00063067)
found -3.04 (+-0.000308415) 24.9337 (+-0.0951441) 5.00003 (+-0.000630061)
found 7.52 (+-0.000310168) 24.934 (+-0.0952095) 5.00008 (+-0.000630495)
found -5.92 (+-0.000349058) 19.9475 (+-0.0852293) 4.00013 (+-0.000564404)
found -7.84 (+-0.000347075) 19.9472 (+-0.0851668) 4.00007 (+-0.00056399)
found -1.6 (+-0.000404301) 14.9608 (+-0.0738414) 3.00013 (+-0.000488991)
found -0.159999 (+-0.000403929) 14.9607 (+-0.0738322) 3.00012 (+-0.00048893)
found 0.8 (+-0.000404937) 14.9609 (+-0.0738575) 3.00015 (+-0.000489097)
found 5.12 (+-0.000405138) 14.961 (+-0.073863) 3.00016 (+-0.000489134)
found 6.08 (+-0.000499943) 9.97439 (+-0.0603743) 2.00019 (+-0.00039981)
found 7.04 (+-0.000497756) 9.97414 (+-0.0603361) 2.00014 (+-0.000399557)
found -8.8 (+-0.000493764) 9.97378 (+-0.0602688) 2.00007 (+-0.000399111)
found -2.56 (+-0.000496476) 9.97398 (+-0.0603135) 2.00011 (+-0.000399407)
found 1.76 (+-0.000495159) 9.97393 (+-0.0602934) 2.0001 (+-0.000399274)
found 8.48 (+-0.000498284) 9.97419 (+-0.0603451) 2.00015 (+-0.000399616)
found -8.32 (+-0.000493173) 9.97373 (+-0.0602588) 2.00006 (+-0.000399045)
found 2.24 (+-0.000490377) 9.97358 (+-0.0602146) 2.00003 (+-0.000398752)
found -6.88 (+-0.000710066) 4.98738 (+-0.0427191) 1.00013 (+-0.000282894)
found -3.52 (+-0.000709312) 4.98733 (+-0.042712) 1.00012 (+-0.000282847)
found 2.72001 (+-0.000705326) 4.98717 (+-0.0426778) 1.00009 (+-0.00028262)
found -9.75999 (+-0.000699591) 4.98697 (+-0.0426272) 1.00005 (+-0.000282285)
#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;
}
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()