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 39.8942 10
created -8.5 3.98942 1
created -7.9 35.9048 9
created -7.3 15.9577 4
created -6.7 39.8942 10
created -6.1 31.9154 8
created -5.5 3.98942 1
created -4.9 3.98942 1
created -4.3 35.9048 9
created -3.7 19.9471 5
created -3.1 15.9577 4
created -2.5 31.9154 8
created -1.9 23.9365 6
created -1.3 3.98942 1
created -0.7 7.97885 2
created -0.1 31.9154 8
created 0.5 35.9048 9
created 1.1 23.9365 6
created 1.7 35.9048 9
created 2.3 11.9683 3
created 2.9 31.9154 8
created 3.5 3.98942 1
created 4.1 31.9154 8
created 4.7 11.9683 3
created 5.3 39.8942 10
created 5.9 7.97885 2
created 6.5 11.9683 3
created 7.1 3.98942 1
created 7.7 35.9048 9
created 8.3 3.98942 1
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.53593e-05)
fit chi^2 = 5.6168e-06
found -9.1 (+-0.000326431) 39.8936 (+-0.129251) 10 (+-0.00106069)
found -6.7 (+-0.000328762) 39.8941 (+-0.129357) 10.0002 (+-0.00106156)
found 5.3 (+-0.00032718) 39.8937 (+-0.129283) 10.0001 (+-0.00106096)
found -7.9 (+-0.000344857) 35.9044 (+-0.122649) 9.00006 (+-0.00100652)
found -4.3 (+-0.000345097) 35.9044 (+-0.122659) 9.00007 (+-0.0010066)
found 0.5 (+-0.000347251) 35.9048 (+-0.122749) 9.00018 (+-0.00100734)
found 1.7 (+-0.00034614) 35.9046 (+-0.122701) 9.00012 (+-0.00100695)
found 7.7 (+-0.000343756) 35.9042 (+-0.122605) 9.00002 (+-0.00100616)
found -6.1 (+-0.00036723) 31.9153 (+-0.115692) 8.00014 (+-0.000949426)
found -2.5 (+-0.000367727) 31.9153 (+-0.115706) 8.00013 (+-0.000949539)
found -0.0999981 (+-0.000367604) 31.9153 (+-0.115704) 8.00014 (+-0.00094952)
found 2.9 (+-0.000365673) 31.915 (+-0.115631) 8.00005 (+-0.00094892)
found 4.1 (+-0.000365673) 31.915 (+-0.115631) 8.00005 (+-0.00094892)
found 9.5 (+-0.000364248) 31.9153 (+-0.11559) 8.00014 (+-0.000948588)
found 1.1 (+-0.000427662) 23.937 (+-0.100296) 6.00023 (+-0.000823076)
found -1.9 (+-0.000424399) 23.9365 (+-0.100202) 6.00012 (+-0.000822307)
found -3.7 (+-0.00046765) 19.9474 (+-0.0915367) 5.00017 (+-0.000751194)
found -7.3 (+-0.000526229) 15.9584 (+-0.0819434) 4.00025 (+-0.000672467)
found -3.1 (+-0.000524084) 15.9581 (+-0.081898) 4.00017 (+-0.000672095)
found 2.3 (+-0.000608853) 11.9689 (+-0.070985) 3.00022 (+-0.000582537)
found 4.7 (+-0.000609241) 11.969 (+-0.0709915) 3.00023 (+-0.000582591)
found 6.5 (+-0.000599532) 11.9682 (+-0.0708415) 3.00004 (+-0.00058136)
found 8.9 (+-0.000603281) 11.9685 (+-0.0709007) 3.00012 (+-0.000581845)
found 5.89999 (+-0.000745893) 7.97937 (+-0.0579633) 2.00017 (+-0.000475675)
found -9.69999 (+-0.000742765) 7.97922 (+-0.057928) 2.00013 (+-0.000475386)
found -0.699993 (+-0.000741562) 7.97917 (+-0.0579189) 2.00012 (+-0.00047531)
found -8.5 (+-0.00107296) 3.99034 (+-0.0410905) 1.00025 (+-0.000337209)
found 3.5 (+-0.0010699) 3.99018 (+-0.0410719) 1.00021 (+-0.000337056)
found -5.50001 (+-0.00105663) 3.98982 (+-0.0409991) 1.00012 (+-0.000336459)
found 8.29999 (+-0.00106355) 3.98997 (+-0.0410358) 1.00016 (+-0.00033676)
found -1.30001 (+-0.00105775) 3.98977 (+-0.0410023) 1.00011 (+-0.000336485)
found 7.10001 (+-0.00106355) 3.98997 (+-0.0410358) 1.00016 (+-0.00033676)
found -4.89998 (+-0.00105764) 3.98988 (+-0.0410054) 1.00013 (+-0.000336511)
#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;
}
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
double Double_t
Double 8 bytes.
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()