This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 4.98678 1
created -9.28 19.9471 4
created -8.8 19.9471 4
created -8.32 39.8942 8
created -7.84 34.9074 7
created -7.36 29.9207 6
created -6.88 9.97356 2
created -6.4 44.881 9
created -5.92 9.97356 2
created -5.44 34.9074 7
created -4.96 4.98678 1
created -4.48 19.9471 4
created -4 34.9074 7
created -3.52 49.8678 10
created -3.04 39.8942 8
created -2.56 19.9471 4
created -2.08 14.9603 3
created -1.6 24.9339 5
created -1.12 24.9339 5
created -0.64 29.9207 6
created -0.16 14.9603 3
created 0.32 24.9339 5
created 0.8 19.9471 4
created 1.28 19.9471 4
created 1.76 29.9207 6
created 2.24 24.9339 5
created 2.72 49.8678 10
created 3.2 9.97356 2
created 3.68 49.8678 10
created 4.16 39.8942 8
created 4.64 9.97356 2
created 5.12 44.881 9
created 5.6 24.9339 5
created 6.08 29.9207 6
created 6.56 14.9603 3
created 7.04 14.9603 3
created 7.52 19.9471 4
created 8 34.9074 7
created 8.48 44.881 9
created 8.96 39.8942 8
created 9.44 44.881 9
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.99518e-05)
fit chi^2 = 5.06278e-06
found -3.52 (+-0.000247999) 49.8679 (+-0.152226) 10.0002 (+-0.00100807)
found 2.72 (+-0.000246719) 49.8675 (+-0.152132) 10.0001 (+-0.00100745)
found 3.68 (+-0.000247115) 49.8676 (+-0.152163) 10.0001 (+-0.00100765)
found -6.4 (+-0.000259558) 44.8806 (+-0.144293) 9.00004 (+-0.000955532)
found 5.12 (+-0.000260214) 44.8808 (+-0.144335) 9.00007 (+-0.000955814)
found 8.48 (+-0.00026162) 44.8812 (+-0.144429) 9.00015 (+-0.000956433)
found 9.44 (+-0.000259319) 44.8813 (+-0.144296) 9.00017 (+-0.000955556)
found -8.32 (+-0.000277052) 39.8943 (+-0.136142) 8.00011 (+-0.000901559)
found -3.04 (+-0.000277459) 39.8944 (+-0.136168) 8.00014 (+-0.000901731)
found 4.16 (+-0.000276925) 39.8943 (+-0.136138) 8.00012 (+-0.00090153)
found 8.96 (+-0.000278163) 39.8946 (+-0.136211) 8.00018 (+-0.000902013)
found -7.84 (+-0.000297062) 34.9077 (+-0.127397) 7.00014 (+-0.000843644)
found -5.44 (+-0.000294216) 34.9071 (+-0.12725) 7.00003 (+-0.000842673)
found -4 (+-0.000296923) 34.9077 (+-0.12739) 7.00014 (+-0.000843603)
found 8 (+-0.000296782) 34.9076 (+-0.127382) 7.00013 (+-0.000843549)
found -7.36 (+-0.000319906) 29.9207 (+-0.117904) 6.00009 (+-0.000780782)
found -0.64 (+-0.000319853) 29.9207 (+-0.1179) 6.00008 (+-0.000780755)
found 1.76 (+-0.00032016) 29.9207 (+-0.117914) 6.00009 (+-0.000780846)
found 6.08 (+-0.000319853) 29.9207 (+-0.1179) 6.00008 (+-0.000780755)
found 2.24 (+-0.000352903) 24.9344 (+-0.107727) 5.00016 (+-0.000713387)
found 5.6 (+-0.000352714) 24.9343 (+-0.107719) 5.00015 (+-0.000713335)
found -1.6 (+-0.000350841) 24.934 (+-0.107645) 5.00008 (+-0.000712845)
found -1.12 (+-0.000351777) 24.9341 (+-0.107681) 5.00011 (+-0.000713084)
found 0.32 (+-0.000350536) 24.9339 (+-0.107633) 5.00007 (+-0.000712766)
found -2.56 (+-0.000393812) 19.9474 (+-0.0963308) 4.00011 (+-0.00063792)
found -9.28 (+-0.000391264) 19.9471 (+-0.0962522) 4.00005 (+-0.0006374)
found -8.8 (+-0.000394253) 19.9475 (+-0.0963443) 4.00012 (+-0.000638009)
found -4.48 (+-0.00039224) 19.9473 (+-0.0962842) 4.00008 (+-0.000637611)
found 0.8 (+-0.000393369) 19.9473 (+-0.0963153) 4.00009 (+-0.000637817)
found 1.28 (+-0.000393695) 19.9474 (+-0.0963258) 4.0001 (+-0.000637887)
found 7.52 (+-0.000393547) 19.9474 (+-0.0963219) 4.0001 (+-0.000637861)
found -2.08 (+-0.000455392) 14.9606 (+-0.0834396) 3.00009 (+-0.000552552)
found -0.16 (+-0.000456288) 14.9607 (+-0.0834616) 3.00011 (+-0.000552698)
found 6.56 (+-0.000455244) 14.9606 (+-0.0834366) 3.00009 (+-0.000552532)
found 7.04 (+-0.000454354) 14.9605 (+-0.0834146) 3.00007 (+-0.000552387)
found -5.92 (+-0.00056387) 9.97424 (+-0.0682325) 2.00016 (+-0.000451848)
found 3.2 (+-0.000565625) 9.97445 (+-0.0682638) 2.0002 (+-0.000452055)
found -6.88 (+-0.000563336) 9.97419 (+-0.0682233) 2.00015 (+-0.000451787)
found 4.64 (+-0.000564354) 9.97429 (+-0.068241) 2.00017 (+-0.000451904)
found -4.96 (+-0.00080069) 4.98728 (+-0.0482773) 1.00011 (+-0.000319701)
found -9.75999 (+-0.000789749) 4.98692 (+-0.0481814) 1.00004 (+-0.000319066)
#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()