This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 31.9154 8
created -9.1 15.9577 4
created -8.5 15.9577 4
created -7.9 31.9154 8
created -7.3 11.9683 3
created -6.7 7.97885 2
created -6.1 31.9154 8
created -5.5 3.98942 1
created -4.9 15.9577 4
created -4.3 7.97885 2
created -3.7 27.926 7
created -3.1 19.9471 5
created -2.5 27.926 7
created -1.9 3.98942 1
created -1.3 39.8942 10
created -0.7 31.9154 8
created -0.1 39.8942 10
created 0.5 35.9048 9
created 1.1 15.9577 4
created 1.7 15.9577 4
created 2.3 23.9365 6
created 2.9 27.926 7
created 3.5 27.926 7
created 4.1 39.8942 10
created 4.7 31.9154 8
created 5.3 11.9683 3
created 5.9 3.98942 1
created 6.5 11.9683 3
created 7.1 27.926 7
created 7.7 11.9683 3
created 8.3 27.926 7
created 8.9 35.9048 9
created 9.5 27.926 7
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.06411e-05)
fit chi^2 = 4.86366e-06
found -1.3 (+-0.00030498) 39.8939 (+-0.120331) 10.0001 (+-0.000987494)
found -0.0999998 (+-0.000306768) 39.8943 (+-0.120412) 10.0002 (+-0.000988164)
found 4.1 (+-0.00030648) 39.8942 (+-0.120398) 10.0002 (+-0.000988047)
found 0.499999 (+-0.000322996) 35.9048 (+-0.114218) 9.00018 (+-0.00093733)
found 8.9 (+-0.000323148) 35.9049 (+-0.114224) 9.00018 (+-0.000937376)
found -0.7 (+-0.00034407) 31.9158 (+-0.107744) 8.00026 (+-0.000884202)
found 4.7 (+-0.000342591) 31.9154 (+-0.107687) 8.00017 (+-0.000883731)
found -9.7 (+-0.000341761) 31.915 (+-0.107644) 8.00005 (+-0.000883381)
found -7.9 (+-0.000341423) 31.9151 (+-0.10764) 8.00009 (+-0.000883349)
found -6.1 (+-0.000339917) 31.9149 (+-0.107586) 8.00004 (+-0.000882906)
found 9.5 (+-0.000363927) 27.9262 (+-0.10067) 7.0002 (+-0.000826146)
found -3.7 (+-0.000365167) 27.9258 (+-0.100695) 7.00009 (+-0.00082635)
found -2.5 (+-0.000364604) 27.9257 (+-0.100678) 7.00008 (+-0.000826209)
found 2.9 (+-0.000366908) 27.9261 (+-0.100753) 7.00017 (+-0.000826829)
found 3.5 (+-0.0003677) 27.9263 (+-0.100781) 7.00022 (+-0.00082706)
found 7.1 (+-0.000364966) 27.9257 (+-0.100687) 7.00008 (+-0.000826289)
found 8.3 (+-0.000366433) 27.9261 (+-0.100738) 7.00016 (+-0.000826705)
found 2.3 (+-0.000396194) 23.9367 (+-0.0932762) 6.00014 (+-0.00076547)
found -3.1 (+-0.000435662) 19.9475 (+-0.0851907) 5.00018 (+-0.000699117)
found -9.1 (+-0.00048722) 15.958 (+-0.0762003) 4.00016 (+-0.000625337)
found 1.1 (+-0.000487522) 15.9581 (+-0.0762069) 4.00017 (+-0.000625391)
found -8.5 (+-0.00048722) 15.958 (+-0.0762003) 4.00016 (+-0.000625337)
found -4.9 (+-0.000482334) 15.9575 (+-0.076104) 4.00004 (+-0.000624547)
found 1.7 (+-0.000486531) 15.9579 (+-0.0761857) 4.00013 (+-0.000625217)
found -7.3 (+-0.000562598) 11.9686 (+-0.0659931) 3.00013 (+-0.000541571)
found 5.3 (+-0.00056138) 11.9685 (+-0.0659762) 3.00012 (+-0.000541433)
found 7.7 (+-0.000565329) 11.9688 (+-0.0660344) 3.00018 (+-0.000541911)
found 6.5 (+-0.000560967) 11.9685 (+-0.0659693) 3.0001 (+-0.000541376)
found -6.69999 (+-0.000693049) 7.97927 (+-0.0539253) 2.00014 (+-0.000442537)
found -4.3 (+-0.000693455) 7.97927 (+-0.053929) 2.00014 (+-0.000442567)
found -5.50001 (+-0.000990524) 3.98997 (+-0.0381897) 1.00016 (+-0.000313403)
found -1.89999 (+-0.000996394) 3.99023 (+-0.0382243) 1.00022 (+-0.000313687)
found 5.9 (+-0.000981993) 3.98966 (+-0.0381404) 1.00008 (+-0.000312999)
#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()