This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.7 27.926 7
created -9.1 27.926 7
created -8.5 3.98942 1
created -7.9 15.9577 4
created -7.3 23.9365 6
created -6.7 39.8942 10
created -6.1 15.9577 4
created -5.5 19.9471 5
created -4.9 27.926 7
created -4.3 19.9471 5
created -3.7 23.9365 6
created -3.1 7.97885 2
created -2.5 23.9365 6
created -1.9 19.9471 5
created -1.3 3.98942 1
created -0.7 31.9154 8
created -0.1 15.9577 4
created 0.5 31.9154 8
created 1.1 39.8942 10
created 1.7 39.8942 10
created 2.3 7.97885 2
created 2.9 23.9365 6
created 3.5 3.98942 1
created 4.1 15.9577 4
created 4.7 15.9577 4
created 5.3 39.8942 10
created 5.9 39.8942 10
created 6.5 3.98942 1
created 7.1 23.9365 6
created 7.7 3.98942 1
created 8.3 27.926 7
created 8.9 15.9577 4
created 9.5 35.9048 9
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-4.6806e-05)
fit chi^2 = 6.24733e-06
found -6.7 (+-0.000346371) 39.894 (+-0.136407) 10.0001 (+-0.00111942)
found 1.1 (+-0.000347823) 39.8944 (+-0.136477) 10.0002 (+-0.00112)
found 1.7 (+-0.000346412) 39.8941 (+-0.136412) 10.0002 (+-0.00111946)
found 5.3 (+-0.000347025) 39.8942 (+-0.136439) 10.0002 (+-0.00111969)
found 5.9 (+-0.000345949) 39.894 (+-0.136393) 10.0001 (+-0.0011193)
found 9.5 (+-0.000362356) 35.9048 (+-0.129308) 9.00016 (+-0.00106116)
found -0.699999 (+-0.000385981) 31.915 (+-0.121961) 8.00006 (+-0.00100087)
found 0.500002 (+-0.000388613) 31.9155 (+-0.12206) 8.00018 (+-0.00100168)
found -9.7 (+-0.00041511) 27.9258 (+-0.114155) 7.00009 (+-0.000936811)
found -9.1 (+-0.000413753) 27.9258 (+-0.114122) 7.0001 (+-0.00093654)
found -4.9 (+-0.000415021) 27.926 (+-0.114161) 7.00013 (+-0.000936858)
found 8.3 (+-0.00041291) 27.9257 (+-0.114093) 7.00006 (+-0.0009363)
found -7.3 (+-0.000449759) 23.9368 (+-0.105738) 6.00018 (+-0.000867736)
found -3.7 (+-0.000447459) 23.9365 (+-0.10567) 6.00009 (+-0.000867176)
found -2.5 (+-0.000447459) 23.9364 (+-0.10567) 6.00009 (+-0.000867176)
found 2.9 (+-0.000445416) 23.9362 (+-0.105613) 6.00004 (+-0.000866708)
found 7.1 (+-0.000444692) 23.9362 (+-0.105593) 6.00003 (+-0.000866549)
found -5.5 (+-0.00049261) 19.9473 (+-0.0965224) 5.00014 (+-0.000792109)
found -4.3 (+-0.00049342) 19.9474 (+-0.0965426) 5.00017 (+-0.000792275)
found -1.9 (+-0.000490272) 19.9471 (+-0.0964674) 5.00009 (+-0.000791659)
found -6.1 (+-0.00055338) 15.9582 (+-0.086387) 4.00019 (+-0.000708934)
found -0.0999999 (+-0.000553967) 15.9582 (+-0.0863987) 4.00021 (+-0.000709029)
found 8.9 (+-0.000553936) 15.9582 (+-0.0863981) 4.00021 (+-0.000709025)
found -7.9 (+-0.000548972) 15.9578 (+-0.0862995) 4.00009 (+-0.000708216)
found 4.1 (+-0.000548009) 15.9577 (+-0.0862795) 4.00007 (+-0.000708051)
found 4.7 (+-0.000552854) 15.9581 (+-0.0863764) 4.00018 (+-0.000708847)
found 2.3 (+-0.000789575) 7.97953 (+-0.0611613) 2.00021 (+-0.000501919)
found -3.1 (+-0.000786972) 7.97932 (+-0.0611317) 2.00016 (+-0.000501676)
found 6.49999 (+-0.00112793) 3.99018 (+-0.0433138) 1.00021 (+-0.000355454)
found -8.50001 (+-0.00112143) 3.98992 (+-0.0432753) 1.00014 (+-0.000355138)
found 3.5 (+-0.00112012) 3.98987 (+-0.0432674) 1.00013 (+-0.000355074)
found 7.7 (+-0.00112463) 3.99002 (+-0.0432936) 1.00017 (+-0.000355289)
found -1.29999 (+-0.00112433) 3.99002 (+-0.0432922) 1.00017 (+-0.000355277)
#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()