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 15.9577 4
created -8.5 39.8942 10
created -7.9 35.9048 9
created -7.3 23.9365 6
created -6.7 15.9577 4
created -6.1 35.9048 9
created -5.5 23.9365 6
created -4.9 11.9683 3
created -4.3 35.9048 9
created -3.7 11.9683 3
created -3.1 11.9683 3
created -2.5 15.9577 4
created -1.9 19.9471 5
created -1.3 39.8942 10
created -0.7 15.9577 4
created -0.1 27.926 7
created 0.5 23.9365 6
created 1.1 7.97885 2
created 1.7 3.98942 1
created 2.3 7.97885 2
created 2.9 19.9471 5
created 3.5 39.8942 10
created 4.1 19.9471 5
created 4.7 27.926 7
created 5.3 35.9048 9
created 5.9 23.9365 6
created 6.5 15.9577 4
created 7.1 27.926 7
created 7.7 39.8942 10
created 8.3 23.9365 6
created 8.9 27.926 7
created 9.5 7.97885 2
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.21758e-05)
fit chi^2 = 1.44224e-06
found -8.5 (+-0.000166667) 39.8941 (+-0.0655522) 10.0002 (+-0.000537954)
found -1.3 (+-0.000166324) 39.8939 (+-0.0655355) 10.0001 (+-0.000537817)
found 3.5 (+-0.000166436) 39.894 (+-0.0655407) 10.0001 (+-0.00053786)
found 7.7 (+-0.000166723) 39.8941 (+-0.0655545) 10.0002 (+-0.000537972)
found -7.9 (+-0.000176121) 35.9049 (+-0.0622073) 9.00021 (+-0.000510504)
found -6.1 (+-0.000175543) 35.9046 (+-0.0621819) 9.00013 (+-0.000510296)
found -4.3 (+-0.000175025) 35.9044 (+-0.0621601) 9.00008 (+-0.000510116)
found 5.3 (+-0.000175872) 35.9048 (+-0.0621962) 9.00017 (+-0.000510412)
found -0.0999994 (+-0.000199389) 27.9259 (+-0.0548509) 7.00013 (+-0.000450133)
found 4.7 (+-0.000199877) 27.9261 (+-0.0548679) 7.00018 (+-0.000450273)
found 7.1 (+-0.000199817) 27.9261 (+-0.0548662) 7.00018 (+-0.000450259)
found 8.9 (+-0.000198986) 27.9258 (+-0.0548378) 7.0001 (+-0.000450026)
found -7.3 (+-0.00021599) 23.9367 (+-0.050801) 6.00017 (+-0.000416898)
found -5.5 (+-0.000215782) 23.9367 (+-0.0507951) 6.00016 (+-0.00041685)
found 5.9 (+-0.00021599) 23.9367 (+-0.050801) 6.00017 (+-0.000416898)
found 8.3 (+-0.000216572) 23.9369 (+-0.0508185) 6.00022 (+-0.000417041)
found 0.499998 (+-0.000215284) 23.9365 (+-0.0507805) 6.00012 (+-0.00041673)
found 4.1 (+-0.000237653) 19.9476 (+-0.0464014) 5.00022 (+-0.000380793)
found -1.9 (+-0.000237097) 19.9474 (+-0.0463875) 5.00018 (+-0.000380679)
found 2.9 (+-0.00023655) 19.9473 (+-0.0463746) 5.00016 (+-0.000380573)
found -6.7 (+-0.000265954) 15.9582 (+-0.041508) 4.00019 (+-0.000340635)
found -0.700002 (+-0.000266307) 15.9583 (+-0.0415155) 4.00022 (+-0.000340697)
found 6.5 (+-0.000265609) 15.9581 (+-0.0415006) 4.00017 (+-0.000340575)
found -9.1 (+-0.000264451) 15.9579 (+-0.0414796) 4.00014 (+-0.000340402)
found -2.5 (+-0.000264427) 15.9578 (+-0.0414765) 4.0001 (+-0.000340376)
found -4.9 (+-0.000308037) 11.9688 (+-0.0359622) 3.00019 (+-0.000295123)
found -3.7 (+-0.000307047) 11.9687 (+-0.0359469) 3.00016 (+-0.000294998)
found -3.1 (+-0.000305761) 11.9684 (+-0.0359261) 3.00009 (+-0.000294827)
found 9.5 (+-0.000372682) 7.97915 (+-0.0293239) 2.00012 (+-0.000240646)
found 1.09999 (+-0.000375107) 7.97905 (+-0.0293414) 2.00009 (+-0.00024079)
found 2.3 (+-0.000374718) 7.979 (+-0.0293371) 2.00008 (+-0.000240755)
found -9.69999 (+-0.000531491) 3.98956 (+-0.0207515) 1.00005 (+-0.000170297)
found 1.7 (+-0.000532335) 3.98955 (+-0.0207562) 1.00005 (+-0.000170336)
#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()