This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 3.98942 1
created -9.1 3.98942 1
created -8.5 27.926 7
created -7.9 23.9365 6
created -7.3 35.9048 9
created -6.7 31.9154 8
created -6.1 23.9365 6
created -5.5 7.97885 2
created -4.9 11.9683 3
created -4.3 35.9048 9
created -3.7 27.926 7
created -3.1 19.9471 5
created -2.5 27.926 7
created -1.9 11.9683 3
created -1.3 11.9683 3
created -0.7 39.8942 10
created -0.1 27.926 7
created 0.5 15.9577 4
created 1.1 7.97885 2
created 1.7 19.9471 5
created 2.3 3.98942 1
created 2.9 3.98942 1
created 3.5 23.9365 6
created 4.1 3.98942 1
created 4.7 7.97885 2
created 5.3 19.9471 5
created 5.9 27.926 7
created 6.5 7.97885 2
created 7.1 3.98942 1
created 7.7 23.9365 6
created 8.3 23.9365 6
created 8.9 19.9471 5
created 9.5 19.9471 5
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-3.7988e-05)
fit chi^2 = 3.48238e-06
found -0.699999 (+-0.000258536) 39.894 (+-0.101839) 10.0001 (+-0.000835744)
found -7.3 (+-0.000273424) 35.9048 (+-0.096652) 9.00018 (+-0.000793173)
found -4.3 (+-0.000272701) 35.9046 (+-0.0966211) 9.00013 (+-0.00079292)
found -6.7 (+-0.00029041) 31.9155 (+-0.0911403) 8.00019 (+-0.000747942)
found -3.7 (+-0.000310586) 27.9261 (+-0.0852585) 7.00018 (+-0.000699673)
found -0.100002 (+-0.000310493) 27.9261 (+-0.0852558) 7.00018 (+-0.000699651)
found -8.5 (+-0.000308724) 27.9258 (+-0.0851973) 7.00009 (+-0.000699171)
found -2.5 (+-0.000309338) 27.9258 (+-0.0852156) 7.0001 (+-0.000699321)
found 5.9 (+-0.000308993) 27.9258 (+-0.0852045) 7.00009 (+-0.00069923)
found -7.9 (+-0.000336359) 23.9369 (+-0.0789608) 6.00021 (+-0.000647991)
found -6.1 (+-0.000334722) 23.9366 (+-0.0789132) 6.00013 (+-0.0006476)
found 3.5 (+-0.000332009) 23.9362 (+-0.0788363) 6.00002 (+-0.00064697)
found 7.7 (+-0.000333764) 23.9364 (+-0.0788861) 6.00009 (+-0.000647378)
found 8.3 (+-0.000335305) 23.9366 (+-0.0789287) 6.00014 (+-0.000647728)
found -3.1 (+-0.000368643) 19.9475 (+-0.0720856) 5.00018 (+-0.00059157)
found 1.7 (+-0.000364616) 19.9469 (+-0.0719879) 5.00004 (+-0.000590768)
found 5.3 (+-0.000366938) 19.9472 (+-0.0720439) 5.00012 (+-0.000591228)
found 8.9 (+-0.000367854) 19.9473 (+-0.0720655) 5.00014 (+-0.000591404)
found 9.5 (+-0.000363982) 19.9472 (+-0.0719833) 5.00013 (+-0.00059073)
found 0.499997 (+-0.000410961) 15.9579 (+-0.0644524) 4.00012 (+-0.000528928)
found -1.9 (+-0.000476437) 11.9686 (+-0.0558461) 3.00013 (+-0.000458301)
found -4.9 (+-0.000476376) 11.9686 (+-0.0558466) 3.00014 (+-0.000458305)
found -1.3 (+-0.000477417) 11.9687 (+-0.0558625) 3.00017 (+-0.000458435)
found 6.49999 (+-0.000583413) 7.97911 (+-0.0455994) 2.00011 (+-0.000374211)
found -5.5 (+-0.000585392) 7.97916 (+-0.045618) 2.00012 (+-0.000374363)
found 1.1 (+-0.000585614) 7.97916 (+-0.04562) 2.00012 (+-0.00037438)
found 4.7 (+-0.000582268) 7.97901 (+-0.0455865) 2.00008 (+-0.000374105)
found 4.09999 (+-0.000832869) 3.98976 (+-0.0322851) 1.0001 (+-0.000264947)
found 2.29999 (+-0.000829092) 3.98966 (+-0.0322649) 1.00008 (+-0.000264782)
found 7.10001 (+-0.000832869) 3.98976 (+-0.0322851) 1.0001 (+-0.000264947)
found -9.09999 (+-0.000831125) 3.98976 (+-0.0322772) 1.0001 (+-0.000264882)
found 2.90001 (+-0.000830167) 3.98971 (+-0.0322713) 1.00009 (+-0.000264834)
found -9.7 (+-0.000819978) 3.9894 (+-0.0322134) 1.00001 (+-0.000264359)
#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()