This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 23.9365 6
created -9.1 27.926 7
created -8.5 7.97885 2
created -7.9 35.9048 9
created -7.3 3.98942 1
created -6.7 35.9048 9
created -6.1 11.9683 3
created -5.5 35.9048 9
created -4.9 31.9154 8
created -4.3 11.9683 3
created -3.7 39.8942 10
created -3.1 19.9471 5
created -2.5 7.97885 2
created -1.9 15.9577 4
created -1.3 3.98942 1
created -0.7 19.9471 5
created -0.1 7.97885 2
created 0.5 15.9577 4
created 1.1 31.9154 8
created 1.7 15.9577 4
created 2.3 35.9048 9
created 2.9 19.9471 5
created 3.5 39.8942 10
created 4.1 19.9471 5
created 4.7 7.97885 2
created 5.3 7.97885 2
created 5.9 11.9683 3
created 6.5 15.9577 4
created 7.1 3.98942 1
created 7.7 11.9683 3
created 8.3 35.9048 9
created 8.9 31.9154 8
created 9.5 39.8942 10
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-5.03387e-05)
fit chi^2 = 6.90783e-06
found -3.7 (+-0.000363718) 39.8939 (+-0.143413) 10.0001 (+-0.00117692)
found 3.5 (+-0.00036425) 39.894 (+-0.143438) 10.0001 (+-0.00117712)
found 9.5 (+-0.000362182) 39.8944 (+-0.143361) 10.0002 (+-0.00117649)
found -7.9 (+-0.000381747) 35.9043 (+-0.135988) 9.00004 (+-0.00111598)
found -6.7 (+-0.000382131) 35.9043 (+-0.136003) 9.00005 (+-0.00111611)
found -5.5 (+-0.000384271) 35.9047 (+-0.136092) 9.00014 (+-0.00111684)
found 2.3 (+-0.000383944) 35.9046 (+-0.136077) 9.00012 (+-0.00111671)
found 8.3 (+-0.000384271) 35.9047 (+-0.136092) 9.00014 (+-0.00111684)
found -4.9 (+-0.000408103) 31.9154 (+-0.128329) 8.00015 (+-0.00105313)
found 8.9 (+-0.000409863) 31.9158 (+-0.128398) 8.00025 (+-0.00105369)
found 1.1 (+-0.000407244) 31.9152 (+-0.128295) 8.0001 (+-0.00105285)
found -9.1 (+-0.000435486) 27.9259 (+-0.120014) 7.0001 (+-0.000984895)
found -9.7 (+-0.000471779) 23.9365 (+-0.111143) 6.00009 (+-0.000912091)
found -3.1 (+-0.000517695) 19.9474 (+-0.101492) 5.00016 (+-0.000832893)
found 2.9 (+-0.000520737) 19.9477 (+-0.101567) 5.00025 (+-0.00083351)
found 4.1 (+-0.000517695) 19.9474 (+-0.101492) 5.00016 (+-0.000832893)
found -0.7 (+-0.000513533) 19.9469 (+-0.101389) 5.00004 (+-0.00083205)
found 1.7 (+-0.000582879) 15.9583 (+-0.090859) 4.00022 (+-0.000745633)
found -1.9 (+-0.000574827) 15.9575 (+-0.0906978) 4.00004 (+-0.00074431)
found 0.500003 (+-0.000579195) 15.9579 (+-0.0907846) 4.00013 (+-0.000745022)
found 6.5 (+-0.000575616) 15.9576 (+-0.0907131) 4.00005 (+-0.000744436)
found -6.1 (+-0.000675674) 11.969 (+-0.0787291) 3.00023 (+-0.000646089)
found -4.3 (+-0.00067564) 11.969 (+-0.0787286) 3.00023 (+-0.000646085)
found 5.9 (+-0.000668139) 11.9684 (+-0.0786101) 3.00008 (+-0.000645113)
found 7.70001 (+-0.000669483) 11.9686 (+-0.0786355) 3.00013 (+-0.000645321)
found -8.5 (+-0.000830449) 7.97953 (+-0.0643149) 2.00021 (+-0.000527799)
found -2.5 (+-0.000824792) 7.97916 (+-0.0642522) 2.00012 (+-0.000527285)
found -0.100001 (+-0.000824792) 7.97916 (+-0.0642522) 2.00012 (+-0.000527285)
found 4.7 (+-0.000822145) 7.97906 (+-0.0642249) 2.00009 (+-0.000527061)
found 5.3 (+-0.000820002) 7.97896 (+-0.0642019) 2.00007 (+-0.000526872)
found -7.3 (+-0.00118883) 3.99028 (+-0.0455623) 1.00023 (+-0.000373906)
found -1.3 (+-0.00117629) 3.98982 (+-0.0454881) 1.00012 (+-0.000373298)
found 7.1 (+-0.0011724) 3.98971 (+-0.0454661) 1.00009 (+-0.000373117)
#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()