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 4.98678 1
created -8.8 44.881 9
created -8.32 24.9339 5
created -7.84 4.98678 1
created -7.36 39.8942 8
created -6.88 14.9603 3
created -6.4 49.8678 10
created -5.92 39.8942 8
created -5.44 29.9207 6
created -4.96 4.98678 1
created -4.48 14.9603 3
created -4 49.8678 10
created -3.52 4.98678 1
created -3.04 4.98678 1
created -2.56 19.9471 4
created -2.08 29.9207 6
created -1.6 49.8678 10
created -1.12 39.8942 8
created -0.64 49.8678 10
created -0.16 24.9339 5
created 0.32 44.881 9
created 0.8 39.8942 8
created 1.28 29.9207 6
created 1.76 49.8678 10
created 2.24 4.98678 1
created 2.72 24.9339 5
created 3.2 44.881 9
created 3.68 9.97356 2
created 4.16 44.881 9
created 4.64 49.8678 10
created 5.12 34.9074 7
created 5.6 49.8678 10
created 6.08 14.9603 3
created 6.56 29.9207 6
created 7.04 49.8678 10
created 7.52 14.9603 3
created 8 49.8678 10
created 8.48 49.8678 10
created 8.96 19.9471 4
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.83878e-05)
fit chi^2 = 5.09465e-06
found -6.4 (+-0.000248133) 49.8677 (+-0.152657) 10.0001 (+-0.00101092)
found -4 (+-0.000246806) 49.8673 (+-0.152563) 10 (+-0.0010103)
found -1.6 (+-0.000248645) 49.8678 (+-0.152694) 10.0001 (+-0.00101117)
found -0.64 (+-0.000248497) 49.8678 (+-0.152684) 10.0001 (+-0.0010111)
found 1.76 (+-0.00024731) 49.8675 (+-0.1526) 10.0001 (+-0.00101054)
found 4.64 (+-0.000248891) 49.8679 (+-0.152713) 10.0002 (+-0.00101129)
found 5.6 (+-0.000248013) 49.8676 (+-0.152648) 10.0001 (+-0.00101086)
found 7.04 (+-0.000247881) 49.8676 (+-0.152638) 10.0001 (+-0.0010108)
found 8 (+-0.000248348) 49.8678 (+-0.152674) 10.0001 (+-0.00101104)
found 8.48 (+-0.000248545) 49.8678 (+-0.152688) 10.0001 (+-0.00101113)
found -8.8 (+-0.000260668) 44.8807 (+-0.144767) 9.00006 (+-0.000958674)
found 0.32 (+-0.000262133) 44.8811 (+-0.144862) 9.00013 (+-0.000959299)
found 3.2 (+-0.000261031) 44.8808 (+-0.144789) 9.00007 (+-0.000958817)
found 4.16 (+-0.000261702) 44.881 (+-0.144836) 9.00012 (+-0.000959128)
found 9.44 (+-0.000259525) 44.8811 (+-0.144707) 9.00013 (+-0.000958278)
found -7.36 (+-0.00027621) 39.8939 (+-0.136471) 8.00004 (+-0.000903737)
found -5.92 (+-0.000278717) 39.8945 (+-0.136619) 8.00016 (+-0.000904717)
found -1.12 (+-0.000279292) 39.8947 (+-0.136655) 8.0002 (+-0.000904954)
found 0.8 (+-0.000278591) 39.8945 (+-0.136611) 8.00015 (+-0.000904663)
found 5.12 (+-0.000298936) 34.908 (+-0.127849) 7.0002 (+-0.000846642)
found -5.44 (+-0.000320569) 29.9207 (+-0.118262) 6.00009 (+-0.000783152)
found 1.28 (+-0.000323022) 29.9212 (+-0.118372) 6.00018 (+-0.000783882)
found -2.08 (+-0.000322126) 29.921 (+-0.11833) 6.00014 (+-0.000783605)
found 6.56 (+-0.000321815) 29.9209 (+-0.118317) 6.00013 (+-0.000783514)
found -8.32 (+-0.000351799) 24.9341 (+-0.107983) 5.0001 (+-0.000715083)
found -0.16 (+-0.000354685) 24.9345 (+-0.108093) 5.00019 (+-0.000715809)
found 2.72 (+-0.000351799) 24.9341 (+-0.107983) 5.0001 (+-0.000715083)
found 8.96 (+-0.00039749) 19.9478 (+-0.0967125) 4.0002 (+-0.000640448)
found -2.56 (+-0.000393184) 19.9472 (+-0.0965771) 4.00007 (+-0.000639551)
found 6.08 (+-0.000459469) 14.961 (+-0.0837684) 3.00016 (+-0.000554729)
found 7.52 (+-0.000460807) 14.9612 (+-0.0838025) 3.0002 (+-0.000554955)
found -6.88 (+-0.000460195) 14.9611 (+-0.0837867) 3.00018 (+-0.00055485)
found -4.48 (+-0.000456284) 14.9607 (+-0.0836952) 3.00011 (+-0.000554245)
found 3.68 (+-0.000566574) 9.97434 (+-0.0684634) 2.00018 (+-0.000453377)
found -7.84 (+-0.000805289) 4.98738 (+-0.0484479) 1.00013 (+-0.000320831)
found -3.52001 (+-0.000799612) 4.98728 (+-0.048403) 1.00011 (+-0.000320534)
found 2.23999 (+-0.000806796) 4.98748 (+-0.0484624) 1.00015 (+-0.000320927)
found -4.96 (+-0.000800812) 4.98717 (+-0.0484076) 1.00009 (+-0.000320564)
found -9.27999 (+-0.000798906) 4.98723 (+-0.048396) 1.0001 (+-0.000320487)
found -9.76 (+-0.000786568) 4.98677 (+-0.0482846) 1.00001 (+-0.000319749)
found -3.04 (+-0.000794168) 4.98697 (+-0.0483513) 1.00005 (+-0.000320191)
#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()