This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 49.8678 10
created -9.28 24.9339 5
created -8.8 14.9603 3
created -8.32 24.9339 5
created -7.84 49.8678 10
created -7.36 19.9471 4
created -6.88 14.9603 3
created -6.4 49.8678 10
created -5.92 24.9339 5
created -5.44 19.9471 4
created -4.96 44.881 9
created -4.48 34.9074 7
created -4 4.98678 1
created -3.52 19.9471 4
created -3.04 39.8942 8
created -2.56 29.9207 6
created -2.08 39.8942 8
created -1.6 24.9339 5
created -1.12 9.97356 2
created -0.64 34.9074 7
created -0.16 9.97356 2
created 0.32 34.9074 7
created 0.8 34.9074 7
created 1.28 19.9471 4
created 1.76 44.881 9
created 2.24 24.9339 5
created 2.72 44.881 9
created 3.2 19.9471 4
created 3.68 4.98678 1
created 4.16 4.98678 1
created 4.64 49.8678 10
created 5.12 4.98678 1
created 5.6 19.9471 4
created 6.08 19.9471 4
created 6.56 9.97356 2
created 7.04 34.9074 7
created 7.52 4.98678 1
created 8 39.8942 8
created 8.48 19.9471 4
created 8.96 44.881 9
created 9.44 49.8678 10
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.080001 (+-3.16278e-05)
fit chi^2 = 5.63639e-06
found -9.76 (+-0.000260976) 49.8674 (+-0.160553) 10.0001 (+-0.00106321)
found -7.84 (+-0.000260778) 49.8676 (+-0.160552) 10.0001 (+-0.0010632)
found -6.4 (+-0.000260573) 49.8675 (+-0.160537) 10.0001 (+-0.0010631)
found 4.64 (+-0.000259004) 49.8672 (+-0.160429) 10 (+-0.00106239)
found 9.44 (+-0.000259587) 49.8681 (+-0.160488) 10.0002 (+-0.00106278)
found -4.96 (+-0.000275385) 44.881 (+-0.152346) 9.00011 (+-0.00100887)
found 1.76 (+-0.000275063) 44.8809 (+-0.152324) 9.00009 (+-0.00100872)
found 2.72 (+-0.000275063) 44.8809 (+-0.152324) 9.00009 (+-0.00100872)
found 8.96 (+-0.000275773) 44.8811 (+-0.152374) 9.00014 (+-0.00100905)
found -3.04 (+-0.000292157) 39.8942 (+-0.143637) 8.0001 (+-0.000951193)
found -2.08 (+-0.000292372) 39.8943 (+-0.14365) 8.00011 (+-0.000951277)
found 8 (+-0.000290772) 39.894 (+-0.143558) 8.00005 (+-0.00095067)
found -4.48 (+-0.000312024) 34.9075 (+-0.13435) 7.0001 (+-0.000889692)
found -0.64 (+-0.000310913) 34.9072 (+-0.134288) 7.00004 (+-0.00088928)
found 0.320001 (+-0.000312177) 34.9075 (+-0.134354) 7.00009 (+-0.000889719)
found 0.799999 (+-0.00031281) 34.9076 (+-0.134386) 7.00011 (+-0.000889931)
found 7.04 (+-0.000310436) 34.9071 (+-0.134265) 7.00003 (+-0.000889129)
found -2.56 (+-0.000339408) 29.9211 (+-0.124489) 6.00016 (+-0.000824392)
found -9.28 (+-0.000371361) 24.9342 (+-0.113628) 5.00013 (+-0.000752463)
found -5.92 (+-0.000371744) 24.9343 (+-0.113642) 5.00014 (+-0.000752558)
found -1.6 (+-0.000370476) 24.9341 (+-0.113593) 5.0001 (+-0.000752235)
found 2.24 (+-0.000372866) 24.9345 (+-0.113686) 5.00018 (+-0.00075285)
found -8.32 (+-0.000371361) 24.9342 (+-0.113628) 5.00013 (+-0.000752463)
found -7.36 (+-0.000416019) 19.9475 (+-0.101658) 4.00013 (+-0.0006732)
found 1.28 (+-0.000417302) 19.9477 (+-0.101698) 4.00016 (+-0.000673464)
found 3.2 (+-0.000414396) 19.9474 (+-0.10161) 4.0001 (+-0.000672882)
found 8.48 (+-0.000417586) 19.9477 (+-0.101708) 4.00017 (+-0.000673526)
found -5.44 (+-0.000416643) 19.9476 (+-0.101677) 4.00014 (+-0.000673323)
found -3.52 (+-0.000414141) 19.9473 (+-0.101602) 4.00009 (+-0.000672824)
found 5.6 (+-0.000412834) 19.9471 (+-0.101559) 4.00005 (+-0.000672539)
found 6.08 (+-0.00041363) 19.9472 (+-0.101581) 4.00006 (+-0.000672689)
found -8.8 (+-0.000481001) 14.9607 (+-0.0880519) 3.0001 (+-0.000583095)
found -6.88 (+-0.000482325) 14.9609 (+-0.0880864) 3.00014 (+-0.000583324)
found -1.12 (+-0.000592792) 9.97404 (+-0.0719564) 2.00012 (+-0.000476508)
found -0.16 (+-0.00059398) 9.97414 (+-0.0719769) 2.00014 (+-0.000476644)
found 6.56 (+-0.000592075) 9.97399 (+-0.0719444) 2.00011 (+-0.000476429)
found 5.11999 (+-0.000847306) 4.98743 (+-0.0509625) 1.00014 (+-0.000337483)
found 7.52 (+-0.000849155) 4.98748 (+-0.0509782) 1.00015 (+-0.000337587)
found -4 (+-0.000844832) 4.98728 (+-0.0509388) 1.00011 (+-0.000337326)
found 3.68 (+-0.000835325) 4.98697 (+-0.0508571) 1.00005 (+-0.000336785)
found 4.16001 (+-0.000841051) 4.98728 (+-0.0509115) 1.00011 (+-0.000337145)
#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()