This macro fits the source spectrum using the AWMI algorithm from the "TSpectrumFit" class ("TSpectrum" class is used to find peaks).
created -9.76 34.9074 7
created -9.28 4.98678 1
created -8.8 24.9339 5
created -8.32 39.8942 8
created -7.84 34.9074 7
created -7.36 49.8678 10
created -6.88 24.9339 5
created -6.4 29.9207 6
created -5.92 14.9603 3
created -5.44 19.9471 4
created -4.96 44.881 9
created -4.48 4.98678 1
created -4 39.8942 8
created -3.52 29.9207 6
created -3.04 44.881 9
created -2.56 44.881 9
created -2.08 24.9339 5
created -1.6 14.9603 3
created -1.12 44.881 9
created -0.64 49.8678 10
created -0.16 49.8678 10
created 0.32 24.9339 5
created 0.8 9.97356 2
created 1.28 49.8678 10
created 1.76 9.97356 2
created 2.24 19.9471 4
created 2.72 44.881 9
created 3.2 24.9339 5
created 3.68 39.8942 8
created 4.16 4.98678 1
created 4.64 34.9074 7
created 5.12 34.9074 7
created 5.6 4.98678 1
created 6.08 4.98678 1
created 6.56 29.9207 6
created 7.04 14.9603 3
created 7.52 14.9603 3
created 8 29.9207 6
created 8.48 49.8678 10
created 8.96 49.8678 10
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 (+-1.04949e-05)
fit chi^2 = 6.51179e-07
found -7.36 (+-8.8798e-05) 49.8677 (+-0.0545832) 10.0001 (+-0.00036146)
found -0.64 (+-8.91031e-05) 49.8681 (+-0.0546065) 10.0002 (+-0.000361614)
found -0.160001 (+-8.89185e-05) 49.8679 (+-0.0545925) 10.0002 (+-0.000361522)
found 1.28 (+-8.82687e-05) 49.8673 (+-0.0545451) 10 (+-0.000361208)
found 8.48 (+-8.89715e-05) 49.8679 (+-0.0545965) 10.0002 (+-0.000361548)
found 8.96 (+-8.85828e-05) 49.8677 (+-0.0545695) 10.0001 (+-0.000361369)
found -4.96 (+-9.31277e-05) 44.8806 (+-0.0517519) 9.00005 (+-0.000342711)
found -3.04 (+-9.38183e-05) 44.8812 (+-0.0517971) 9.00015 (+-0.00034301)
found -2.56 (+-9.37602e-05) 44.8811 (+-0.0517931) 9.00014 (+-0.000342984)
found -1.12 (+-9.36576e-05) 44.8811 (+-0.0517867) 9.00013 (+-0.000342941)
found 2.72 (+-9.34936e-05) 44.8808 (+-0.0517749) 9.00009 (+-0.000342863)
found -8.32 (+-9.94344e-05) 39.8943 (+-0.0488301) 8.00012 (+-0.000323362)
found -4 (+-9.89683e-05) 39.894 (+-0.0488036) 8.00007 (+-0.000323186)
found 3.68 (+-9.8905e-05) 39.894 (+-0.0487997) 8.00006 (+-0.00032316)
found -9.76 (+-0.000105693) 34.907 (+-0.0456418) 7.00001 (+-0.000302248)
found -7.84 (+-0.000106768) 34.9079 (+-0.045702) 7.00018 (+-0.000302647)
found 4.64 (+-0.000105945) 34.9074 (+-0.0456592) 7.00008 (+-0.000302363)
found 5.12 (+-0.000105945) 34.9074 (+-0.0456592) 7.00008 (+-0.000302363)
found -3.52 (+-0.000115427) 29.9211 (+-0.0423169) 6.00017 (+-0.00028023)
found -6.4 (+-0.000114711) 29.9207 (+-0.0422834) 6.00008 (+-0.000280008)
found 6.56 (+-0.000114186) 29.9205 (+-0.0422605) 6.00004 (+-0.000279857)
found 8 (+-0.000115054) 29.9209 (+-0.0422999) 6.00013 (+-0.000280117)
found -6.88 (+-0.000126564) 24.9344 (+-0.0386349) 5.00016 (+-0.000255847)
found -2.08 (+-0.000126158) 24.9342 (+-0.0386191) 5.00012 (+-0.000255743)
found 0.319998 (+-0.000126064) 24.9342 (+-0.038616) 5.00012 (+-0.000255722)
found 3.2 (+-0.000126663) 24.9344 (+-0.0386388) 5.00017 (+-0.000255873)
found -8.8 (+-0.000125701) 24.934 (+-0.0386025) 5.00009 (+-0.000255633)
found -5.44 (+-0.000141323) 19.9475 (+-0.0345508) 4.00012 (+-0.000228802)
found 2.24 (+-0.000141126) 19.9474 (+-0.034545) 4.00011 (+-0.000228763)
found -5.92 (+-0.00016347) 14.9606 (+-0.0299283) 3.0001 (+-0.000198191)
found -1.6 (+-0.000164011) 14.9608 (+-0.0299419) 3.00014 (+-0.000198281)
found 7.04 (+-0.000163268) 14.9606 (+-0.0299235) 3.00009 (+-0.000198159)
found 7.52 (+-0.000163268) 14.9606 (+-0.0299235) 3.00009 (+-0.000198159)
found 1.76 (+-0.00020172) 9.97414 (+-0.0244624) 2.00014 (+-0.000161994)
found 0.800003 (+-0.000201966) 9.97419 (+-0.0244664) 2.00015 (+-0.000162021)
found -4.48 (+-0.000289219) 4.98758 (+-0.017333) 1.00017 (+-0.000114782)
found 4.16 (+-0.000288627) 4.98748 (+-0.0173274) 1.00015 (+-0.000114745)
found 9.43999 (+-0.000283002) 4.98728 (+-0.0172867) 1.00011 (+-0.000114476)
found -9.28 (+-0.000287597) 4.98732 (+-0.0173179) 1.00012 (+-0.000114683)
found 5.59999 (+-0.00028505) 4.98712 (+-0.0172967) 1.00008 (+-0.000114542)
found 6.08001 (+-0.00028472) 4.98707 (+-0.0172936) 1.00007 (+-0.000114521)
#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()