This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 49.8678 10
created -9.28 29.9207 6
created -8.8 4.98678 1
created -8.32 9.97356 2
created -7.84 44.881 9
created -7.36 39.8942 8
created -6.88 9.97356 2
created -6.4 49.8678 10
created -5.92 29.9207 6
created -5.44 39.8942 8
created -4.96 39.8942 8
created -4.48 49.8678 10
created -4 44.881 9
created -3.52 14.9603 3
created -3.04 39.8942 8
created -2.56 29.9207 6
created -2.08 49.8678 10
created -1.6 44.881 9
created -1.12 44.881 9
created -0.64 4.98678 1
created -0.16 9.97356 2
created 0.32 29.9207 6
created 0.8 49.8678 10
created 1.28 29.9207 6
created 1.76 24.9339 5
created 2.24 29.9207 6
created 2.72 24.9339 5
created 3.2 44.881 9
created 3.68 24.9339 5
created 4.16 14.9603 3
created 4.64 44.881 9
created 5.12 39.8942 8
created 5.6 34.9074 7
created 6.08 34.9074 7
created 6.56 29.9207 6
created 7.04 24.9339 5
created 7.52 24.9339 5
created 8 29.9207 6
created 8.48 19.9471 4
created 8.96 39.8942 8
created 9.44 4.98678 1
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-9.87222e-06)
fit chi^2 = 6.29477e-07
found -9.76 (+-8.72667e-05) 49.8674 (+-0.0536585) 10.0001 (+-0.000355336)
found -6.4 (+-8.7047e-05) 49.8675 (+-0.0536474) 10.0001 (+-0.000355263)
found -4.48 (+-8.75294e-05) 49.868 (+-0.0536829) 10.0002 (+-0.000355498)
found -2.08 (+-8.74397e-05) 49.8679 (+-0.0536761) 10.0002 (+-0.000355453)
found 0.8 (+-8.7311e-05) 49.8677 (+-0.0536662) 10.0001 (+-0.000355388)
found -7.84 (+-9.19075e-05) 44.8809 (+-0.0509047) 9.0001 (+-0.0003371)
found -4 (+-9.20836e-05) 44.8811 (+-0.0509164) 9.00013 (+-0.000337178)
found -1.6 (+-9.24238e-05) 44.8814 (+-0.0509393) 9.00019 (+-0.000337329)
found -1.12 (+-9.18218e-05) 44.8809 (+-0.0509001) 9.0001 (+-0.00033707)
found 3.2 (+-9.19868e-05) 44.8809 (+-0.0509091) 9.0001 (+-0.000337129)
found 4.64 (+-9.20008e-05) 44.881 (+-0.0509105) 9.00011 (+-0.000337139)
found -7.36 (+-9.76024e-05) 39.8942 (+-0.0480008) 8.00011 (+-0.00031787)
found -5.44 (+-9.78785e-05) 39.8944 (+-0.0480166) 8.00014 (+-0.000317974)
found -4.96 (+-9.808e-05) 39.8946 (+-0.0480292) 8.00018 (+-0.000318058)
found -3.04 (+-9.75511e-05) 39.8941 (+-0.0479969) 8.00009 (+-0.000317844)
found 5.12 (+-9.79833e-05) 39.8945 (+-0.0480231) 8.00016 (+-0.000318018)
found 8.96 (+-9.71722e-05) 39.8939 (+-0.0479753) 8.00005 (+-0.000317701)
found 5.6 (+-0.000104811) 34.9077 (+-0.0449249) 7.00015 (+-0.000297501)
found 6.08 (+-0.000104689) 34.9076 (+-0.0449182) 7.00013 (+-0.000297457)
found -9.28 (+-0.000112799) 29.9208 (+-0.0415756) 6.00011 (+-0.000275321)
found -5.92 (+-0.000113544) 29.9212 (+-0.0416085) 6.00018 (+-0.000275539)
found -2.56 (+-0.000113544) 29.9212 (+-0.0416085) 6.00018 (+-0.000275539)
found 1.28 (+-0.000113322) 29.921 (+-0.0415981) 6.00015 (+-0.00027547)
found 6.56 (+-0.000113138) 29.9209 (+-0.0415891) 6.00012 (+-0.00027541)
found 0.320002 (+-0.000112985) 29.9209 (+-0.0415832) 6.00012 (+-0.000275372)
found 2.24 (+-0.000112984) 29.9208 (+-0.0415818) 6.0001 (+-0.000275362)
found 8 (+-0.000112892) 29.9207 (+-0.0415776) 6.00009 (+-0.000275334)
found 1.76 (+-0.000124136) 24.9342 (+-0.0379733) 5.00012 (+-0.000251466)
found 2.72 (+-0.000124371) 24.9343 (+-0.0379828) 5.00015 (+-0.000251529)
found 3.68 (+-0.000124038) 24.9342 (+-0.0379701) 5.00012 (+-0.000251445)
found 7.04 (+-0.00012404) 24.9341 (+-0.0379695) 5.00011 (+-0.000251441)
found 7.52 (+-0.00012404) 24.9341 (+-0.0379695) 5.00011 (+-0.000251441)
found 8.48 (+-0.000139266) 19.9476 (+-0.0339799) 4.00014 (+-0.000225021)
found -3.52 (+-0.000161658) 14.961 (+-0.0294488) 3.00017 (+-0.000195015)
found 4.16 (+-0.000161254) 14.9608 (+-0.0294387) 3.00014 (+-0.000194949)
found -6.88 (+-0.000199142) 9.97434 (+-0.0240651) 2.00018 (+-0.000159364)
found -8.31999 (+-0.000197045) 9.97394 (+-0.024031) 2.0001 (+-0.000159138)
found -0.159997 (+-0.000196545) 9.97379 (+-0.024022) 2.00007 (+-0.000159078)
found -0.640009 (+-0.000281741) 4.98728 (+-0.0170187) 1.00011 (+-0.000112701)
found 9.43999 (+-0.000277745) 4.98718 (+-0.0169911) 1.00009 (+-0.000112518)
found -8.80001 (+-0.000280848) 4.98712 (+-0.0170102) 1.00008 (+-0.000112645)
#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()