This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 7.97885 2
created -9.1 11.9683 3
created -8.5 39.8942 10
created -7.9 19.9471 5
created -7.3 23.9365 6
created -6.7 19.9471 5
created -6.1 35.9048 9
created -5.5 3.98942 1
created -4.9 35.9048 9
created -4.3 15.9577 4
created -3.7 23.9365 6
created -3.1 35.9048 9
created -2.5 3.98942 1
created -1.9 11.9683 3
created -1.3 3.98942 1
created -0.7 39.8942 10
created -0.1 31.9154 8
created 0.5 27.926 7
created 1.1 39.8942 10
created 1.7 11.9683 3
created 2.3 15.9577 4
created 2.9 27.926 7
created 3.5 11.9683 3
created 4.1 3.98942 1
created 4.7 11.9683 3
created 5.3 15.9577 4
created 5.9 39.8942 10
created 6.5 35.9048 9
created 7.1 39.8942 10
created 7.7 39.8942 10
created 8.3 11.9683 3
created 8.9 11.9683 3
created 9.5 31.9154 8
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.34341e-05)
fit chi^2 = 5.56424e-06
found -8.5 (+-0.000326436) 39.8939 (+-0.128713) 10.0001 (+-0.00105628)
found -0.699998 (+-0.000326207) 39.8939 (+-0.128706) 10.0001 (+-0.00105622)
found 1.1 (+-0.000326803) 39.894 (+-0.12873) 10.0001 (+-0.00105642)
found 5.9 (+-0.000327367) 39.8941 (+-0.128757) 10.0002 (+-0.00105665)
found 7.1 (+-0.000328405) 39.8944 (+-0.128807) 10.0002 (+-0.00105706)
found 7.7 (+-0.000327244) 39.8941 (+-0.128752) 10.0002 (+-0.00105661)
found -6.1 (+-0.000343478) 35.9044 (+-0.122084) 9.00008 (+-0.00100188)
found -4.9 (+-0.00034324) 35.9044 (+-0.122074) 9.00006 (+-0.0010018)
found -3.1 (+-0.000343689) 35.9045 (+-0.122093) 9.00009 (+-0.00100196)
found 6.5 (+-0.000346618) 35.9052 (+-0.122218) 9.00026 (+-0.00100298)
found -0.100001 (+-0.000367474) 31.9157 (+-0.115221) 8.00022 (+-0.000945563)
found 9.5 (+-0.00036254) 31.9153 (+-0.115048) 8.00014 (+-0.000944139)
found 0.500001 (+-0.000393511) 27.9264 (+-0.107803) 7.00023 (+-0.000884686)
found 2.9 (+-0.000390719) 27.9258 (+-0.107707) 7.00009 (+-0.000883894)
found -7.3 (+-0.00042354) 23.9366 (+-0.0997609) 6.00013 (+-0.000818687)
found -3.7 (+-0.000424246) 23.9368 (+-0.099783) 6.00017 (+-0.000818868)
found -7.9 (+-0.000466473) 19.9476 (+-0.0911331) 5.00021 (+-0.000747883)
found -6.7 (+-0.000466223) 19.9475 (+-0.0911265) 5.00019 (+-0.000747828)
found -4.3 (+-0.000522385) 15.9582 (+-0.0815298) 4.00019 (+-0.000669073)
found 2.3 (+-0.000520198) 15.9579 (+-0.0814849) 4.00013 (+-0.000668705)
found 5.3 (+-0.000521169) 15.9581 (+-0.081506) 4.00017 (+-0.000668878)
found 1.7 (+-0.000604232) 11.9688 (+-0.0706245) 3.00018 (+-0.000579579)
found 3.5 (+-0.00060001) 11.9685 (+-0.0705607) 3.0001 (+-0.000579056)
found 8.3 (+-0.000603479) 11.9687 (+-0.0706131) 3.00017 (+-0.000579486)
found -9.09999 (+-0.000602543) 11.9687 (+-0.0705995) 3.00016 (+-0.000579374)
found -1.9 (+-0.00059545) 11.9682 (+-0.0704913) 3.00003 (+-0.000578486)
found 4.7 (+-0.000598362) 11.9683 (+-0.0705341) 3.00007 (+-0.000578838)
found 8.9 (+-0.000602687) 11.9686 (+-0.0705998) 3.00014 (+-0.000579376)
found -9.7 (+-0.000734206) 7.97885 (+-0.0575992) 2.00004 (+-0.000472688)
found -5.5 (+-0.00106697) 3.99028 (+-0.0408919) 1.00023 (+-0.000335579)
found -2.50001 (+-0.00105856) 3.98997 (+-0.0408434) 1.00016 (+-0.000335181)
found -1.29998 (+-0.0010595) 3.99003 (+-0.0408493) 1.00017 (+-0.000335229)
found 4.1 (+-0.00105034) 3.98966 (+-0.040795) 1.00008 (+-0.000334783)
#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()