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 31.9154 8
created -8.5 27.926 7
created -7.9 35.9048 9
created -7.3 35.9048 9
created -6.7 27.926 7
created -6.1 39.8942 10
created -5.5 15.9577 4
created -4.9 11.9683 3
created -4.3 27.926 7
created -3.7 7.97885 2
created -3.1 35.9048 9
created -2.5 11.9683 3
created -1.9 31.9154 8
created -1.3 39.8942 10
created -0.7 31.9154 8
created -0.1 15.9577 4
created 0.5 11.9683 3
created 1.1 19.9471 5
created 1.7 11.9683 3
created 2.3 39.8942 10
created 2.9 39.8942 10
created 3.5 23.9365 6
created 4.1 27.926 7
created 4.7 39.8942 10
created 5.3 11.9683 3
created 5.9 27.926 7
created 6.5 3.98942 1
created 7.1 19.9471 5
created 7.7 19.9471 5
created 8.3 11.9683 3
created 8.9 7.97885 2
created 9.5 11.9683 3
the total number of created peaks = 33 with sigma = 0.1
the total number of found peaks = 33 with sigma = 0.100002 (+-2.62375e-05)
fit chi^2 = 2.13609e-06
found -6.1 (+-0.000202645) 39.894 (+-0.0797678) 10.0001 (+-0.000654613)
found -1.3 (+-0.000203209) 39.8943 (+-0.0797948) 10.0002 (+-0.000654836)
found 2.3 (+-0.000202759) 39.8941 (+-0.0797741) 10.0002 (+-0.000654666)
found 2.9 (+-0.000203177) 39.8943 (+-0.0797935) 10.0002 (+-0.000654825)
found 4.7 (+-0.000202485) 39.894 (+-0.0797605) 10.0001 (+-0.000654554)
found -7.9 (+-0.000214365) 35.9049 (+-0.0757074) 9.00021 (+-0.000621292)
found -7.3 (+-0.000214365) 35.9049 (+-0.0757074) 9.00021 (+-0.000621292)
found -3.1 (+-0.000212791) 35.9044 (+-0.0756403) 9.00006 (+-0.000620741)
found -0.700002 (+-0.000227237) 31.9155 (+-0.0713731) 8.00018 (+-0.000585723)
found -9.1 (+-0.000227218) 31.9154 (+-0.0713716) 8.00017 (+-0.000585711)
found -1.9 (+-0.000227041) 31.9154 (+-0.0713659) 8.00017 (+-0.000585663)
found -6.7 (+-0.000243942) 27.9264 (+-0.0667987) 7.00025 (+-0.000548183)
found -8.5 (+-0.000243701) 27.9263 (+-0.06679) 7.00022 (+-0.000548111)
found -4.3 (+-0.0002416) 27.9257 (+-0.0667185) 7.00006 (+-0.000547525)
found 4.1 (+-0.000243532) 27.9262 (+-0.0667842) 7.00021 (+-0.000548064)
found 5.9 (+-0.000241229) 27.9256 (+-0.0667072) 7.00005 (+-0.000547432)
found 3.5 (+-0.000263568) 23.937 (+-0.0618461) 6.00022 (+-0.00050754)
found -9.7 (+-0.000262501) 23.9365 (+-0.0618092) 6.00011 (+-0.000507237)
found 1.1 (+-0.000286793) 19.947 (+-0.0564092) 5.00008 (+-0.000462921)
found 7.1 (+-0.000286464) 19.947 (+-0.0564027) 5.00008 (+-0.000462868)
found 7.7 (+-0.000287336) 19.9471 (+-0.0564226) 5.0001 (+-0.000463031)
found -5.5 (+-0.000322913) 15.9581 (+-0.0505006) 4.00017 (+-0.000414432)
found -0.100003 (+-0.000322528) 15.958 (+-0.0504922) 4.00014 (+-0.000414363)
found -2.5 (+-0.000375472) 11.9689 (+-0.0437755) 3.00022 (+-0.000359244)
found 1.7 (+-0.000374773) 11.9688 (+-0.0437645) 3.0002 (+-0.000359153)
found 5.3 (+-0.00037543) 11.9689 (+-0.043775) 3.00022 (+-0.000359239)
found 8.3 (+-0.000371926) 11.9684 (+-0.0437198) 3.00009 (+-0.000358786)
found -4.9 (+-0.000373608) 11.9686 (+-0.0437456) 3.00014 (+-0.000358998)
found 0.500001 (+-0.000372961) 11.9685 (+-0.0437352) 3.00012 (+-0.000358913)
found 9.5 (+-0.000367471) 11.9683 (+-0.0436612) 3.00006 (+-0.000358305)
found -3.7 (+-0.000461798) 7.97952 (+-0.0357643) 2.00021 (+-0.0002935)
found 8.9 (+-0.0004568) 7.979 (+-0.0357098) 2.00008 (+-0.000293052)
found 6.5 (+-0.000656744) 3.98997 (+-0.0253104) 1.00016 (+-0.00020771)
#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()