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 34.9074 7
created -8.8 29.9207 6
created -8.32 24.9339 5
created -7.84 29.9207 6
created -7.36 4.98678 1
created -6.88 29.9207 6
created -6.4 39.8942 8
created -5.92 29.9207 6
created -5.44 44.881 9
created -4.96 14.9603 3
created -4.48 24.9339 5
created -4 39.8942 8
created -3.52 9.97356 2
created -3.04 39.8942 8
created -2.56 29.9207 6
created -2.08 29.9207 6
created -1.6 34.9074 7
created -1.12 49.8678 10
created -0.64 29.9207 6
created -0.16 44.881 9
created 0.32 24.9339 5
created 0.8 14.9603 3
created 1.28 34.9074 7
created 1.76 49.8678 10
created 2.24 39.8942 8
created 2.72 49.8678 10
created 3.2 24.9339 5
created 3.68 19.9471 4
created 4.16 39.8942 8
created 4.64 44.881 9
created 5.12 39.8942 8
created 5.6 29.9207 6
created 6.08 9.97356 2
created 6.56 14.9603 3
created 7.04 14.9603 3
created 7.52 14.9603 3
created 8 49.8678 10
created 8.48 4.98678 1
created 8.96 44.881 9
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.85592e-05)
fit chi^2 = 5.0734e-06
found -1.12 (+-0.000248005) 49.8678 (+-0.152366) 10.0001 (+-0.001009)
found 1.76 (+-0.000248259) 49.8679 (+-0.152386) 10.0002 (+-0.00100913)
found 2.72 (+-0.000247979) 49.8678 (+-0.152365) 10.0001 (+-0.00100899)
found 8 (+-0.000246291) 49.8673 (+-0.152244) 10 (+-0.00100819)
found -5.44 (+-0.000260911) 44.8809 (+-0.144514) 9.00009 (+-0.000956997)
found -0.16 (+-0.000261308) 44.881 (+-0.14454) 9.00011 (+-0.00095717)
found 4.64 (+-0.000262027) 44.8812 (+-0.144589) 9.00016 (+-0.000957497)
found 8.96 (+-0.000260678) 44.8809 (+-0.144504) 9.0001 (+-0.000956929)
found 9.44 (+-0.000259711) 44.8813 (+-0.144456) 9.00018 (+-0.000956614)
found -6.4 (+-0.000277565) 39.8943 (+-0.136298) 8.00012 (+-0.000902591)
found -4 (+-0.000276473) 39.894 (+-0.136234) 8.00007 (+-0.000902166)
found -3.04 (+-0.00027665) 39.8941 (+-0.136245) 8.00008 (+-0.000902238)
found 2.24 (+-0.000278709) 39.8947 (+-0.13637) 8.0002 (+-0.000903065)
found 4.16 (+-0.000277624) 39.8944 (+-0.136303) 8.00013 (+-0.000902622)
found 5.12 (+-0.000278009) 39.8945 (+-0.136326) 8.00015 (+-0.000902775)
found -9.28 (+-0.00029554) 34.9073 (+-0.127436) 7.00007 (+-0.000843907)
found -1.6 (+-0.000297668) 34.9078 (+-0.127547) 7.00016 (+-0.000844638)
found 1.28 (+-0.000296964) 34.9076 (+-0.12751) 7.00013 (+-0.000844395)
found -8.8 (+-0.000321194) 29.9209 (+-0.11807) 6.00012 (+-0.00078188)
found -5.92 (+-0.000322186) 29.9211 (+-0.118117) 6.00017 (+-0.000782193)
found -2.56 (+-0.000321614) 29.921 (+-0.11809) 6.00014 (+-0.000782011)
found -2.08 (+-0.000321425) 29.9209 (+-0.118081) 6.00013 (+-0.000781951)
found -0.64 (+-0.000322523) 29.9212 (+-0.118134) 6.00019 (+-0.000782302)
found 5.6 (+-0.000320428) 29.9208 (+-0.118037) 6.0001 (+-0.000781661)
found -7.84 (+-0.000319283) 29.9206 (+-0.117986) 6.00006 (+-0.000781321)
found -6.88 (+-0.0003199) 29.9207 (+-0.118015) 6.00009 (+-0.000781518)
found -8.32 (+-0.000352416) 24.9342 (+-0.107805) 5.00012 (+-0.000713903)
found 0.319998 (+-0.000352139) 24.9342 (+-0.107796) 5.00012 (+-0.000713842)
found 3.2 (+-0.00035269) 24.9343 (+-0.107817) 5.00014 (+-0.000713985)
found -4.48 (+-0.000351937) 24.9341 (+-0.107787) 5.00011 (+-0.000713787)
found 3.68 (+-0.000395042) 19.9475 (+-0.0964571) 4.00013 (+-0.000638756)
found -4.96 (+-0.000457795) 14.9609 (+-0.0835755) 3.00014 (+-0.000553452)
found 0.800001 (+-0.000457141) 14.9607 (+-0.0835586) 3.00012 (+-0.00055334)
found 7.04 (+-0.00045427) 14.9604 (+-0.0834887) 3.00006 (+-0.000552877)
found 7.52 (+-0.000457033) 14.9608 (+-0.083558) 3.00013 (+-0.000553336)
found 6.56 (+-0.000453573) 14.9604 (+-0.0834726) 3.00005 (+-0.00055277)
found -3.52 (+-0.000564502) 9.97424 (+-0.0683046) 2.00016 (+-0.000452326)
found 6.08 (+-0.000560398) 9.97388 (+-0.0682345) 2.00009 (+-0.000451861)
found 8.48 (+-0.000808808) 4.98768 (+-0.0483952) 1.0002 (+-0.000320482)
found -7.36 (+-0.000802874) 4.98733 (+-0.0483397) 1.00012 (+-0.000320114)
found -9.75999 (+-0.000793689) 4.98708 (+-0.0482611) 1.00007 (+-0.000319594)
#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()