This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 24.9339 5
created -9.28 34.9074 7
created -8.8 4.98678 1
created -8.32 39.8942 8
created -7.84 14.9603 3
created -7.36 39.8942 8
created -6.88 4.98678 1
created -6.4 39.8942 8
created -5.92 19.9471 4
created -5.44 49.8678 10
created -4.96 24.9339 5
created -4.48 14.9603 3
created -4 9.97356 2
created -3.52 44.881 9
created -3.04 9.97356 2
created -2.56 19.9471 4
created -2.08 24.9339 5
created -1.6 34.9074 7
created -1.12 9.97356 2
created -0.64 34.9074 7
created -0.16 19.9471 4
created 0.32 39.8942 8
created 0.8 19.9471 4
created 1.28 39.8942 8
created 1.76 49.8678 10
created 2.24 49.8678 10
created 2.72 34.9074 7
created 3.2 49.8678 10
created 3.68 49.8678 10
created 4.16 19.9471 4
created 4.64 14.9603 3
created 5.12 4.98678 1
created 5.6 29.9207 6
created 6.08 34.9074 7
created 6.56 44.881 9
created 7.04 34.9074 7
created 7.52 29.9207 6
created 8 19.9471 4
created 8.48 24.9339 5
created 8.96 39.8942 8
created 9.44 39.8942 8
the total number of created peaks = 41 with sigma = 0.08
the total number of found peaks = 41 with sigma = 0.0800011 (+-2.74122e-05)
fit chi^2 = 4.52003e-06
found -5.44 (+-0.000233529) 49.8676 (+-0.143775) 10.0001 (+-0.000952107)
found 1.76 (+-0.000234648) 49.868 (+-0.14386) 10.0002 (+-0.000952667)
found 2.24 (+-0.000234533) 49.868 (+-0.143851) 10.0002 (+-0.000952609)
found 3.2 (+-0.000234533) 49.868 (+-0.143851) 10.0002 (+-0.000952609)
found 3.68 (+-0.000234109) 49.8678 (+-0.14382) 10.0001 (+-0.000952401)
found -3.52 (+-0.000245251) 44.8806 (+-0.136339) 9.00004 (+-0.000902862)
found 6.56 (+-0.000247073) 44.8811 (+-0.136459) 9.00014 (+-0.000903655)
found -8.32 (+-0.000260167) 39.8939 (+-0.128545) 8.00004 (+-0.000851247)
found -7.36 (+-0.000260167) 39.8939 (+-0.128545) 8.00004 (+-0.000851247)
found -6.4 (+-0.000260389) 39.8939 (+-0.128558) 8.00005 (+-0.000851334)
found 0.32 (+-0.00026127) 39.8941 (+-0.128607) 8.00008 (+-0.000851659)
found 1.28 (+-0.000262165) 39.8944 (+-0.128662) 8.00014 (+-0.000852026)
found 8.96 (+-0.000262112) 39.8944 (+-0.128658) 8.00013 (+-0.000851997)
found 9.44 (+-0.000260008) 39.8945 (+-0.128553) 8.00016 (+-0.000851298)
found -9.28 (+-0.000278769) 34.9073 (+-0.120276) 7.00006 (+-0.000796488)
found -1.6 (+-0.0002792) 34.9073 (+-0.120296) 7.00007 (+-0.000796623)
found -0.64 (+-0.000278986) 34.9073 (+-0.120285) 7.00006 (+-0.000796547)
found 2.72 (+-0.000281574) 34.908 (+-0.120424) 7.0002 (+-0.000797468)
found 6.08 (+-0.000280831) 34.9077 (+-0.120383) 7.00015 (+-0.000797195)
found 7.04 (+-0.000280831) 34.9077 (+-0.120383) 7.00015 (+-0.000797195)
found 7.52 (+-0.000302923) 29.9208 (+-0.111434) 6.00011 (+-0.000737933)
found 5.6 (+-0.000301775) 29.9207 (+-0.111385) 6.00008 (+-0.000737609)
found -4.96 (+-0.000332557) 24.9342 (+-0.101755) 5.00013 (+-0.000673837)
found -9.76 (+-0.000331813) 24.9339 (+-0.101716) 5.00007 (+-0.000673582)
found -2.08 (+-0.000332324) 24.9341 (+-0.101744) 5.00011 (+-0.000673765)
found 8.48 (+-0.000332532) 24.9342 (+-0.101752) 5.00012 (+-0.000673821)
found -5.92 (+-0.000374169) 19.9478 (+-0.0910875) 4.00018 (+-0.000603198)
found -0.16 (+-0.000373465) 19.9476 (+-0.0910639) 4.00015 (+-0.000603042)
found 0.8 (+-0.000373719) 19.9477 (+-0.0910723) 4.00016 (+-0.000603097)
found 4.16 (+-0.000372549) 19.9475 (+-0.0910361) 4.00013 (+-0.000602857)
found 8 (+-0.000372347) 19.9474 (+-0.0910273) 4.00011 (+-0.0006028)
found -2.56 (+-0.000370758) 19.9472 (+-0.0909781) 4.00007 (+-0.000602473)
found -7.84 (+-0.000432892) 14.9609 (+-0.0789053) 3.00016 (+-0.000522525)
found -4.48 (+-0.000429095) 14.9605 (+-0.0788125) 3.00007 (+-0.00052191)
found 4.64 (+-0.000427727) 14.9604 (+-0.0787813) 3.00005 (+-0.000521704)
found -3.04 (+-0.000531074) 9.97409 (+-0.0644424) 2.00013 (+-0.000426749)
found -4 (+-0.00053031) 9.97404 (+-0.06443) 2.00012 (+-0.000426667)
found -1.12 (+-0.000531915) 9.97414 (+-0.0644559) 2.00014 (+-0.000426839)
found -6.88 (+-0.00076124) 4.98753 (+-0.045659) 1.00016 (+-0.000302362)
found -8.8 (+-0.000760426) 4.98748 (+-0.0456514) 1.00015 (+-0.000302312)
found 5.12 (+-0.0007543) 4.98717 (+-0.0455961) 1.00009 (+-0.000301945)
#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()